Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 3 | CS_PASSWORD="onap123#@!" |
| 4 | SDC_USER="asdc_user" |
| 5 | SDC_PASSWORD="Aa1234%^!" |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 6 | JETTY_BASE="/var/lib/jetty" |
Gitelman, Tal (tg851x) | 328388b | 2018-03-22 13:03:44 +0200 | [diff] [blame] | 7 | BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx1536m -Xms1536m" |
| 8 | FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx256m -Xms256m" |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 9 | SIM_JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m" |
| 10 | API_TESTS_JAVA_OPTIONS="-Xmx512m -Xms512m" |
| 11 | UI_TESTS_JAVA_OPTIONS="-Xmx1024m -Xms1024m" |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 12 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 13 | function usage { |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 14 | echo "usage: docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -l|--local <Run-without-pull>] [ -t|--runTests <Run-with-sanityDocker>] [ -h|--help ]" |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 18 | function cleanup { |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 19 | echo "performing old dockers cleanup" |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 20 | |
| 21 | if [ "$1" == "all" ] ; then |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 22 | docker_ids=`docker ps -a | egrep -v "onap/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'` |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 23 | for X in ${docker_ids} |
| 24 | do |
| 25 | docker rm -f ${X} |
| 26 | done |
| 27 | else |
| 28 | echo "performing $1 docker cleanup" |
| 29 | tmp=`docker ps -a -q --filter="name=$1"` |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 30 | if [[ ! -z "$tmp" ]]; then |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 31 | docker rm -f ${tmp} |
| 32 | fi |
| 33 | fi |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | |
| 37 | function dir_perms { |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 38 | mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE |
| 39 | mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 40 | mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/ExtentReport |
| 41 | mkdir -p ${WORKSPACE}/data/logs/sdc-api-tests/target |
| 42 | mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/ExtentReport |
| 43 | mkdir -p ${WORKSPACE}/data/logs/sdc-ui-tests/target |
Yuli Shlosberg | 23cc7f5 | 2018-02-28 13:19:42 +0200 | [diff] [blame] | 44 | mkdir -p ${WORKSPACE}/data/logs/docker_logs |
Yuli Shlosberg | e2eef60 | 2018-04-10 23:05:13 +0300 | [diff] [blame] | 45 | mkdir -p ${WORKSPACE}/data/logs/WS |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 46 | chmod -R 777 ${WORKSPACE}/data/logs |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 47 | } |
Yuli Shlosberg | 36604c7 | 2018-02-25 16:03:45 +0200 | [diff] [blame] | 48 | |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 49 | function docker_logs { |
| 50 | |
Yuli Shlosberg | 23cc7f5 | 2018-02-28 13:19:42 +0200 | [diff] [blame] | 51 | docker logs $1 > ${WORKSPACE}/data/logs/docker_logs/$1_docker.log |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 52 | |
| 53 | } |
| 54 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 55 | function probe_cs { |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 56 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 57 | cs_stat=false |
Yuli Shlosberg | 5d0f58e | 2018-02-26 14:18:08 +0200 | [diff] [blame] | 58 | docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 59 | rc=$? |
| 60 | if [[ $rc == 0 ]]; then |
| 61 | echo DOCKER start finished in $2 seconds |
| 62 | cs_stat=true |
| 63 | fi |
| 64 | |
| 65 | } |
| 66 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 67 | function probe_be { |
| 68 | |
| 69 | be_stat=false |
Yuli Shlosberg | 5d0f58e | 2018-02-26 14:18:08 +0200 | [diff] [blame] | 70 | docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 71 | rc=$? |
| 72 | if [[ $rc == 200 ]]; then |
| 73 | echo DOCKER start finished in $2 seconds |
| 74 | be_stat=true |
| 75 | fi |
| 76 | |
| 77 | } |
| 78 | |
| 79 | function probe_fe { |
| 80 | |
| 81 | fe_stat=false |
Yuli Shlosberg | 5d0f58e | 2018-02-26 14:18:08 +0200 | [diff] [blame] | 82 | docker exec $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 83 | rc=$? |
| 84 | if [[ $rc == 200 ]]; then |
| 85 | echo DOCKER start finished in $2 seconds |
| 86 | fe_stat=true |
| 87 | fi |
| 88 | |
| 89 | } |
| 90 | |
| 91 | function probe_es { |
| 92 | |
| 93 | es_stat=false |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 94 | health_Check_http_code=$(curl --noproxy "*" -o /dev/null -w '%{http_code}' http://${IP}:9200/_cluster/health?wait_for_status=yellow&timeout=120s) |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 95 | if [[ "$health_Check_http_code" -eq 200 ]] |
| 96 | then |
| 97 | echo DOCKER start finished in $2 seconds |
| 98 | es_stat=true |
| 99 | fi |
| 100 | |
| 101 | } |
| 102 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 103 | function probe_sim { |
| 104 | |
| 105 | if lsof -Pi :8285 -sTCP:LISTEN -t >/dev/null ; then |
| 106 | echo "running" |
| 107 | sim_stat=true |
| 108 | else |
| 109 | echo "not running" |
| 110 | sim_stat=false |
| 111 | fi |
| 112 | |
| 113 | |
| 114 | } |
| 115 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 116 | function probe_docker { |
| 117 | |
| 118 | match_result=false |
| 119 | MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"` |
| 120 | echo MATCH is -- $MATCH |
| 121 | |
| 122 | if [ -n "$MATCH" ]; then |
| 123 | echo DOCKER start finished in $2 seconds |
| 124 | match_result=true |
| 125 | fi |
| 126 | } |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 127 | function monitor_docker { |
| 128 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 129 | echo monitor $1 Docker |
| 130 | sleep 5 |
| 131 | TIME_OUT=900 |
| 132 | INTERVAL=20 |
| 133 | TIME=0 |
| 134 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 135 | if [ "$1" == "sdc-cs" ]; then |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 136 | probe_cs $1 $TIME |
| 137 | if [[ $cs_stat == true ]]; then break; fi |
| 138 | elif [ "$1" == "sdc-es" ]; then |
| 139 | probe_es $1 $TIME |
| 140 | if [[ $es_stat == true ]]; then break; fi |
| 141 | elif [ "$1" == "sdc-BE" ]; then |
| 142 | probe_be $1 $TIME |
| 143 | if [[ $be_stat == true ]]; then break; fi |
| 144 | elif [ "$1" == "sdc-FE" ]; then |
| 145 | probe_fe $1 $TIME |
| 146 | if [[ $fe_stat == true ]]; then break; fi |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 147 | else |
| 148 | probe_docker $1 $TIME |
| 149 | if [[ $match_result == true ]]; then break; fi |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 150 | fi |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 151 | echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 152 | sleep $INTERVAL |
| 153 | TIME=$(($TIME+$INTERVAL)) |
| 154 | done |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 155 | |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 156 | docker_logs $1 |
Yuli Shlosberg | 36604c7 | 2018-02-25 16:03:45 +0200 | [diff] [blame] | 157 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 158 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 159 | echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m" |
| 160 | fi |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 161 | |
| 162 | } |
| 163 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 164 | function healthCheck { |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 165 | curl --noproxy "*" ${IP}:9200/_cluster/health?pretty=true |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 166 | |
| 167 | echo "BE health-Check:" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 168 | curl --noproxy "*" http://${IP}:8080/sdc2/rest/healthCheck |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 169 | |
| 170 | echo "" |
| 171 | echo "" |
| 172 | echo "FE health-Check:" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 173 | curl --noproxy "*" http://${IP}:8181/sdc1/rest/healthCheck |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 174 | |
| 175 | |
| 176 | echo "" |
| 177 | echo "" |
Yuli Shlosberg | 474996a | 2018-02-27 18:55:25 +0200 | [diff] [blame] | 178 | 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;) |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 179 | if [[ ${healthCheck_http_code} != 200 ]] |
| 180 | then |
| 181 | echo "Error [${healthCheck_http_code}] while user existance check" |
| 182 | return ${healthCheck_http_code} |
| 183 | fi |
| 184 | echo "check user existance: OK" |
| 185 | return ${healthCheck_http_code} |
| 186 | } |
| 187 | |
Grinberg Moti | 9724621 | 2017-02-21 19:30:31 +0200 | [diff] [blame] | 188 | RELEASE=latest |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 189 | LOCAL=false |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 190 | RUNTESTS=false |
Tal Gitelman | 8e5fc51 | 2017-10-23 13:49:06 +0300 | [diff] [blame] | 191 | DEBUG_PORT="--publish 4000:4000" |
Tal Gitelman | e224d0b | 2017-10-17 15:24:25 +0300 | [diff] [blame] | 192 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 193 | while [ $# -gt 0 ]; do |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 194 | case $1 in |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 195 | # -r | --release - The specific docker version to pull and deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 196 | -r | --release ) |
| 197 | shift 1 ; |
| 198 | RELEASE=$1; |
| 199 | shift 1;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 200 | # -e | --environment - The environment name you want to deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 201 | -e | --environment ) |
| 202 | shift 1; |
| 203 | DEP_ENV=$1; |
| 204 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 205 | # -p | --port - The port from which to connect to the docker nexus |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 206 | -p | --port ) |
| 207 | shift 1 ; |
| 208 | PORT=$1; |
| 209 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 210 | # -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] | 211 | -l | --local ) |
| 212 | LOCAL=true; |
| 213 | shift 1;; |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 214 | # -ta - Use this for running the APIs sanity docker after all other dockers have been deployed |
| 215 | -ta ) |
| 216 | shift 1 ; |
| 217 | API_SUITE=$1; |
| 218 | RUN_API_TESTS=true; |
| 219 | shift 1 ;; |
| 220 | # -tu - Use this for running the UI sanity docker after all other dockers have been deployed |
| 221 | -tu ) |
| 222 | shift 1 ; |
| 223 | UI_SUITE=$1; |
| 224 | RUN_UI_TESTS=true; |
| 225 | shift 1 ;; |
| 226 | # -tad - Use this for running the DEFAULT suite of tests in APIs sanity docker after all other dockers have been deployed |
| 227 | -tad | -t ) |
| 228 | API_SUITE="onapApiSanity"; |
| 229 | RUN_API_TESTS=true; |
| 230 | shift 1 ;; |
| 231 | # -tud - Use this for running the DEFAULT suite of tests in UI sanity docker after all other dockers have been deployed |
| 232 | -tud ) |
| 233 | UI_SUITE="onapUiSanity"; |
| 234 | RUN_UI_TESTS=true; |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 235 | shift 1 ;; |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 236 | # -d | --docker - The init specified docker |
| 237 | -d | --docker ) |
| 238 | shift 1 ; |
| 239 | DOCKER=$1; |
| 240 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 241 | # -h | --help - Display the help message with all the available run options |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 242 | -h | --help ) |
| 243 | usage; |
| 244 | exit 0;; |
| 245 | * ) |
| 246 | usage; |
| 247 | exit 1;; |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 248 | esac |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 249 | done |
| 250 | |
Yuli Shlosberg | 3301bec | 2017-11-08 15:31:27 +0200 | [diff] [blame] | 251 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 252 | [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || echo ${DEP_ENV} |
Yuli Shlosberg | 316bb25 | 2017-11-14 11:47:17 +0200 | [diff] [blame] | 253 | [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release |
| 254 | [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW |
| 255 | [ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=nexus3.onap.org:${PORT} |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 256 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 257 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 258 | export IP=`ip route get 8.8.8.8 | awk '/src/{ print $7 }'` |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 259 | export PREFIX=${NEXUS_DOCKER_REPO}'/onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 260 | |
| 261 | if [ ${LOCAL} = true ]; then |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 262 | PREFIX='onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 263 | fi |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 264 | |
| 265 | echo "" |
| 266 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 267 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 268 | #Elastic-Search |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 269 | function sdc-es { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 270 | echo "docker run sdc-elasticsearch..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 271 | if [ ${LOCAL} = false ]; then |
| 272 | echo "pulling code" |
| 273 | docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE} |
| 274 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 275 | docker run -dit --name sdc-es --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 --volume /etc/localtime:/etc/localtime:ro --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 |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 276 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 277 | echo "please wait while ES is starting..." |
| 278 | monitor_docker sdc-es |
| 279 | } |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 280 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 281 | |
| 282 | #Init-Elastic-Search |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 283 | function sdc-init-es { |
Tal Gitelman | 38211c8 | 2018-01-24 17:59:53 +0200 | [diff] [blame] | 284 | echo "docker run sdc-init-elasticsearch..." |
| 285 | if [ ${LOCAL} = false ]; then |
| 286 | echo "pulling code" |
| 287 | docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE} |
| 288 | fi |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 289 | echo "Running sdc-init-es" |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 290 | docker run --name sdc-init-es --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 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments ${PREFIX}/sdc-init-elasticsearch:${RELEASE} > /dev/null 2>&1 |
| 291 | rc=$? |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 292 | docker_logs sdc-init-es |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 293 | if [[ $rc != 0 ]]; then exit $rc; fi |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 294 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 295 | } |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 296 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 297 | #Cassandra |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 298 | function sdc-cs { |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 299 | echo "docker run sdc-cassandra..." |
| 300 | if [ ${LOCAL} = false ]; then |
| 301 | docker pull ${PREFIX}/sdc-cassandra:${RELEASE} |
| 302 | fi |
Gitelman, Tal (tg851x) | 328388b | 2018-03-22 13:03:44 +0200 | [diff] [blame] | 303 | docker run -dit --name sdc-cs --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 --volume /etc/localtime:/etc/localtime:ro --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 |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 304 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 305 | |
| 306 | echo "please wait while CS is starting..." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 307 | monitor_docker sdc-cs |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 308 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 309 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 310 | #Cassandra-init |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 311 | function sdc-cs-init { |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 312 | echo "docker run sdc-cassandra-init..." |
| 313 | if [ ${LOCAL} = false ]; then |
| 314 | docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE} |
| 315 | fi |
| 316 | docker run --name sdc-cs-init --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 --volume /etc/localtime:/etc/localtime:ro --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 |
| 317 | rc=$? |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 318 | docker_logs sdc-cs-init |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 319 | if [[ $rc != 0 ]]; then exit $rc; fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 320 | } |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 321 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 322 | #Kibana |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 323 | function sdc-kbn { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 324 | echo "docker run sdc-kibana..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 325 | if [ ${LOCAL} = false ]; then |
| 326 | docker pull ${PREFIX}/sdc-kibana:${RELEASE} |
Gitelman, Tal (tg851x) | 6a1b82a | 2018-03-21 17:42:47 +0200 | [diff] [blame] | 327 | docker run --detach --name sdc-kbn --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 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE} |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 328 | fi |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 329 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 330 | } |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 331 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 332 | #Back-End |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 333 | function sdc-BE { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 334 | echo "docker run sdc-backend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 335 | if [ ${LOCAL} = false ]; then |
| 336 | docker pull ${PREFIX}/sdc-backend:${RELEASE} |
Tal Gitelman | e224d0b | 2017-10-17 15:24:25 +0300 | [diff] [blame] | 337 | else |
Tal Gitelman | 8e5fc51 | 2017-10-23 13:49:06 +0300 | [diff] [blame] | 338 | ADDITIONAL_ARGUMENTS=${DEBUG_PORT} |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 339 | fi |
Areli, Fuss (af732p) | 9d525f5 | 2018-04-09 18:15:42 +0300 | [diff] [blame] | 340 | docker run --detach --name sdc-BE --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 --volume /etc/localtime:/etc/localtime:ro --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} |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 341 | |
| 342 | echo "please wait while BE is starting..." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 343 | monitor_docker sdc-BE |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 344 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 345 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 346 | # Back-End-Init |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 347 | function sdc-BE-init { |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 348 | echo "docker run sdc-backend-init..." |
| 349 | if [ ${LOCAL} = false ]; then |
| 350 | docker pull ${PREFIX}/sdc-backend-init:${RELEASE} |
| 351 | fi |
| 352 | docker run --name sdc-BE-init --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 --volume /etc/localtime:/etc/localtime:ro --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 |
| 353 | rc=$? |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 354 | docker_logs sdc-BE-init |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 355 | if [[ $rc != 0 ]]; then exit $rc; fi |
| 356 | } |
| 357 | |
Michael Lando | a544510 | 2018-03-04 14:53:33 +0200 | [diff] [blame] | 358 | |
| 359 | # Front-End |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 360 | function sdc-FE { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 361 | echo "docker run sdc-frontend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 362 | if [ ${LOCAL} = false ]; then |
| 363 | docker pull ${PREFIX}/sdc-frontend:${RELEASE} |
| 364 | fi |
Yuli Shlosberg | b4deec1 | 2018-02-25 20:24:44 +0200 | [diff] [blame] | 365 | docker run --detach --name sdc-FE --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 --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/FE/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9443:9443 --publish 8181:8181 ${PREFIX}/sdc-frontend:${RELEASE} |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 366 | |
| 367 | echo "please wait while FE is starting....." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 368 | monitor_docker sdc-FE |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 369 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 370 | |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 371 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 372 | # apis-sanity |
| 373 | function sdc-api-tests { |
| 374 | healthCheck |
| 375 | if [[ (${RUN_API_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then |
| 376 | echo "docker run sdc-api-tests..." |
| 377 | echo "Triger sdc-api-tests docker, please wait..." |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 378 | |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 379 | if [ ${LOCAL} = false ]; then |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 380 | docker pull ${PREFIX}/sdc-api-tests:${RELEASE} |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 381 | fi |
Yuli Shlosberg | 316bb25 | 2017-11-14 11:47:17 +0200 | [diff] [blame] | 382 | |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 383 | 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 --volume /etc/localtime:/etc/localtime:ro --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 --publish 9560:9560 ${PREFIX}/sdc-api-tests:${RELEASE} echo "please wait while SDC-API-TESTS is starting....." |
| 384 | monitor_docker sdc-api-tests |
| 385 | |
| 386 | fi |
| 387 | } |
| 388 | |
| 389 | # ui-sanity |
| 390 | function sdc-ui-tests { |
| 391 | healthCheck |
| 392 | if [[ (${RUN_UI_TESTS} = true) && (${healthCheck_http_code} == 200) ]]; then |
| 393 | echo "docker run sdc-ui-tets..." |
| 394 | echo "Triger sdc-ui-tests docker, please wait..." |
| 395 | |
| 396 | if [ ${LOCAL} = false ]; then |
| 397 | docker pull ${PREFIX}/sdc-ui-tests:${RELEASE} |
| 398 | fi |
| 399 | |
| 400 | sdc-sim |
| 401 | 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 --volume /etc/localtime:/etc/localtime:ro --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} |
| 402 | echo "please wait while SDC-UI-TESTS is starting....." |
| 403 | monitor_docker sdc-ui-tests |
| 404 | |
| 405 | fi |
| 406 | } |
| 407 | |
| 408 | |
| 409 | # SDC-Simulator |
| 410 | function sdc-sim { |
| 411 | echo "docker run sdc-webSimulator..." |
| 412 | if [ ${LOCAL} = false ]; then |
Yuli Shlosberg | 98369b1 | 2018-04-10 19:36:24 +0300 | [diff] [blame] | 413 | docker pull ${PREFIX}/sdc-simulator:${RELEASE} |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 414 | fi |
| 415 | |
| 416 | probe_sim |
| 417 | if [ sim_stat=false ]; then |
| 418 | |
Yuli Shlosberg | e2eef60 | 2018-04-10 23:05:13 +0300 | [diff] [blame] | 419 | docker run --detach --name sdc-sim --env JAVA_OPTIONS="${SIM_JAVA_OPTIONS}" --env ENVNAME="${DEP_ENV}" --volume /etc/localtime:/etc/localtime:ro --volume ${WORKSPACE}/data/logs/WS/:/var/lib/jetty/logs --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 8285:8080 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE} |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 420 | echo "please wait while SDC-WEB-SIMULATOR is starting....." |
| 421 | monitor_docker sdc-sim |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 422 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 423 | fi |
| 424 | } |
| 425 | |
| 426 | if [ -z "${DOCKER}" ]; then |
| 427 | cleanup all |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 428 | dir_perms |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 429 | sdc-es |
| 430 | sdc-init-es |
| 431 | sdc-cs |
| 432 | sdc-cs-init |
Gitelman, Tal (tg851x) | 19c9bda | 2018-03-19 19:07:30 +0200 | [diff] [blame] | 433 | # sdc-kbn |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 434 | sdc-BE |
| 435 | sdc-BE-init |
| 436 | sdc-FE |
Yuli Shlosberg | e07a516 | 2018-02-26 10:11:10 +0200 | [diff] [blame] | 437 | healthCheck |
Yuli Shlosberg | f59a225 | 2018-03-21 11:14:08 +0200 | [diff] [blame] | 438 | sdc-api-tests |
| 439 | sdc-ui-tests |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 440 | else |
| 441 | cleanup ${DOCKER} |
svishnev | 0b698c4 | 2018-03-08 15:50:44 +0200 | [diff] [blame] | 442 | dir_perms |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 443 | ${DOCKER} |
Yuli Shlosberg | e07a516 | 2018-02-26 10:11:10 +0200 | [diff] [blame] | 444 | healthCheck |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame] | 445 | fi |