4 echo "usage: setup_sdc_for_sanity.sh {tad|tud}"
5 echo "setup sdc and run api test suite: setup_sdc_for_sanity.sh tad"
6 echo "setup sdc and run ui test suite: setup_sdc_for_sanity.sh tud"
9 # returns 0: if SDC_LOCAL_IMAGES is set to true value
10 # returns 1: otherwise
11 function using_local_images {
12 SDC_LOCAL_IMAGES=$(echo "${SDC_LOCAL_IMAGES}" | tr '[:upper:]' '[:lower:]')
14 case "$SDC_LOCAL_IMAGES" in
26 echo "This is ${WORKSPACE}/scripts/sdc/setup_sdc_for_sanity.sh"
29 if [ "$1" != "tad" ] && [ "$1" != "tud" ]; then
34 # Clone sdc enviroment template
35 mkdir -p ${WORKSPACE}/data/environments/
36 mkdir -p ${WORKSPACE}/data/clone/
38 cd ${WORKSPACE}/data/clone
39 if using_local_images && [ -n "$SDC_LOCAL_GITREPO" ] ; then
40 if [ -d "$SDC_LOCAL_GITREPO" ] ; then
42 cp -a "$SDC_LOCAL_GITREPO" ./sdc
44 echo "[ERROR]: Local git repo for sdc does not exist: ${SDC_LOCAL_GITREPO}"
48 git clone --depth 1 http://gerrit.onap.org/r/sdc -b ${GERRIT_BRANCH}
51 chmod -R 777 ${WORKSPACE}/data/clone
53 # set enviroment variables
55 export ENV_NAME='CSIT'
56 export MR_IP_ADDR='10.0.0.1'
60 IP_ADDRESS=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
61 export HOST_IP=$IP_ADDRESS
63 # setup enviroment json
65 cat ${WORKSPACE}/data/clone/sdc/sdc-os-chef/environments/Template.json | sed "s/yyy/"$IP_ADDRESS"/g" > ${WORKSPACE}/data/environments/$ENV_NAME.json
66 sed -i "s/xxx/"$ENV_NAME"/g" ${WORKSPACE}/data/environments/$ENV_NAME.json
67 sed -i "s/\"ueb_url_list\":.*/\"ueb_url_list\": \""$MR_IP_ADDR","$MR_IP_ADDR"\",/g" ${WORKSPACE}/data/environments/$ENV_NAME.json
68 sed -i "s/\"fqdn\":.*/\"fqdn\": [\""$MR_IP_ADDR"\", \""$MR_IP_ADDR"\"]/g" ${WORKSPACE}/data/environments/$ENV_NAME.json
70 cp ${WORKSPACE}/data/clone/sdc/sdc-os-chef/scripts/docker_run.sh ${WORKSPACE}/scripts/sdc/
72 source ${WORKSPACE}/data/clone/sdc/version.properties
73 export RELEASE=$major.$minor-STAGING-latest
75 if using_local_images ; then
76 if [ -n "$SDC_LOCAL_TAG" ] ; then
77 RELEASE="$SDC_LOCAL_TAG"
78 elif [ -z "$SDC_LOCAL_GITREPO" ] ; then
79 echo "[WARNING]: Local images used but no tag and no source (git repo) provided for them - we will use tag 'latest'"
83 echo "[INFO]: We will use the locally built images (tag: ${RELEASE})"
84 ${WORKSPACE}/scripts/sdc/docker_run.sh \
88 -p 10001 -${TEST_SUITE}
90 echo "[INFO]: We will download images from the default registry (tag: ${RELEASE})"
91 ${WORKSPACE}/scripts/sdc/docker_run.sh \
94 -p 10001 -${TEST_SUITE}
99 # This file is sourced in another script which is out of our control...
103 # The code below for example does nothing and breaks immediately (running locally at least)
104 # Also it is very fragile: empty CID variable and broken docker command...
106 #monitor test processes
112 CID=`docker ps | grep tests | awk '{print $1}'`
114 while [ "$TIME" -lt "$TIME_OUT" ]; do
116 PID=`docker exec -i $CID ps -ef | grep java | awk '{print $1}'`
118 echo sanity PID is -- $PID
122 echo SDC sanity finished in $TIME seconds
126 echo Sleep: $INTERVAL seconds before testing if SDC sanity completed. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
128 TIME=$(($TIME+$INTERVAL))
131 if [ "$TIME" -ge "$TIME_OUT" ]
133 echo TIME OUT: SDC sanity was NOT completed in $TIME_OUT seconds... Could cause problems for tests...