blob: 045162ace774b236a42c4d43427d9eff7c352cb9 [file] [log] [blame]
ilanap31742c92019-01-03 14:36:38 +02001#!/bin/bash
2
3
ilanap31742c92019-01-03 14:36:38 +02004# checking some stuff for local run
5if [ -z "$BUILD_NUMBER" ]
6then
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
ilanap5f063222019-08-05 14:10:34 +030016 IMAGES_TAG=1.5-STAGING-latest
ilanap31742c92019-01-03 14:36:38 +020017 fi
ilanap31742c92019-01-03 14:36:38 +020018fi
ilanapbf362442019-01-06 15:40:21 +020019echo "Workspace under: $WORKSPACE"
ilanap31742c92019-01-03 14:36:38 +020020# add dynamic ports from kubernetes master
21if [ -z "$TEST_CI_BE_HOST" ]
22then
23 TEST_CI_BE_HOST="$(ifconfig 'eth0' | sed -n '2p' | awk '{print $2}' | sed 's/addr://g')"
ilanape5d23232019-01-30 12:50:04 +020024 TEST_CI_BE_PORT=8081
ilanap31742c92019-01-03 14:36:38 +020025 TEST_CI_CATALOG_HOST=$TEST_CI_BE_HOST
ilanap31742c92019-01-03 14:36:38 +020026fi
ilanape53320e2019-02-04 14:15:11 +020027if [ -z "$TEST_CI_CATALOG_PORT" ]
28then
29 TEST_CI_CATALOG_PORT=8080
30fi
ilanap31742c92019-01-03 14:36:38 +020031echo "host $TEST_CI_BE_HOST"
32
ilanapbf362442019-01-06 15:40:21 +020033if [ -e "$WORKSPACE/data" ]
ilanap31742c92019-01-03 14:36:38 +020034then
ilanapbf362442019-01-06 15:40:21 +020035 rm -Rf $WORKSPACE/data
ilanap31742c92019-01-03 14:36:38 +020036fi
37
38
ilanapbf362442019-01-06 15:40:21 +020039mkdir -p $WORKSPACE/data/logs/cucumber
40mkdir -p $WORKSPACE/data/scripts
41mkdir -p $WORKSPACE/data/environments
ilanap31742c92019-01-03 14:36:38 +020042
ilanapbf362442019-01-06 15:40:21 +020043cp $WORKSPACE/sdc-os-chef/environments/Template.json $WORKSPACE/TEST_CI.json
44cp $WORKSPACE/sdc-os-chef/scripts/docker_run.sh $WORKSPACE/data/scripts
45cp $WORKSPACE/cucumber-js-test-apis-ci/config.json $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020046
47
ilanapbf362442019-01-06 15:40:21 +020048chmod 777 $WORKSPACE/data/scripts/docker_run.sh
ilanap31742c92019-01-03 14:36:38 +020049
ilanapbf362442019-01-06 15:40:21 +020050sed -i "s/xxx/TEST_CI/g" $WORKSPACE/TEST_CI.json
51sed -i "s/yyy/$TEST_CI_BE_HOST/g" $WORKSPACE/TEST_CI.json
ilanapbf362442019-01-06 15:40:21 +020052mv $WORKSPACE/TEST_CI.json $WORKSPACE/data/environments
ilanap31742c92019-01-03 14:36:38 +020053
ilanape53320e2019-02-04 14:15:11 +020054sed -i "s/8080:8080/$TEST_CI_CATALOG_PORT:8080/g" $WORKSPACE/data/scripts/docker_run.sh
55sed -i "s/:8080\/sdc/:$TEST_CI_CATALOG_PORT\/sdc/g" $WORKSPACE/data/scripts/docker_run.sh
56
ilanap31742c92019-01-03 14:36:38 +020057echo "getting images for $IMAGES_TAG"
ilanape53320e2019-02-04 14:15:11 +020058$WORKSPACE/data/scripts/docker_run.sh -e TEST_CI -r $IMAGES_TAG -p 10001
ilanap31742c92019-01-03 14:36:38 +020059
60echo "setting configuration"
61
ilanapbf362442019-01-06 15:40:21 +020062sed -i "s/onboarding.port/$TEST_CI_BE_PORT/g" $WORKSPACE/data/environments/dockerConfig.json
63sed -i "s/onboarding.server/$TEST_CI_BE_HOST/g" $WORKSPACE/data/environments/dockerConfig.json
64sed -i "s/onboarding.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json
ilanapbf362442019-01-06 15:40:21 +020065sed -i "s/CatalogBE.port/$TEST_CI_CATALOG_PORT/g" $WORKSPACE/data/environments/dockerConfig.json
66sed -i "s/CatalogBE.server/$TEST_CI_CATALOG_HOST/g" $WORKSPACE/data/environments/dockerConfig.json
67sed -i "s/CatalogBE.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020068
ilanapbf362442019-01-06 15:40:21 +020069cat $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020070
71echo "time to run the cucumber"
72
73# TODO check status and tar stuff
74docker 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
ilanapbf362442019-01-06 15:40:21 +020075echo "Checking exit status"
ilanap31742c92019-01-03 14:36:38 +020076DOCKER_ID=`docker ps -a --filter name="cucumber-sdc-api-test" --format "{{.ID}}"`
ilanapbf362442019-01-06 15:40:21 +020077EXIT_STATUS=`docker inspect --format='{{.State.ExitCode}}' $DOCKER_ID`
78docker rm -f $DOCKER_ID
79echo "Exit status: $EXIT_STATUS"
80echo " logs can be found under $WORKSPACE/data/logs"
ilanap31742c92019-01-03 14:36:38 +020081
82echo "removing all the dockers"
83docker ps -a --filter "name=sdc-" | grep $IMAGES_TAG | cut -d " " -f1 | xargs docker rm -f
84
85exit $EXIT_STATUS
ilanapbf362442019-01-06 15:40:21 +020086