Skip to content
Snippets Groups Projects
Commit 8eb66c56 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/81-fixture-script-makes-it-too-easy-to-destroy-everything-by-mistake' into clmcservice
parents ad6149d3 94633e30
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ test:all:
script:
- 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
......
......@@ -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`
......
#!/bin/bash
repo_root="/vagrant"
config_file="rspec.json"
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
echo " -f defaults to '${config_file}'" 1>&2
echo " -r defaults to '${repo_root}'" 1>&2
echo " -c must be specified, use 'all' for all" 1>&2
exit 1
}
......@@ -154,9 +160,6 @@ if [ $# -gt 1 ]; then
OPTIND=$((OPTIND+1))
fi
repo_root="/vagrant"
config_file="rspec.json"
# collect the optional arguments
while getopts "hf:r:c:" opt; do
case $opt in
......@@ -182,12 +185,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}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment