blob: 0e52a6bcbd5e7a40c8aac9338dc59c5abbcf2148 [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
16 IMAGES_TAG=1.4-STAGING-latest
17 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
21# add dynamic ports from kubernetes master
22if [ -z "$TEST_CI_BE_HOST" ]
23then
24 TEST_CI_BE_HOST="$(ifconfig 'eth0' | sed -n '2p' | awk '{print $2}' | sed 's/addr://g')"
25 TEST_CI_BE_PORT=8285
26 TEST_CI_CATALOG_HOST=$TEST_CI_BE_HOST
27 TEST_CI_CATALOG_PORT=$TEST_CI_BE_PORT
28 TEST_CI_AP_HOST=$TEST_CI_BE_HOST
29 TEST_CI_AP_PORT=8080
30fi
31
32
33echo "host $TEST_CI_BE_HOST"
34
ilanapbf362442019-01-06 15:40:21 +020035if [ -e "$WORKSPACE/data" ]
ilanap31742c92019-01-03 14:36:38 +020036then
ilanapbf362442019-01-06 15:40:21 +020037 rm -Rf $WORKSPACE/data
ilanap31742c92019-01-03 14:36:38 +020038fi
39
40
ilanapbf362442019-01-06 15:40:21 +020041mkdir -p $WORKSPACE/data/logs/cucumber
42mkdir -p $WORKSPACE/data/scripts
43mkdir -p $WORKSPACE/data/environments
ilanap31742c92019-01-03 14:36:38 +020044
ilanapbf362442019-01-06 15:40:21 +020045cp $WORKSPACE/sdc-os-chef/environments/Template.json $WORKSPACE/TEST_CI.json
46cp $WORKSPACE/sdc-os-chef/scripts/docker_run.sh $WORKSPACE/data/scripts
47cp $WORKSPACE/cucumber-js-test-apis-ci/config.json $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020048
49
ilanapbf362442019-01-06 15:40:21 +020050chmod 777 $WORKSPACE/data/scripts/docker_run.sh
ilanap31742c92019-01-03 14:36:38 +020051
ilanapbf362442019-01-06 15:40:21 +020052sed -i "s/xxx/TEST_CI/g" $WORKSPACE/TEST_CI.json
53sed -i "s/yyy/$TEST_CI_BE_HOST/g" $WORKSPACE/TEST_CI.json
54sed -i "s/8080/$TEST_CI_BE_PORT/g" $WORKSPACE/TEST_CI.json
55mv $WORKSPACE/TEST_CI.json $WORKSPACE/data/environments
ilanap31742c92019-01-03 14:36:38 +020056
57echo "getting images for $IMAGES_TAG"
ilanap31742c92019-01-03 14:36:38 +020058$WORKSPACE/data/scripts/docker_run.sh -e TEST_CI -r $IMAGES_TAG -sim -p 10001
59
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
65sed -i "s/vf.port/$TEST_CI_BE_PORT/g" $WORKSPACE/data/environments/dockerConfig.json
66sed -i "s/vf.server/$TEST_CI_BE_HOST/g" $WORKSPACE/data/environments/dockerConfig.json
67sed -i "s/vf.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json
68sed -i "s/CatalogBE.port/$TEST_CI_CATALOG_PORT/g" $WORKSPACE/data/environments/dockerConfig.json
69sed -i "s/CatalogBE.server/$TEST_CI_CATALOG_HOST/g" $WORKSPACE/data/environments/dockerConfig.json
70sed -i "s/CatalogBE.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json
71sed -i "s/activity_spec.port/$TEST_CI_AP_PORT/g" $WORKSPACE/data/environments/dockerConfig.json
72sed -i "s/activity_spec.server/$TEST_CI_AP_HOST/g" $WORKSPACE/data/environments/dockerConfig.json
73sed -i "s/activity_spec.user/cs0008/g" $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020074
ilanapbf362442019-01-06 15:40:21 +020075cat $WORKSPACE/data/environments/dockerConfig.json
ilanap31742c92019-01-03 14:36:38 +020076
77echo "time to run the cucumber"
78
79# TODO check status and tar stuff
80docker 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 +020081echo "Checking exit status"
ilanap31742c92019-01-03 14:36:38 +020082DOCKER_ID=`docker ps -a --filter name="cucumber-sdc-api-test" --format "{{.ID}}"`
ilanapbf362442019-01-06 15:40:21 +020083EXIT_STATUS=`docker inspect --format='{{.State.ExitCode}}' $DOCKER_ID`
84docker rm -f $DOCKER_ID
85echo "Exit status: $EXIT_STATUS"
86echo " logs can be found under $WORKSPACE/data/logs"
ilanap31742c92019-01-03 14:36:38 +020087
88echo "removing all the dockers"
89docker ps -a --filter "name=sdc-" | grep $IMAGES_TAG | cut -d " " -f1 | xargs docker rm -f
90
91exit $EXIT_STATUS
ilanapbf362442019-01-06 15:40:21 +020092