Add LVM CI job

This patch adds several CI jobs:

- PEP8
- Unit tests
- LVM

It also changes how we build our images. Now we only push a new image to
Docker Hub if the tests pass successfully.  And we only bother to build
the images if PEP8, Unit tests, and LVM jobs run successfully.
This commit is contained in:
Gorka Eguileor 2018-09-06 05:38:00 +02:00
parent 5b5213f48b
commit de1ee38d4d
11 changed files with 164 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Byte-compiled / optimized / DLL files
.*
!.gitignore
!.travis.yml
.*.sw?
__pycache__/
*.py[cod]

66
.travis.yml Normal file
View File

@ -0,0 +1,66 @@
language: python
python: 2.7
git:
quiet: true
jobs:
include:
- name: "PEP8"
stage: phase1-tests
sudo: false
script: make lint
- name: "Unit tests"
stage: phase1-tests
sudo: false
install: sudo pip install tox
script: tox -epy27
- name: "LVM baremetal master"
stage: phase2-tests
sudo: required
install:
- sudo travis-scripts/setup-lvm.sh
- sudo apt-get install -y open-iscsi targetcli multipath-tools
- sudo pip install git+https://github.com/openstack/cinder.git
- sudo pip install -e ./
script:
- sudo make functional-tests
- name: "LVM baremetal latest"
stage: phase2-tests
sudo: required
install:
- sudo travis-scripts/setup-lvm.sh
- sudo apt-get install -y open-iscsi targetcli multipath-tools
- sudo pip install git+https://github.com/openstack/cinder.git@stable/rocky
- sudo pip install -e ./
script:
- sudo make functional-tests
- name: "Image build"
stage: build
sudo: required
script:
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username "$DOCKER_USERNAME"
- travis-scripts/build
# Travis-CI only supports Ubuntu, which is incompatible with our images
# - name: "LVM"
# stage: sanity-checks
# sudo: required
# script:
# - sudo travis-scripts/setup-lvm.sh
# - sudo make ubuntu-lvm
- name: "Tag and push images"
stage: push
sudo: required
script:
- echo "$DOCKER_PASSWORD" | docker login --password-stdin --username "$DOCKER_USERNAME"
- travis-scripts/push
# Noop, each job hast its own requirements and we don't want to install
# requirements.txt
install: true

View File

@ -1,6 +1,7 @@
# Based on centos this image builds cinderlib master with Cinder master branch
FROM centos:7
ARG VERSION
ARG RELEASE
LABEL maintainers="Gorka Eguileor <geguileo@redhat.com>" \
description="Cinderlib" \
version=${VERSION:-master}

View File

@ -47,12 +47,18 @@ clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr htmlcov/
lint: ## check style with flake8
python-requirements:
pip install -r requirements_dev.txt
pip install -e .
lint: python-requirements ## check style with flake8
flake8 cinderlib tests
test: ## run tests quickly with the default Python
unit-tests:
tox -epy27
python setup.py test
functional-tests:
unit2 discover -v -s tests/functional
test-all: ## run tests on every Python version with tox
tox

View File

@ -8,7 +8,7 @@ logs: false
# LVM backend uses cinder-rtstool command that is installed by Cinder in the
# virtual environment, so we need the custom sudo command that inherits the
# virtualenv binaries PATH
venv_sudo: true
venv_sudo: false
# We only define one backend
backends:

13
travis-scripts/build Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
. "$DIR/set-tags"
set -ev
for tag_info_string in $TAGS; do
IFS=';' read -a tag_info <<< "$tag_info_string"
echo "Building ${tag_info[3]} using ${tag_info[0]} ..."
docker build --build-arg RELEASE=${tag_info[2]} --build-arg VERSION=${tag_info[1]} -t ${tag_info[3]} -f ${tag_info[0]} .
echo "Pusing ${tag_info[3]} ..."
docker push ${tag_info[3]}
done

View File

