ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 4 | # checking some stuff for local run |
| 5 | if [ -z "$BUILD_NUMBER" ] |
| 6 | then |
| 7 | if [ -z "$WORKSPACE" ] |
| 8 | then |
| 9 | currentDir=`pwd` |
| 10 | cd ../ |
| 11 | WORKSPACE=`pwd` |
| 12 | cd $currentDir |
| 13 | fi |
| 14 | if [ -z "$IMAGES_TAG" ] |
| 15 | then |
ilanap | 5f06322 | 2019-08-05 14:10:34 +0300 | [diff] [blame] | 16 | IMAGES_TAG=1.5-STAGING-latest |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 17 | fi |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 18 | fi |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 19 | echo "Workspace under: $WORKSPACE" |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 20 | # add dynamic ports from kubernetes master |
| 21 | if [ -z "$TEST_CI_BE_HOST" ] |
| 22 | then |
| 23 | TEST_CI_BE_HOST="$(ifconfig 'eth0' | sed -n '2p' | awk '{print $2}' | sed 's/addr://g')" |
ilanap | e5d2323 | 2019-01-30 12:50:04 +0200 | [diff] [blame] | 24 | TEST_CI_BE_PORT=8081 |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 25 | TEST_CI_CATALOG_HOST=$TEST_CI_BE_HOST |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 26 | fi |
ilanap | e53320e | 2019-02-04 14:15:11 +0200 | [diff] [blame] | 27 | if [ -z "$TEST_CI_CATALOG_PORT" ] |
| 28 | then |
| 29 | TEST_CI_CATALOG_PORT=8080 |
| 30 | fi |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 31 | echo "host $TEST_CI_BE_HOST" |
| 32 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 33 | if [ -e "$WORKSPACE/data" ] |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 34 | then |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 35 | rm -Rf $WORKSPACE/data |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 36 | fi |
| 37 | |
| 38 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 39 | mkdir -p $WORKSPACE/data/logs/cucumber |
| 40 | mkdir -p $WORKSPACE/data/scripts |
| 41 | mkdir -p $WORKSPACE/data/environments |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 42 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 43 | cp $WORKSPACE/sdc-os-chef/environments/Template.json $WORKSPACE/TEST_CI.json |
| 44 | cp $WORKSPACE/sdc-os-chef/scripts/docker_run.sh $WORKSPACE/data/scripts |
| 45 | cp $WORKSPACE/cucumber-js-test-apis-ci/config.json $WORKSPACE/data/environments/dockerConfig.json |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 46 | |
| 47 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 48 | chmod 777 $WORKSPACE/data/scripts/docker_run.sh |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 49 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 50 | sed -i "s/xxx/TEST_CI/g" $WORKSPACE/TEST_CI.json |
| 51 | sed -i "s/yyy/$TEST_CI_BE_HOST/g" $WORKSPACE/TEST_CI.json |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 52 | mv $WORKSPACE/TEST_CI.json $WORKSPACE/data/environments |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 53 | |
ilanap | e53320e | 2019-02-04 14:15:11 +0200 | [diff] [blame] | 54 | sed -i "s/8080:8080/$TEST_CI_CATALOG_PORT:8080/g" $WORKSPACE/data/scripts/docker_run.sh |
| 55 | sed -i "s/:8080\/sdc/:$TEST_CI_CATALOG_PORT\/sdc/g" $WORKSPACE/data/scripts/docker_run.sh |
| 56 | |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 57 | echo "getting images for $IMAGES_TAG" |
ilanap | e53320e | 2019-02-04 14:15:11 +0200 | [diff] [blame] | 58 | $WORKSPACE/data/scripts/docker_run.sh -e TEST_CI -r $IMAGES_TAG -p 10001 |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 59 | |
| 60 | echo "setting configuration" |
| 61 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 62 | sed -i "s/onboarding.port/$TEST_CI_BE_PORT/g" $WORKSPACE/data/environments/dockerConfig.json |
| 63 | sed -i "s/onboarding.server/$TEST_CI_BE_HOST/g" $WORKSPACE/data/environments/dockerConfig.json |
| 64 | sed -i "s/onboarding.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 65 | sed -i "s/CatalogBE.port/$TEST_CI_CATALOG_PORT/g" $WORKSPACE/data/environments/dockerConfig.json |
| 66 | sed -i "s/CatalogBE.server/$TEST_CI_CATALOG_HOST/g" $WORKSPACE/data/environments/dockerConfig.json |
| 67 | sed -i "s/CatalogBE.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 68 | |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 69 | cat $WORKSPACE/data/environments/dockerConfig.json |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 70 | |
| 71 | echo "time to run the cucumber" |
| 72 | |
| 73 | # TODO check status and tar stuff |
| 74 | docker run --name cucumber-sdc-api-tests --volume $WORKSPACE/data/environments:/var/lib/tests/environments --volume $WORKSPACE/data/logs/cucumber:/var/lib/tests/report onap/cucumber-sdc-api-tests:latest |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 75 | echo "Checking exit status" |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 76 | DOCKER_ID=`docker ps -a --filter name="cucumber-sdc-api-test" --format "{{.ID}}"` |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 77 | EXIT_STATUS=`docker inspect --format='{{.State.ExitCode}}' $DOCKER_ID` |
| 78 | docker rm -f $DOCKER_ID |
| 79 | echo "Exit status: $EXIT_STATUS" |
| 80 | echo " logs can be found under $WORKSPACE/data/logs" |
ilanap | 31742c9 | 2019-01-03 14:36:38 +0200 | [diff] [blame] | 81 | |
| 82 | echo "removing all the dockers" |
| 83 | docker ps -a --filter "name=sdc-" | grep $IMAGES_TAG | cut -d " " -f1 | xargs docker rm -f |
| 84 | |
| 85 | exit $EXIT_STATUS |
ilanap | bf36244 | 2019-01-06 15:40:21 +0200 | [diff] [blame] | 86 | |