From 3e8098a2df71c7b11533051f096bb91fc7844652 Mon Sep 17 00:00:00 2001 From: chemistry_sourabh Date: Mon, 15 May 2017 01:45:04 -0400 Subject: [PATCH 1/2] Changed TGT version (+5 squashed commits) Squashed commits: [639b713] Fixed tgt [57c9d09] test [2a588f7] Changed to centos [a177944] Added ceph tag [8b29689] CI Final Commit (+1 squashed commit) Squashed commits: [50097a9] Commented docker files (+1 squashed commit) Squashed commits: [e4c0f50] Added comments (+6 squashed commits) Squashed commits: [14e426c] Update images [876b6bd] Repo change [2ae8ab0] Added new lines [314830d] Changed to docker hub [51c5d61] Added build status [2faa0b0] Dockerfile for environment (+1 squashed commit) Squashed commits: [c338292] Travis --- .travis.yml | 34 ++++++++++++++++++++++++- Dockerfile_ci | 23 +++++++++++++++++ Dockerfile_env | 47 +++++++++++++++++++++++++++++++++++ Dockerfile_env_centos | 58 +++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + docker/yum.repo | 23 +++++++++++++++++ 6 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 Dockerfile_ci create mode 100644 Dockerfile_env create mode 100644 Dockerfile_env_centos create mode 100644 docker/yum.repo diff --git a/.travis.yml b/.travis.yml index 3a2bc43..8230479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,42 @@ language: python python: - "2.7" +sudo: required + install: - pip install pep8 -script: +services: + - docker + +before_script: # Run pep8 on all .py files in all subfolders # ignore E402: module level import not at top of file - find . -name \*.py -exec pep8 --ignore=E402 {} + + + # Run Ceph Container and Wait for some time so that ceph runs + - sudo docker run -d -v ceph:/etc/ceph -e MON_IP=172.17.0.2 -e CEPH_PUBLIC_NETWORK=172.17.0.0/24 --name ceph ceph/demo:tag-build-master-hammer-centos-7 + - sleep 30 + + # Run HIL Container + - sudo docker run -d --name hil bmis/hil + + # Build BMI Container From Environment Image + - sudo docker pull bmis/bmi-ci + - sudo docker build -t bmi-test -f Dockerfile_ci . + - sudo docker run -d -v ceph:/etc/ceph --name bmi bmi-test + + # Just for debugging purposes to check if all containers run + - sudo docker ps + + # Insert Image into Ceph using ceph client in BMI Container + - sudo docker exec bmi rbd create --image-format 2 --size 10 bmi_test + +script: + # Run Tests in BMI container + - sudo docker exec bmi pytest -v --random-order-bucket=global --ignore tests/unit/picasso tests/ + +after_script: + # Extract and Upload logs for debugging incase of failure + - sudo docker cp bmi:/var/log/bmi/ims.log ./ims.log + - curl -sT ./ims.log chunk.io diff --git a/Dockerfile_ci b/Dockerfile_ci new file mode 100644 index 0000000..6cb3456 --- /dev/null +++ b/Dockerfile_ci @@ -0,0 +1,23 @@ +# This will be by CI tool to build BMI image that will be used for testing. + +# Basing on image stored in docker hub for faster build +FROM bmis/bmi-ci + +# Copy source code +USER bmi +COPY ims/ /home/bmi/ims/ +COPY tests/ /home/bmi/tests/ +COPY scripts/ /home/bmi/scripts/ +COPY setup.py /home/bmi/setup.py + +# Install +USER root +WORKDIR /home/bmi +RUN python setup.py develop + +# Create DB +USER bmi +RUN bmi db ls + +# Start dependencies when container starts +CMD dumb-init /home/bmi/runbmi.sh diff --git a/Dockerfile_env b/Dockerfile_env new file mode 100644 index 0000000..e8a1bde --- /dev/null +++ b/Dockerfile_env @@ -0,0 +1,47 @@ +# This File is to create the image for BMI environment. +# It will install all dependencies and create the required folder structure +# The CI Tool will just create a new image based of this and run tests + +# Using ubuntu as base +FROM ubuntu + +# Install all dependencies except dnsmasq +RUN apt-get -y update && apt-get install -y tgt-rbd ceph-common python python-dev python-setuptools build-essential python-pip sudo sqlite3 git + +# Install test stuff +RUN pip install dumb-init pytest pytest-random-order + +# Create user and remove password for root +RUN useradd -ms /bin/bash bmi +RUN passwd -d bmi +RUN passwd -d root +RUN usermod -aG sudo bmi + +# Create required folders +RUN mkdir /etc/bmi/ +RUN mkdir /var/log/bmi/ +RUN mkdir /var/lib/tftpboot/ +RUN mkdir /var/lib/tftpboot/pxelinux.cfg/ +RUN mkdir /var/lib/bmi/ + +# Add config file +COPY docker/bmi_config.cfg /etc/bmi/bmiconfig.cfg +ENV BMI_CONFIG=/etc/bmi/bmiconfig.cfg + +# Set Permissions +RUN chown bmi:bmi /etc/tgt/conf.d/ +RUN chown bmi:bmi /var/log/bmi/ +RUN chown bmi:bmi /var/lib/tftpboot/ +RUN chown bmi:bmi /var/lib/tftpboot/pxelinux.cfg/ +RUN chown bmi:bmi /var/lib/bmi/ + +# Add the BMI execute script +COPY docker/runbmi.sh /home/bmi/runbmi.sh +RUN chmod a+x /home/bmi/runbmi.sh + +# Set Environment variables +ENV HAAS_USERNAME=admin +ENV HAAS_PASSWORD=admin + +# Expose as volume to get keyring and ceph config +VOLUME /etc/ceph diff --git a/Dockerfile_env_centos b/Dockerfile_env_centos new file mode 100644 index 0000000..eb45966 --- /dev/null +++ b/Dockerfile_env_centos @@ -0,0 +1,58 @@ +# This File is to create the image for BMI environment. +# It will install all dependencies and create the required folder structure +# The CI Tool will just create a new image based of this and run tests + +# Using ubuntu as base +FROM centos + +# Install all dependencies except dnsmasq +RUN yum install -y epel-release +RUN rpm --import 'https://download.ceph.com/keys/release.asc' +COPY docker/yum.repo /etc/yum.repos.d/ceph.repo +RUN yum -y update && yum install -y ceph-common-0.94.9 librbd1-devel-0.94.9 librados2-devel-0.94.9 python python-setuptools python-pip sudo sqlite cpan perl-Config-General libxslt-devel git make gcc + +# Install test stuff +RUN pip install dumb-init pytest pytest-random-order coverage==4.3 pytest-cov coveralls + +RUN git clone https://github.com/fujita/tgt +WORKDIR tgt/ +RUN git reset --hard 3c8c9e96b82d87a334b1d340fa29218b7b94f26d +RUN sudo make CEPH_RBD=1 clean +RUN sudo make CEPH_RBD=1 +RUN sudo make CEPH_RBD=1 install + +WORKDIR ../ +# Create user and remove password for root +RUN useradd -ms /bin/bash bmi +RUN passwd -d bmi +RUN passwd -d root +RUN usermod -aG wheel bmi + +# Create required folders +RUN mkdir /etc/bmi/ +RUN mkdir /var/log/bmi/ +RUN mkdir /var/lib/tftpboot/ +RUN mkdir /var/lib/tftpboot/pxelinux.cfg/ +RUN mkdir /var/lib/bmi/ + +# Add config file +COPY docker/bmi_config.cfg /etc/bmi/bmiconfig.cfg +ENV BMI_CONFIG=/etc/bmi/bmiconfig.cfg + +# Set Permissions +RUN chown bmi:bmi /etc/tgt/conf.d/ +RUN chown bmi:bmi /var/log/bmi/ +RUN chown bmi:bmi /var/lib/tftpboot/ +RUN chown bmi:bmi /var/lib/tftpboot/pxelinux.cfg/ +RUN chown bmi:bmi /var/lib/bmi/ + +# Add the BMI execute script +COPY docker/runbmi.sh /home/bmi/runbmi.sh +RUN chmod a+x /home/bmi/runbmi.sh + +# Set Environment variables +ENV HAAS_USERNAME=admin +ENV HAAS_PASSWORD=admin + +# Expose as volume to get keyring and ceph config +VOLUME /etc/ceph diff --git a/README.md b/README.md index 64754df..3ec7a2d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://travis-ci.org/CCI-MOC/ims.svg?branch=dev)](https://travis-ci.org/CCI-MOC/ims) # BMI The Bare Metal Imaging (BMI) is a core component of the Massachusetts Open Cloud and an Image Management System(IMS) that diff --git a/docker/yum.repo b/docker/yum.repo new file mode 100644 index 0000000..3bdeff7 --- /dev/null +++ b/docker/yum.repo @@ -0,0 +1,23 @@ +[ceph] +name=Ceph packages for $basearch +baseurl=https://download.ceph.com/rpm-hammer/el7/$basearch +enabled=1 +priority=2 +gpgcheck=1 +gpgkey=https://download.ceph.com/keys/release.asc + +[ceph-noarch] +name=Ceph noarch packages +baseurl=https://download.ceph.com/rpm-hammer/el7/noarch +enabled=1 +priority=2 +gpgcheck=1 +gpgkey=https://download.ceph.com/keys/release.asc + +[ceph-source] +name=Ceph source packages +baseurl=https://download.ceph.com/rpm-hammer/el7/SRPMS +enabled=0 +priority=2 +gpgcheck=1 +gpgkey=https://download.ceph.com/keys/release.asc \ No newline at end of file From e6733086949a243dce8b820e92fdceccd3bf5f71 Mon Sep 17 00:00:00 2001 From: chemistry_sourabh Date: Tue, 6 Jun 2017 20:26:31 -0400 Subject: [PATCH 2/2] Coverage --- .travis.yml | 7 +++++-- Dockerfile_ci | 1 + Dockerfile_env | 2 +- README.md | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8230479..beeefa8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ before_script: # Build BMI Container From Environment Image - sudo docker pull bmis/bmi-ci - sudo docker build -t bmi-test -f Dockerfile_ci . - - sudo docker run -d -v ceph:/etc/ceph --name bmi bmi-test + - sudo docker run -d -e TRAVIS=$TRAVIS -e TRAVIS_JOB_ID=$TRAVIS_JOB_ID -e TRAVIS_BRANCH=$TRAVIS_BRANCH -v ceph:/etc/ceph --name bmi bmi-test # Just for debugging purposes to check if all containers run - sudo docker ps @@ -35,8 +35,11 @@ before_script: script: # Run Tests in BMI container - - sudo docker exec bmi pytest -v --random-order-bucket=global --ignore tests/unit/picasso tests/ + - sudo docker exec bmi pytest -v --random-order-bucket=global --cov=ims --ignore tests/unit/picasso tests/ +after_success: + # Submit Coverage to Coveralls + - sudo docker exec bmi coveralls after_script: # Extract and Upload logs for debugging incase of failure - sudo docker cp bmi:/var/log/bmi/ims.log ./ims.log diff --git a/Dockerfile_ci b/Dockerfile_ci index 6cb3456..d87c9c0 100644 --- a/Dockerfile_ci +++ b/Dockerfile_ci @@ -5,6 +5,7 @@ FROM bmis/bmi-ci # Copy source code USER bmi +COPY .git/ /home/bmi/.git COPY ims/ /home/bmi/ims/ COPY tests/ /home/bmi/tests/ COPY scripts/ /home/bmi/scripts/ diff --git a/Dockerfile_env b/Dockerfile_env index e8a1bde..a0cccfe 100644 --- a/Dockerfile_env +++ b/Dockerfile_env @@ -9,7 +9,7 @@ FROM ubuntu RUN apt-get -y update && apt-get install -y tgt-rbd ceph-common python python-dev python-setuptools build-essential python-pip sudo sqlite3 git # Install test stuff -RUN pip install dumb-init pytest pytest-random-order +RUN pip install dumb-init pytest pytest-random-order coverage==4.3 pytest-cov coveralls # Create user and remove password for root RUN useradd -ms /bin/bash bmi diff --git a/README.md b/README.md index 3ec7a2d..3333d65 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/CCI-MOC/ims.svg?branch=dev)](https://travis-ci.org/CCI-MOC/ims) +[![Coverage Status](https://coveralls.io/repos/github/CCI-MOC/ims/badge.svg?branch=dev)](https://coveralls.io/github/CCI-MOC/ims?branch=dev) # BMI The Bare Metal Imaging (BMI) is a core component of the Massachusetts Open Cloud and an Image Management System(IMS) that