Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 3 | # |
| 4 | # Constants: |
| 5 | # |
| 6 | |
| 7 | WORKSPACE="${WORKSPACE:-}" |
| 8 | SUCCESS=0 |
| 9 | FAILURE=1 |
| 10 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 11 | CS_PASSWORD="onap123#@!" |
| 12 | SDC_USER="asdc_user" |
| 13 | SDC_PASSWORD="Aa1234%^!" |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 14 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 15 | JETTY_BASE="/var/lib/jetty" |
kooper | b087a8b | 2019-04-04 14:03:36 +0000 | [diff] [blame] | 16 | SDC_CERT_DIR="onap/cert" |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 17 | |
| 18 | RELEASE=latest |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 19 | DCAE_RELEASE=latest |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 20 | LOCAL=false |
| 21 | RUNTESTS=false |
Tal Gitelman | ef4b94e | 2018-08-02 17:11:25 +0300 | [diff] [blame] | 22 | BE_DEBUG_PORT="--publish 4000:4000" |
| 23 | FE_DEBUG_PORT="--publish 6000:6000" |
Tal Gitelman | c4d387d | 2019-03-28 11:00:54 +0200 | [diff] [blame] | 24 | ONBOARD_DEBUG_PORT="--publish 4001:4001" |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 25 | |
| 26 | |
| 27 | # Java Options: |
Gitelman, Tal (tg851x) | 328388b | 2018-03-22 13:03:44 +0200 | [diff] [blame] | 28 | BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m" |
| 29 | FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m" |
Avi Ziv | c175a0d | 2018-03-15 13:21:44 +0200 | [diff] [blame] | 30 | ONBOARD_BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4001,server=y,suspend=n -Xmx1g -Xms1g" |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 31 | DCAE_BE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-be/logback-spring.xml" |
| 32 | DCAE_FE_JAVA_OPTIONS="-XX:MaxPermSize=256m -Xmx1024m -Dconfig.home=config -Dlog.home=/var/lib/jetty/logs/ -Dlogging.config=config/dcae-fe/logback-spring.xml" |
Yuli Shlosberg | af70a20 | 2018-09-25 17:16:48 +0300 | [diff] [blame] | 33 | SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m -Dlog4j.configuration=file:///${JETTY_BASE}/config/sdc-simulator/log4j.properties" |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 34 | API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m" |
| 35 | UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m" |
dekstroza | 8352006 | 2018-05-03 16:47:08 +0100 | [diff] [blame] | 36 | #Define this as variable, so it can be excluded in run commands on Docker for OSX, as /etc/localtime cant be mounted there. |
| 37 | LOCAL_TIME_MOUNT_CMD="--volume /etc/localtime:/etc/localtime:ro" |
| 38 | # If os is OSX, unset this, so /etc/localtime is not mounted, otherwise leave it be |
| 39 | if [[ "$OSTYPE" == "darwin"* ]]; then |
| 40 | LOCAL_TIME_MOUNT_CMD="" |
| 41 | fi |
| 42 | |
| 43 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 44 | # |
| 45 | # Functions: |
| 46 | # |
| 47 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 48 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 49 | function usage { |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 50 | echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -sim|--simulator <Run-with-simulator>] [ -ta <run api tests with the supplied test suit>] [ -tu <run ui tests with the supplied test suit>] [ -ta <run api tests with the supplied test suit>] [ -tu <run ui tests with the supplied test suit>] [ -tad <run api tests with the default test suit>] [ -tu <run ui tests with the default test suit>] [ -dcae|--dcae <Run-with DCAE using label DCAE-RELEASE-NAME>][ -h|--help ]" |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 51 | echo "start dockers built locally example: docker_run.sh -l" |
| 52 | echo "start dockers built locally and simulator example: docker_run.sh -l -sim" |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 53 | echo "start dockers, pull from onap nexus according to release and simulator example: docker_run.sh -r 1.5-STAGING-latest -sim" |
| 54 | echo "start dockers with DCAE, pull from onap nexus according to respective releases: docker_run.sh -r 1.5-STAGING-latest -dcae 1.3-STAGING-latest" |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 55 | echo "start dockers built locally and run api tests docker example: docker_run.sh -l -tad" |
| 56 | echo "start dockers built locally and run only the catalog be example: docker_run.sh -l -d sdc-BE " |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 57 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 58 | # |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 59 | |
| 60 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 61 | function cleanup { |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 62 | echo "Performing old dockers cleanup" |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 63 | |
| 64 | if [ "$1" == "all" ] ; then |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 65 | docker_ids=`docker ps -a | egrep -v "onap/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit}|dcae" | awk '{print $1}'` |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 66 | for X in ${docker_ids} |
| 67 | do |
| 68 | docker rm -f ${X} |
| 69 | done |
| 70 | else |
| 71 | echo "performing $1 docker cleanup" |
| 72 | tmp=`docker ps -a -q --filter="name=$1"` |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 73 | if [[ ! -z "$tmp" ]]; then |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 74 | docker rm -f ${tmp} |
| 75 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 76 | fi |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 77 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 78 | # |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 79 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 80 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 81 | function dir_perms { |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 82 | mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE |
| 83 | mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 84 | |
| 85 | mkdir -p ${WORKSPACE}/data/logs/DCAE-BE/DCAE |
| 86 | mkdir -p ${WORKSPACE}/data/logs/DCAE-FE/DCAE |
| 87 | |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 88 | mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport |
| 89 | mkdir -p ${WORKSPACE}/data/logs/ONBOARD/SDC/ONBOARD-BE |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 90 | mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target |
| 91 | mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 92 | mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target |
| 93 | mkdir -p ${WORKSPACE}/data/logs/docker_logs |
| 94 | mkdir -p ${WORKSPACE}/data/logs/WS |
kooper | b087a8b | 2019-04-04 14:03:36 +0000 | [diff] [blame] | 95 | echo "create dir" |
Liang Ding | 19fe5d2 | 2019-04-18 18:59:53 -0700 | [diff] [blame] | 96 | echo "${WORKSPACE}/data/${SDC_CERT_DIR}" |
kooper | b087a8b | 2019-04-04 14:03:36 +0000 | [diff] [blame] | 97 | mkdir -p ${WORKSPACE}/data/${SDC_CERT_DIR} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 98 | chmod -R 777 ${WORKSPACE}/data/logs |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 99 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 100 | # |
| 101 | |
Yuli Shlosberg | 36604c7 | 2018-02-25 16:03:45 +0200 | [diff] [blame] | 102 | |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 103 | function docker_logs { |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 104 | docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 105 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 106 | # |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 107 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 108 | |
| 109 | # |
| 110 | # Readiness Prob |
| 111 | # |
| 112 | |
| 113 | function ready_probe { |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 114 | docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
| 115 | rc=$? |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 116 | if [[ ${rc} == 0 ]]; then |
| 117 | echo DOCKER $1 start finished in $2 seconds |
| 118 | return ${SUCCESS} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 119 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 120 | return ${FAILURE} |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 121 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 122 | # |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 123 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 124 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 125 | function probe_docker { |
| 126 | MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"` |
| 127 | echo MATCH is -- ${MATCH} |
Avi Ziv | c175a0d | 2018-03-15 13:21:44 +0200 | [diff] [blame] | 128 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 129 | if [ -n "$MATCH" ] ; then |
| 130 | echo DOCKER start finished in $2 seconds |
| 131 | return ${SUCCESS} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 132 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 133 | return ${FAILURE} |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 134 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 135 | # |
| 136 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 137 | |
| 138 | function probe_es { |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 139 | health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s) |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 140 | if [[ "$health_Check_http_code" -eq 200 ]] ; then |
| 141 | echo DOCKER start finished in $1 seconds |
| 142 | return ${SUCCESS} |
| 143 | fi |
| 144 | return ${FAILURE} |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 145 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 146 | # |
| 147 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 148 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 149 | function probe_sim { |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 150 | if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 151 | echo "Already running" |
| 152 | return ${SUCCESS} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 153 | else |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 154 | echo "Not running" |
| 155 | return ${FAILURE} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 156 | fi |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 157 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 158 | # |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 159 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 160 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 161 | function probe_dcae_be { |
| 162 | health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8082/dcae/conf/composition) |
| 163 | if [[ "${health_check_http_code}" -eq 200 ]] ; then |
| 164 | echo DOCKER start finished in $1 seconds |
| 165 | return ${SUCCESS} |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 166 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 167 | return ${FAILURE} |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 168 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 169 | # |
| 170 | |
| 171 | function probe_dcae_fe { |
| 172 | health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8183/dcaed/healthCheck) |
| 173 | if [[ "${health_check_http_code}" -eq 200 ]] ; then |
| 174 | echo DOCKER start finished in $1 seconds |
| 175 | return ${SUCCESS} |
| 176 | fi |
| 177 | return ${FAILURE} |
| 178 | } |
| 179 | # |
| 180 | |
| 181 | |
| 182 | # Not applicable for current release. Return Success in any case |
| 183 | function probe_dcae_tools { |
| 184 | health_check_http_code=$(curl -i -o /dev/null -w '%{http_code}' http://${IP}:8082/dcae/getResourcesByMonitoringTemplateCategory) |
| 185 | if [[ "${health_check_http_code}" -eq 200 ]] ; then |
| 186 | echo DOCKER start finished in $1 seconds |
| 187 | return ${SUCCESS} |
| 188 | fi |
| 189 | return ${SUCCESS} |
| 190 | } |
| 191 | # |
| 192 | |
| 193 | |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 194 | function monitor_docker { |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 195 | DOCKER_NAME=$1 |
| 196 | echo "Monitor ${DOCKER_NAME} Docker" |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 197 | sleep 5 |
| 198 | TIME_OUT=900 |
| 199 | INTERVAL=20 |
| 200 | TIME=0 |
Avi Ziv | c175a0d | 2018-03-15 13:21:44 +0200 | [diff] [blame] | 201 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 202 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 203 | |
| 204 | case ${DOCKER_NAME} in |
| 205 | |
| 206 | sdc-cs) |
| 207 | ready_probe ${DOCKER_NAME} ${TIME} ; |
| 208 | status=$? ; |
| 209 | ;; |
| 210 | sdc-es) |
| 211 | probe_es ${TIME} ; |
| 212 | status=$? ; |
| 213 | ;; |
| 214 | sdc-BE) |
| 215 | ready_probe ${DOCKER_NAME} ${TIME} ; |
| 216 | status=$? ; |
| 217 | ;; |
| 218 | sdc-FE) |
| 219 | ready_probe ${DOCKER_NAME} ${TIME} ; |
| 220 | status=$? ; |
| 221 | ;; |
| 222 | sdc-onboard-BE) |
| 223 | ready_probe ${DOCKER_NAME} ${TIME} ; |
| 224 | status=$? ; |
| 225 | ;; |
| 226 | dcae-be) |
| 227 | probe_dcae_be ${TIME} ; |
| 228 | status=$? ; |
| 229 | ;; |
| 230 | dcae-fe) |
| 231 | probe_dcae_fe ${TIME} ; |
| 232 | status=$? ; |
| 233 | ;; |
| 234 | dcae-tools) |
| 235 | probe_dcae_tools ; |
| 236 | status=$? ; |
| 237 | ;; |
| 238 | *) |
| 239 | probe_docker ${DOCKER_NAME} ${TIME}; |
| 240 | status=$? ; |
| 241 | ;; |
| 242 | |
| 243 | esac |
| 244 | |
| 245 | if [ ${status} == ${SUCCESS} ] ; then |
| 246 | break; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 247 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 248 | |
| 249 | echo "Sleep: ${INTERVAL} seconds before testing if ${DOCKER_NAME} DOCKER is up. Total wait time up now is: ${TIME} seconds. Timeout is: ${TIME_OUT} seconds" |
| 250 | sleep ${INTERVAL} |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 251 | TIME=$(($TIME+$INTERVAL)) |
| 252 | done |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 253 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 254 | docker_logs ${DOCKER_NAME} |
Yuli Shlosberg | 36604c7 | 2018-02-25 16:03:45 +0200 | [diff] [blame] | 255 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 256 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 257 | echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m" |
| 258 | fi |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 259 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 260 | # |
| 261 | |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 262 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 263 | function healthCheck { |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 264 | curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 265 | |
| 266 | echo "BE health-Check:" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 267 | curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 268 | |
| 269 | echo "" |
| 270 | echo "" |
| 271 | echo "FE health-Check:" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 272 | curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 273 | |
| 274 | |
| 275 | echo "" |
| 276 | echo "" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 277 | healthCheck_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://${IP}:8080/sdc2/rest/v1/user/demo;) |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 278 | if [[ ${healthCheck_http_code} != 200 ]]; then |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 279 | echo "Error [${healthCheck_http_code}] while user existance check" |
| 280 | return ${healthCheck_http_code} |
| 281 | fi |
| 282 | echo "check user existance: OK" |
| 283 | return ${healthCheck_http_code} |
| 284 | } |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 285 | # |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 286 | |
Tal Gitelman | e224d0b | 2017-10-17 15:24:25 +0300 | [diff] [blame] | 287 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 288 | function command_exit_status { |
| 289 | status=$1 |
| 290 | docker=$2 |
| 291 | if [ "${status}" != "0" ] ; then |
| 292 | echo "[ ERROR ] Docker ${docker} run command exit with status [${status}]" |
| 293 | fi |
| 294 | } |
| 295 | # |
| 296 | |
| 297 | |
| 298 | # |
| 299 | # Run Containers |
| 300 | # |
| 301 | |
| 302 | #Elastic-Search |
| 303 | function sdc-es { |
| 304 | DOCKER_NAME="sdc-es" |
| 305 | echo "docker run sdc-elasticsearch..." |
| 306 | if [ ${LOCAL} = false ]; then |
| 307 | echo "pulling code" |
| 308 | docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE} |
| 309 | fi |
| 310 | docker run -dit --name ${DOCKER_NAME} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --env ES_JAVA_OPTS="-Xms512m -Xmx512m" --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --env ES_HEAP_SIZE=1024M --volume ${WORKSPACE}/data/ES:/usr/share/elasticsearch/data --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9200:9200 --publish 9300:9300 ${PREFIX}/sdc-elasticsearch:${RELEASE} /bin/sh |
| 311 | command_exit_status $? ${DOCKER_NAME} |
| 312 | echo "please wait while ES is starting..." |
| 313 | monitor_docker ${DOCKER_NAME} |
| 314 | } |
| 315 | # |
| 316 | |
| 317 | |
| 318 | #Init-Elastic-Search |
| 319 | function sdc-init-es { |
| 320 | DOCKER_NAME="sdc-init-es" |
| 321 | echo "docker run sdc-init-elasticsearch..." |
| 322 | if [ ${LOCAL} = false ]; then |
| 323 | echo "pulling code" |
| 324 | docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE} |
| 325 | fi |
| 326 | echo "Running sdc-init-es" |
| 327 | docker run --name ${DOCKER_NAME} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} > /dev/null 2>&1 |
| 328 | rc=$? |
| 329 | docker_logs ${DOCKER_NAME} |
| 330 | if [[ ${rc} != 0 ]]; then exit ${rc}; fi |
| 331 | } |
| 332 | # |
| 333 | |
| 334 | |
| 335 | #Cassandra |
| 336 | function sdc-cs { |
| 337 | DOCKER_NAME="sdc-cs" |
| 338 | echo "docker run sdc-cassandra..." |
| 339 | if [ ${LOCAL} = false ]; then |
| 340 | docker pull ${PREFIX}/sdc-cassandra:${RELEASE} |
| 341 | fi |
| 342 | docker run -dit --name ${DOCKER_NAME} --env RELEASE="${RELEASE}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --env MAX_HEAP_SIZE="1536M" --env HEAP_NEWSIZE="512M" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9042:9042 --publish 9160:9160 ${PREFIX}/sdc-cassandra:${RELEASE} /bin/sh |
| 343 | command_exit_status $? ${DOCKER_NAME} |
| 344 | echo "please wait while CS is starting..." |
| 345 | monitor_docker ${DOCKER_NAME} |
| 346 | } |
| 347 | # |
| 348 | |
| 349 | |
| 350 | #Cassandra-init |
| 351 | function sdc-cs-init { |
| 352 | DOCKER_NAME="sdc-cs-init" |
| 353 | echo "docker run sdc-cassandra-init..." |
| 354 | if [ ${LOCAL} = false ]; then |
| 355 | docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE} |
| 356 | fi |
| 357 | docker run --name ${DOCKER_NAME} --env RELEASE="${RELEASE}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --env HOST_IP=${IP} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-cassandra-init:${RELEASE} > /dev/null 2>&1 |
| 358 | rc=$? |
| 359 | docker_logs ${DOCKER_NAME} |
| 360 | if [[ ${rc} != 0 ]]; then exit ${rc}; fi |
| 361 | } |
| 362 | # |
| 363 | |
| 364 | |
| 365 | #Onboard Cassandra-init |
| 366 | function sdc-cs-onboard-init { |
| 367 | DOCKER_NAME="sdc-cs-onboard-init" |
| 368 | echo "docker run sdc-cs-onboard-init..." |
| 369 | if [ ${LOCAL} = false ]; then |
| 370 | docker pull ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE} |
| 371 | fi |
| 372 | docker run --name ${DOCKER_NAME} --env RELEASE="${RELEASE}" --env CS_HOST_IP=${IP} --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env CS_PASSWORD="${CS_PASSWORD}" --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/CS:/var/lib/cassandra --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/CS-Init:/root/chef-solo/cache ${PREFIX}/sdc-onboard-cassandra-init:${RELEASE} |
| 373 | rc=$? |
| 374 | docker_logs ${DOCKER_NAME} |
| 375 | if [[ ${rc} != 0 ]]; then exit ${rc}; fi |
| 376 | } |
| 377 | # |
| 378 | |
| 379 | |
| 380 | #Kibana |
| 381 | function sdc-kbn { |
| 382 | DOCKER_NAME="sdc-kbn" |
| 383 | echo "docker run sdc-kibana..." |
| 384 | if [ ${LOCAL} = false ]; then |
| 385 | docker pull ${PREFIX}/sdc-kibana:${RELEASE} |
| 386 | docker run --detach --name ${DOCKER_NAME} --env ENVNAME="${DEP_ENV}" --env NODE_OPTIONS="--max-old-space-size=200" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE} |
| 387 | command_exit_status $? ${DOCKER_NAME} |
| 388 | fi |
| 389 | } |
| 390 | # |
| 391 | |
| 392 | |
| 393 | #Back-End |
| 394 | function sdc-BE { |
| 395 | DOCKER_NAME="sdc-BE" |
| 396 | echo "docker run sdc-backend..." |
| 397 | if [ ${LOCAL} = false ]; then |
| 398 | docker pull ${PREFIX}/sdc-backend:${RELEASE} |
| 399 | else |
Tal Gitelman | ef4b94e | 2018-08-02 17:11:25 +0300 | [diff] [blame] | 400 | ADDITIONAL_ARGUMENTS=${BE_DEBUG_PORT} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 401 | fi |
| 402 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env JAVA_OPTIONS="${BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8443:8443 --publish 8080:8080 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-backend:${RELEASE} |
| 403 | command_exit_status $? ${DOCKER_NAME} |
| 404 | echo "please wait while BE is starting..." |
| 405 | monitor_docker ${DOCKER_NAME} |
| 406 | } |
| 407 | # |
| 408 | |
| 409 | |
| 410 | # Back-End-Init |
| 411 | function sdc-BE-init { |
| 412 | DOCKER_NAME="sdc-BE-init" |
| 413 | echo "docker run sdc-backend-init..." |
| 414 | if [ ${LOCAL} = false ]; then |
| 415 | docker pull ${PREFIX}/sdc-backend-init:${RELEASE} |
| 416 | fi |
| 417 | docker run --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-backend-init:${RELEASE} > /dev/null 2>&1 |
| 418 | rc=$? |
| 419 | docker_logs ${DOCKER_NAME} |
| 420 | if [[ ${rc} != 0 ]]; then exit ${rc}; fi |
| 421 | } |
| 422 | # |
| 423 | |
| 424 | |
| 425 | # Onboard Back-End |
| 426 | function sdc-onboard-BE { |
| 427 | DOCKER_NAME="sdc-onboard-BE" |
| 428 | echo "docker run sdc-onboard-BE ..." |
| 429 | # TODO Check the dir_perms action . do we need it here ?? |
| 430 | # dir_perms |
| 431 | if [ ${LOCAL} = false ]; then |
| 432 | docker pull ${PREFIX}/sdc-onboard-backend:${RELEASE} |
| 433 | else |
| 434 | ADDITIONAL_ARGUMENTS=${ONBOARD_DEBUG_PORT} |
| 435 | fi |
kooper | b087a8b | 2019-04-04 14:03:36 +0000 | [diff] [blame] | 436 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env cassandra_ssl_enabled="false" --env SDC_CLUSTER_NAME="SDC-CS-${DEP_ENV}" --env SDC_USER="${SDC_USER}" --env SDC_PASSWORD="${SDC_PASSWORD}" --env SDC_CERT_DIR="${SDC_CERT_DIR}" --env JAVA_OPTIONS="${ONBOARD_BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/${SDC_CERT_DIR}:/var/lib/jetty/onap/cert --volume ${WORKSPACE}/data/logs/ONBOARD:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8445:8445 --publish 8081:8081 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-onboard-backend:${RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 437 | command_exit_status $? ${DOCKER_NAME} |
| 438 | echo "please wait while sdc-onboard-BE is starting..." |
| 439 | monitor_docker ${DOCKER_NAME} |
| 440 | } |
| 441 | # |
| 442 | |
| 443 | |
| 444 | # Front-End |
| 445 | function sdc-FE { |
| 446 | DOCKER_NAME="sdc-FE" |
| 447 | echo "docker run sdc-frontend..." |
| 448 | if [ ${LOCAL} = false ]; then |
| 449 | docker pull ${PREFIX}/sdc-frontend:${RELEASE} |
Tal Gitelman | ef4b94e | 2018-08-02 17:11:25 +0300 | [diff] [blame] | 450 | else |
| 451 | ADDITIONAL_ARGUMENTS=${FE_DEBUG_PORT} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 452 | fi |
shrikantawachar | d139e09 | 2019-01-16 12:37:16 +0530 | [diff] [blame] | 453 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${FE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/environments/plugins-configuration.yaml:${JETTY_BASE}/config/catalog-fe/plugins-configuration.yaml --publish 9443:9443 --publish 8181:8181 ${ADDITIONAL_ARGUMENTS} ${PREFIX}/sdc-frontend:${RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 454 | command_exit_status $? ${DOCKER_NAME} |
| 455 | echo "please wait while FE is starting....." |
| 456 | monitor_docker ${DOCKER_NAME} |
| 457 | } |
| 458 | # |
| 459 | |
| 460 | |
| 461 | # DCAE BackEnd |
| 462 | function dcae-be { |
| 463 | if [ ! ${DCAE_ENABLE} ] ; then |
| 464 | return |
| 465 | fi |
| 466 | DOCKER_NAME="dcae-be" |
| 467 | echo "docker run ${DOCKER_NAME}..." |
| 468 | if [ ${LOCAL} = false ]; then |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 469 | docker pull ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 470 | fi |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 471 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_BE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/DCAE-BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-be/chef-solo/environments --publish 8444:8444 --publish 8082:8082 ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 472 | command_exit_status $? ${DOCKER_NAME} |
| 473 | echo "please wait while ${DOCKER_NAME^^} is starting....." |
| 474 | monitor_docker ${DOCKER_NAME} |
| 475 | } |
| 476 | # |
| 477 | |
| 478 | |
| 479 | # DCAE Configuration |
| 480 | function dcae-tools { |
| 481 | if [ ! ${DCAE_ENABLE} ] ; then |
| 482 | return |
| 483 | fi |
| 484 | DOCKER_NAME="dcae-tools" |
| 485 | echo "docker run ${DOCKER_NAME}..." |
| 486 | if [ ${LOCAL} = false ]; then |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 487 | docker pull ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 488 | fi |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 489 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/BE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-tools/chef-solo/environments ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 490 | command_exit_status $? ${DOCKER_NAME} |
| 491 | echo "please wait while ${DOCKER_NAME^^} is starting....." |
| 492 | monitor_docker ${DOCKER_NAME} |
| 493 | |
| 494 | } |
| 495 | # |
| 496 | |
| 497 | |
| 498 | # DCAE FrontEnd |
| 499 | function dcae-fe { |
| 500 | if [ ! ${DCAE_ENABLE} ] ; then |
| 501 | return |
| 502 | fi |
| 503 | DOCKER_NAME="dcae-fe" |
| 504 | echo "docker run ${DOCKER_NAME}..." |
| 505 | if [ ${LOCAL} = false ]; then |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 506 | docker pull ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 507 | fi |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 508 | docker run --detach --name ${DOCKER_NAME} --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${DCAE_FE_JAVA_OPTIONS}" --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/DCAE-FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/var/opt/dcae-fe/chef-solo/environments/ --publish 9444:9444 --publish 8183:8183 ${PREFIX}/${DOCKER_NAME}:${DCAE_RELEASE} |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 509 | command_exit_status $? ${DOCKER_NAME} |
| 510 | echo "please wait while ${DOCKER_NAME^^} is starting....." |
| 511 | monitor_docker ${DOCKER_NAME} |
| 512 | |
| 513 | } |
| 514 | # |
| 515 | |
| 516 | |
| 517 | # apis-sanity |
| 518 | function sdc-api-tests { |
| 519 | if [[ ${RUN_API_TESTS} = true ]] ; then |
Yuli Shlosberg | d0eaeca | 2018-07-19 17:54:15 +0300 | [diff] [blame] | 520 | healthCheck |
| 521 | healthCheck_http_code=$? |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 522 | if [[ ${healthCheck_http_code} == 200 ]] ; then |
| 523 | echo "docker run sdc-api-tests..." |
| 524 | echo "Trigger sdc-api-tests docker, please wait..." |
| 525 | |
| 526 | if [ ${LOCAL} = false ]; then |
| 527 | docker pull ${PREFIX}/sdc-api-tests:${RELEASE} |
| 528 | fi |
| 529 | |
AndyWalshe | c1835f3 | 2019-04-25 11:20:38 +0000 | [diff] [blame] | 530 | docker run --detach --name sdc-api-tests --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${API_TESTS_JAVA_OPTIONS}" --env SUITE_NAME=${API_SUITE} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/sdc-api-tests/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-api-tests/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --volume ${WORKSPACE}/data/${SDC_CERT_DIR}:/var/lib/tests/cert --publish 9560:9560 ${PREFIX}/sdc-api-tests:${RELEASE} echo "please wait while SDC-API-TESTS is starting....." |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 531 | monitor_docker sdc-api-tests |
| 532 | fi |
| 533 | fi |
| 534 | } |
| 535 | # |
| 536 | |
| 537 | |
| 538 | # ui-sanity |
| 539 | function sdc-ui-tests { |
| 540 | |
| 541 | if [[ ${RUN_UI_TESTS} = true ]] ; then |
Yuli Shlosberg | d0eaeca | 2018-07-19 17:54:15 +0300 | [diff] [blame] | 542 | healthCheck |
| 543 | healthCheck_http_code=$? |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 544 | if [[ ${healthCheck_http_code} == 200 ]]; then |
| 545 | echo "docker run sdc-ui-tets..." |
| 546 | echo "Trigger sdc-ui-tests docker, please wait..." |
| 547 | |
| 548 | if [ ${LOCAL} = false ]; then |
| 549 | docker pull ${PREFIX}/sdc-ui-tests:${RELEASE} |
| 550 | fi |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 551 | RUN_SIMULATOR=true; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 552 | sdc-sim |
| 553 | docker run --detach --name sdc-ui-tests --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env JAVA_OPTIONS="${UI_TESTS_JAVA_OPTIONS}" --env SUITE_NAME=${UI_SUITE} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --ulimit nofile=4096:100000 ${LOCAL_TIME_MOUNT_CMD} --volume ${WORKSPACE}/data/logs/sdc-ui-tests/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5901:5901 --publish 6901:6901 ${PREFIX}/sdc-ui-tests:${RELEASE} |
| 554 | echo "please wait while SDC-UI-TESTS is starting....." |
| 555 | monitor_docker sdc-ui-tests |
| 556 | fi |
| 557 | fi |
| 558 | } |
| 559 | # |
| 560 | |
| 561 | |
| 562 | # SDC-Simulator |
| 563 | function sdc-sim { |
Lianhao Lu | 2616684 | 2018-09-07 10:42:10 +0800 | [diff] [blame] | 564 | if [ "${RUN_SIMULATOR}" == true ]; then |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 565 | echo "docker run sdc-webSimulator..." |
| 566 | if [ ${LOCAL} = false ]; then |
| 567 | docker pull ${PREFIX}/sdc-simulator:${RELEASE} |
| 568 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 569 | |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 570 | probe_sim |
| 571 | sim_stat=$? |
Michael Lando | b751c96 | 2018-08-20 11:34:04 +0300 | [diff] [blame] | 572 | if [ ${sim_stat} == 1 ]; then |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 573 | docker run \ |
| 574 | --detach \ |
| 575 | --name sdc-sim \ |
| 576 | --env FE_URL="${FE_URL}" \ |
| 577 | --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" \ |
| 578 | --env ENVNAME="${DEP_ENV}" \ |
| 579 | ${LOCAL_TIME_MOUNT_CMD} \ |
| 580 | --volume ${WORKSPACE}/data/logs/WS/:/var/lib/jetty/logs \ |
| 581 | --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \ |
| 582 | --publish 8285:8080 \ |
| 583 | --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE} |
| 584 | echo "please wait while SDC-WEB-SIMULATOR is starting....." |
| 585 | monitor_docker sdc-sim |
| 586 | fi |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 587 | fi |
| 588 | } |
| 589 | # |
| 590 | |
| 591 | |
| 592 | # |
| 593 | # Main |
| 594 | # |
| 595 | |
| 596 | # Handle command line arguments |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 597 | while [ $# -gt 0 ]; do |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 598 | case $1 in |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 599 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 600 | # -r | --release - The specific docker version to pull and deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 601 | -r | --release ) |
| 602 | shift 1 ; |
| 603 | RELEASE=$1; |
| 604 | shift 1;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 605 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 606 | # -e | --environment - The environment name you want to deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 607 | -e | --environment ) |
| 608 | shift 1; |
| 609 | DEP_ENV=$1; |
| 610 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 611 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 612 | # -p | --port - The port from which to connect to the docker nexus |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 613 | -p | --port ) |
| 614 | shift 1 ; |
| 615 | PORT=$1; |
| 616 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 617 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 618 | # -l | --local - Use this for deploying your local dockers without pulling them first |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 619 | -l | --local ) |
| 620 | LOCAL=true; |
| 621 | shift 1;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 622 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 623 | # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed |
| 624 | -ta ) |
| 625 | shift 1 ; |
| 626 | API_SUITE=$1; |
| 627 | RUN_API_TESTS=true; |
| 628 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 629 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 630 | # -tu - Use this for running the UI sanity docker after all other dockers have been deployed |
| 631 | -tu ) |
| 632 | shift 1 ; |
| 633 | UI_SUITE=$1; |
| 634 | RUN_UI_TESTS=true; |
| 635 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 636 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 637 | # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed |
| 638 | -tad | -t ) |
| 639 | API_SUITE="onapApiSanity"; |
| 640 | RUN_API_TESTS=true; |
| 641 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 642 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 643 | # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed |
| 644 | -tud ) |
| 645 | UI_SUITE="onapUiSanity"; |
| 646 | RUN_UI_TESTS=true; |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 647 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 648 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 649 | # -d | --docker - The init specified docker |
| 650 | -d | --docker ) |
| 651 | shift 1 ; |
| 652 | DOCKER=$1; |
| 653 | shift 1 ;; |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 654 | # -sim | --simulator run the simulator |
| 655 | -sim | --simulator ) |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 656 | RUN_SIMULATOR=true; |
| 657 | shift 1 ;; |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 658 | # -sim | --simulator run the simulator |
| 659 | -u | --fe_url ) |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 660 | shift 1 ; |
| 661 | FE_URL=$1; |
| 662 | shift 1 ;; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 663 | # -dcae | --dcae - Use this to deploy DCAE upon SDC |
| 664 | -dcae | --dcae ) |
kaihlavi | b237271 | 2019-05-27 16:28:23 +0300 | [diff] [blame^] | 665 | shift 1 ; |
| 666 | DCAE_RELEASE=$1; |
| 667 | shift 1; |
| 668 | DCAE_ENABLE='True';; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 669 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 670 | # -h | --help - Display the help message with all the available run options |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 671 | -h | --help ) |
| 672 | usage; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 673 | exit ${SUCCESS};; |
| 674 | |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 675 | * ) |
| 676 | usage; |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 677 | exit ${FAILURE};; |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 678 | esac |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 679 | done |
| 680 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 681 | |
liang ding | d73c287 | 2018-09-27 19:07:02 -0700 | [diff] [blame] | 682 | #Prefix those with WORKSPACE so it can be set to something other than /opt |
dekstroza | 8352006 | 2018-05-03 16:47:08 +0100 | [diff] [blame] | 683 | [ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt) || echo ${DEP_ENV} |
| 684 | [ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt) || NEXUS_USERNAME=release |
| 685 | [ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW |
| 686 | [ -f ${WORKSPACE}/opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat ${WORKSPACE}/opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT} |
| 687 | [ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 688 | |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 689 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 690 | export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'` |
dekstroza | 8352006 | 2018-05-03 16:47:08 +0100 | [diff] [blame] | 691 | #If OSX, then use this to get IP |
| 692 | if [[ "$OSTYPE" == "darwin"* ]]; then |
| 693 | export IP=$(ipconfig getifaddr en0) |
| 694 | fi |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 695 | export PREFIX=${NEXUS_DOCKER_REPO}'/onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 696 | |
| 697 | if [ ${LOCAL} = true ]; then |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 698 | PREFIX='onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 699 | fi |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 700 | |
| 701 | echo "" |
| 702 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 703 | if [ -z "${DOCKER}" ]; then |
Michael Lando | 4b9b947 | 2018-06-02 19:14:05 +0300 | [diff] [blame] | 704 | cleanup all |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 705 | dir_perms |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 706 | sdc-es |
| 707 | sdc-init-es |
| 708 | sdc-cs |
| 709 | sdc-cs-init |
Gitelman, Tal (tg851x) | 19c9bda | 2018-03-19 19:07:30 +0200 | [diff] [blame] | 710 | # sdc-kbn |
Avi Ziv | c175a0d | 2018-03-15 13:21:44 +0200 | [diff] [blame] | 711 | sdc-cs-onboard-init |
| 712 | sdc-onboard-BE |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 713 | sdc-BE |
| 714 | sdc-BE-init |
| 715 | sdc-FE |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 716 | dcae-be |
| 717 | dcae-tools |
| 718 | dcae-fe |
| 719 | healthCheck |
Michael Lando | dc856bb | 2018-08-13 13:27:52 +0300 | [diff] [blame] | 720 | sdc-sim |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 721 | sdc-api-tests |
Areli, Fuss (af732p) | 062d4c1 | 2018-06-03 18:49:19 +0300 | [diff] [blame] | 722 | sdc-ui-tests |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 723 | else |
| 724 | cleanup ${DOCKER} |
svishnev | 0b698c4 | 2018-03-08 15:50:44 +0200 | [diff] [blame] | 725 | dir_perms |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 726 | ${DOCKER} |
Yuli Shlosberg | e07a516 | 2018-02-26 10:11:10 +0200 | [diff] [blame] | 727 | healthCheck |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 728 | fi |