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"
10 # returns 0: if <variable name> is set to true value
11 # returns 1: otherwise
13 _value=$(eval echo "\$${1}" | tr '[:upper:]' '[:lower:]')
24 # returns 0: if SDC_LOCAL_IMAGES is set to true value
25 # returns 1: otherwise
26 function using_local_images {
27 is_true SDC_LOCAL_IMAGES
30 # returns 0: if SDC_TEST_HTTPS is set to true value
31 # returns 1: otherwise
32 function using_https {
33 is_true SDC_TEST_HTTPS
39 echo "This is ${WORKSPACE}/scripts/sdc/setup_sdc_for_sanity.sh"
42 if [ "$1" != "tad" ] && [ "$1" != "tud" ]; then
47 # Clone sdc enviroment template
48 mkdir -p "${WORKSPACE}/data/environments/"
49 mkdir -p "${WORKSPACE}/data/clone/"
51 cd "${WORKSPACE}/data/clone"
52 if using_local_images && [ -n "$SDC_LOCAL_GITREPO" ] ; then
53 SDC_LOCAL_GITREPO=$(realpath "$SDC_LOCAL_GITREPO")
54 if [ -d "$SDC_LOCAL_GITREPO" ] ; then
56 cp -a "$SDC_LOCAL_GITREPO" ./sdc
58 echo "[ERROR]: Local git repo for sdc does not exist: ${SDC_LOCAL_GITREPO}"
62 git clone --depth 1 http://gerrit.onap.org/r/sdc -b ${GERRIT_BRANCH}
66 chmod -R 777 "${WORKSPACE}/data/clone"
68 # set enviroment variables
70 export ENV_NAME='CSIT'
71 export MR_IP_ADDR='10.0.0.1'
72 export TEST_SUITE="$1"
75 IP_ADDRESS=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'`
76 export HOST_IP="$IP_ADDRESS"
78 # setup enviroment json
79 # TODO: use jq or find a better way altogether...
80 cp "${WORKSPACE}/data/clone/sdc/sdc-os-chef/environments/Template.json" \
81 "${WORKSPACE}/data/environments/$ENV_NAME.json"
83 -e "s/xxx/${ENV_NAME}/g" \
84 -e "s/yyy/${IP_ADDRESS}/g" \
85 -e "s/\"ueb_url_list\":.*/\"ueb_url_list\": \"${MR_IP_ADDR},${MR_IP_ADDR}\",/g" \
86 -e "s/\"fqdn\":.*/\"fqdn\": [\"${MR_IP_ADDR}\", \"${MR_IP_ADDR}\"]/g" \
87 "${WORKSPACE}/data/environments/$ENV_NAME.json"
89 # this is very fragile (as all above) and relies on the current state of Template.json in another project...
90 # using jq filters would be much better approach and no need for some "yyy"...
92 -e 's/"disableHttp":[[:space:]]*"\?[[:alnum:]]*"\?/"disableHttp": true/' \
93 "${WORKSPACE}/data/environments/$ENV_NAME.json"
96 cp "${WORKSPACE}/data/clone/sdc/sdc-os-chef/scripts/docker_run.sh" "${WORKSPACE}/scripts/sdc/"
98 source "${WORKSPACE}/data/clone/sdc/version.properties"
99 export RELEASE="${major}.${minor}-STAGING-latest"
101 if using_local_images ; then
102 if [ -n "$SDC_LOCAL_TAG" ] ; then
103 RELEASE="$SDC_LOCAL_TAG"
104 elif [ -z "$SDC_LOCAL_GITREPO" ] ; then
105 echo "[WARNING]: Local images used but no tag and no source (git repo) provided for them - we will use tag 'latest'"
109 echo "[INFO]: We will use the locally built images (tag: ${RELEASE})"
110 "${WORKSPACE}/scripts/sdc/docker_run.sh" \
114 -p 10001 "-${TEST_SUITE}"
116 echo "[INFO]: We will download images from the default registry (tag: ${RELEASE})"
117 ${WORKSPACE}/scripts/sdc/docker_run.sh \
120 -p 10001 "-${TEST_SUITE}"
123 # final step if the robot test needs to be adjusted
124 # TODO: again grab the values from Template directly with jq
125 # jq should be mandatory installed package (is it?)
126 if using_https ; then
127 ROBOT_VARIABLES="${ROBOT_VARIABLES} \
128 -v SDC_FE_PROTOCOL:https \
129 -v SDC_FE_PORT:9443 \
130 -v SDC_BE_PROTOCOL:https \
131 -v SDC_BE_PORT:8443 \
132 -v SDC_ONBOARDING_BE_PROTOCOL:https \
133 -v SDC_ONBOARDING_BE_PORT:8443 \
136 ROBOT_VARIABLES="${ROBOT_VARIABLES} \
137 -v SDC_FE_PROTOCOL:http \
138 -v SDC_FE_PORT:8181 \
139 -v SDC_BE_PROTOCOL:http \
140 -v SDC_BE_PORT:8080 \
141 -v SDC_ONBOARDING_BE_PROTOCOL:http \
142 -v SDC_ONBOARDING_BE_PORT:8081 \
146 # This file is sourced in another script which is out of our control...