@ -0,0 +1,11 @@
+ubuntu-bm-lvm:
+ X_CSI_PERSISTENCE_CONFIG='{"storage":"memory"}' \
+ X_CSI_BACKEND_CONFIG='{"target_protocol":"iscsi","iscsi_ip_address":"127.0.0.1","volume_backend_name":"lvm","volume_driver":"cinder.volume.drivers.lvm.LVMVolumeDriver","volume_group":"ember-volumes","target_helper":"lioadm"}' \
+ X_CSI_EMBER_CONFIG='{"project_id":"io.ember-csi","user_id":"io.ember-csi","root_helper":"sudo","disable_logs":false,"debug":true,"request_multipath":false}' \
+ travis-scripts/run-bm-sanity.sh
+
+ubuntu-lvm:
+ X_CSI_PERSISTENCE_CONFIG='{"storage":"memory"}' \
+ X_CSI_BACKEND_CONFIG='{"target_protocol":"iscsi","iscsi_ip_address":"127.0.0.1","volume_backend_name":"lvm","volume_driver":"cinder.volume.drivers.lvm.LVMVolumeDriver","volume_group":"ember-volumes","target_helper":"lioadm"}' \
+ X_CSI_EMBER_CONFIG='{"project_id":"io.ember-csi","user_id":"io.ember-csi","root_helper":"sudo","disable_logs":false,"debug":true,"request_multipath":false}' \
+ travis-scripts/run-sanity.sh

27
travis-scripts/push Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
. "$DIR/set-tags"
set -ev
# Only push when tagging a release or making changes to master branch
if [[ "$TRAVIS_BRANCH" == "$TRAVIS_TAG" || ("$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false") ]]; then
for tag_info_string in $TAGS; do
IFS=';' read -a tag_info <<< "$tag_info_string"
echo "Pulling ${tag_info[3]} ..."
docker pull ${tag_info[3]}
echo "Retagging and pushing ${tag_info[4]} ..."
docker tag ${tag_info[3]} ${tag_info[4]}
docker push ${tag_info[4]}
if [ "${tag_info[5]}" == "stable" ]; then
echo "Setting stable tag ${tag_info[2]}"
docker tag ${tag_info[4]} ${FINAL_REPO}:${tag_info[2]}
docker push ${FINAL_REPO}:${tag_info[2]}
fi
done
# TODO: Trigger Ember-CSI jobs https://docs.travis-ci.com/user/triggering-builds/
else
echo "This is not a tag or a merge to master, skipping pushing to ember-csi"
fi

1
travis-scripts/rdo-releases Symbolic link
View File

@ -0,0 +1 @@
../hooks/rdo-releases

28
travis-scripts/set-tags Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
TRAVIS_REPO='akrog/travis-ci'
export FINAL_REPO='akrog/cinderlib'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Not a tag (merge to master, PR, or branch)
if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]; then
version=`git tag --sort=-v:refname|head -1`
release=`tail -1 hooks/rdo-releases`
sanitized_branch="${TRAVIS_BRANCH//\//_}"
travis_tag="${sanitized_branch}-PR${TRAVIS_PULL_REQUEST}"
TAGS=("Dockerfile;$version;$release;$TRAVIS_REPO:master-${travis_tag};$FINAL_REPO:master;unstable" \
"Dockerfile-latest;$version;$release;$TRAVIS_REPO:latest-${travis_tag};$FINAL_REPO:latest;unstable" )
else
releases=`cat $DIR/rdo-releases`
while read -r release; do
release_tag="${release}-cl_${TRAVIS_TAG}"
TAGS[$i]="Dockerfile-release;${TRAVIS_TAG};$release;$TRAVIS_REPO:$release_tag;$FINAL_REPO:$release_tag;stable"
i=$((i + 1))
done <<< "$releases"
fi
export TAGS="${TAGS[@]}"
echo "set-tags returns ${TAGS[@]}"

6
travis-scripts/setup-lvm.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ev
truncate -s 10G /root/cinder-volumes
lo_dev=`losetup --show -f /root/cinder-volumes`
vgcreate cinder-volumes $lo_dev
vgscan