diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2eb7da69dbeb8bdeaa1fbab8fc7e4053480a716f..a71870cdca3ece49bf90eb5e82ba1b04dc9737e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ ## © University of Southampton IT Innovation Centre, 2018 ## ## Copyright in this software belongs to University of Southampton -## IT Innovation Centre of Gamma House, Enterprise Road, +## IT Innovation Centre of Gamma House, Enterprise Road, ## Chilworth Science Park, Southampton, SO16 7NS, UK. ## ## This software may not be used, sold, licensed, transferred, copied @@ -18,7 +18,7 @@ ## Created By : Michael Boniface ## Created Date : 21-03-2018 ## Created for Project : FLAME -stages: +stages: - build - test - clean @@ -26,13 +26,13 @@ stages: build:tests: stage: build only: - - schedules - script: + - schedules + script: - echo $CI_PROJECT_DIR - cd $CI_PROJECT_DIR/src/test - python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build - cd $CI_PROJECT_DIR/src/service - - python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build + - python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build artifacts: paths: - build/clmctest-SNAPSHOT.tar.gz @@ -42,28 +42,28 @@ build:tests: test:all: stage: test only: - - schedules - dependencies: + - schedules + dependencies: - build:tests script: - - echo "REPO_USER=${REPO_USER}" > $CI_PROJECT_DIR/reporc + - echo "REPO_USER=${REPO_USER}" > $CI_PROJECT_DIR/reporc - echo "REPO_PASS=${REPO_PASS}" >> $CI_PROJECT_DIR/reporc - - sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR + - sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR -c all - sudo mkdir /var/lib/lxc/test-runner/rootfs/vagrant/build - sudo cp build/clmctest-SNAPSHOT.tar.gz /var/lib/lxc/test-runner/rootfs/vagrant/build - sudo cp build/clmcservice-SNAPSHOT.tar.gz /var/lib/lxc/test-runner/rootfs/vagrant/build - sudo lxc-attach -n test-runner -- pip3 install /vagrant/build/clmctest-SNAPSHOT.tar.gz - sudo lxc-attach -n test-runner -- pip3 install /vagrant/build/clmcservice-SNAPSHOT.tar.gz - sudo lxc-attach -n test-runner -- pytest -s --tb=short -rfp --pyargs clmctest.scripts - - sudo lxc-attach -n test-runner -- pytest -s --tb=short -rfp --pyargs clmcservice.tests + - sudo lxc-attach -n test-runner -- pytest -s --tb=short -rfp --pyargs clmcservice.tests - sudo lxc-attach -n test-runner -- pytest -s --tb=short -rfp --pyargs clmctest.inputs - sudo lxc-attach -n test-runner -- pytest -s --tb=short -rfp --pyargs clmctest.monitoring - when: on_success - + when: on_success + clean: stage: clean only: - - schedules - script: + - schedules + script: - sudo scripts/test/fixture.sh destroy -f src/test/clmctest/rspec.json - when: always + when: always diff --git a/README.md b/README.md index 3a99361f29da50ae484a367087c293cfaf68fbc7..0c12639f257a9e77292e0df2ec817ba9903b320c 100644 --- a/README.md +++ b/README.md @@ -62,14 +62,14 @@ SSH into the VM The containers are controlled using a script called /vagrant/scripts/test/fixtures.sh ``` -Usage: fixture.sh create|start|stop|destroy [-f config_file] [-r repo_root] [-c service_name]" +Usage: fixture.sh create|start|stop|destroy [-f config_file] [-r repo_root] [-c container_name|all]" ``` To create all the services needed for integration tests ``` sudo su -/vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json +/vagrant/scripts/test/fixture.sh create -f /vagrant/src/test/clmctest/rspec.json -c all ``` The containers created are defined an rspec.json file, there's an example here `/vagrant/src/test/clmctest/rspec.json` diff --git a/scripts/test/fixture.sh b/scripts/test/fixture.sh index 907d675215c77785b30c5c9b0757de470af23f7c..2c53069084df68fa055af52fdac5ba966579da3b 100755 --- a/scripts/test/fixture.sh +++ b/scripts/test/fixture.sh @@ -1,7 +1,7 @@ #!/bin/bash usage() { - echo "Usage: $0 create|start|stop|destroy [-f config_file] [-r repo_root] [-c service_name]" 1>&2 + echo "Usage: $0 create|start|stop|destroy [-f config_file] [-r repo_root] [-c container_name|all]" 1>&2 exit 1 } @@ -182,12 +182,19 @@ if [ ! -d ${repo_root} ]; then exit 1 fi +# check a service has been defined +if [ -z ${container} ]; then + echo "A container must be named: use 'all' for all" + usage + exit 1 +fi + # iterate of list of services in configuration file command=$1 service_names=$(jq -r '.[].name' ${config_file}) for service_name in $service_names; do # if all or specific container - if [ -z ${container} ] || [ ${container} == ${service_name} ]; then + if [ ${container} = all -o ${container} = ${service_name} ]; then case "${command}" in create) create ${service_name} ${config_file} ${repo_root}