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" |
| 7 | BE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=4000,server=y,suspend=n -Xmx2g -Xms2g" |
| 8 | FE_JAVA_OPTIONS="-Xdebug -agentlib:jdwp=transport=dt_socket,address=6000,server=y,suspend=n -Xmx512m -Xms512m" |
| 9 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 10 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 11 | function usage { |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 12 | 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] | 13 | } |
| 14 | |
| 15 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 16 | function cleanup { |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 17 | echo "performing old dockers cleanup" |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 18 | |
| 19 | if [ "$1" == "all" ] ; then |
| 20 | docker_ids=`docker ps -a | egrep -v "openecomp/sdc-simulator" | egrep "ecomp-nexus:${PORT}/sdc|sdc|Exit" | awk '{print $1}'` |
| 21 | for X in ${docker_ids} |
| 22 | do |
| 23 | docker rm -f ${X} |
| 24 | done |
| 25 | else |
| 26 | echo "performing $1 docker cleanup" |
| 27 | tmp=`docker ps -a -q --filter="name=$1"` |
| 28 | if [[ ! -z "$tmp" ]]; then |
| 29 | docker rm -f ${tmp} |
| 30 | fi |
| 31 | fi |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | |
| 35 | function dir_perms { |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 36 | mkdir -p ${WORKSPACE}/data/logs/BE/SDC/SDC-BE |
| 37 | mkdir -p ${WORKSPACE}/data/logs/FE/SDC/SDC-FE |
| 38 | chmod -R 777 ${WORKSPACE}/data/logs |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 39 | } |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 40 | function probe_cs { |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 41 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 42 | cs_stat=false |
| 43 | docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
| 44 | rc=$? |
| 45 | if [[ $rc == 0 ]]; then |
| 46 | echo DOCKER start finished in $2 seconds |
| 47 | cs_stat=true |
| 48 | fi |
| 49 | |
| 50 | } |
| 51 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 52 | function probe_be { |
| 53 | |
| 54 | be_stat=false |
| 55 | docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
| 56 | rc=$? |
| 57 | if [[ $rc == 200 ]]; then |
| 58 | echo DOCKER start finished in $2 seconds |
| 59 | be_stat=true |
| 60 | fi |
| 61 | |
| 62 | } |
| 63 | |
| 64 | function probe_fe { |
| 65 | |
| 66 | fe_stat=false |
| 67 | docker exec -it $1 /var/lib/ready-probe.sh > /dev/null 2>&1 |
| 68 | rc=$? |
| 69 | if [[ $rc == 200 ]]; then |
| 70 | echo DOCKER start finished in $2 seconds |
| 71 | fe_stat=true |
| 72 | fi |
| 73 | |
| 74 | } |
| 75 | |
| 76 | function probe_es { |
| 77 | |
| 78 | es_stat=false |
| 79 | health_Check_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s) |
| 80 | if [[ "$health_Check_http_code" -eq 200 ]] |
| 81 | then |
| 82 | echo DOCKER start finished in $2 seconds |
| 83 | es_stat=true |
| 84 | fi |
| 85 | |
| 86 | } |
| 87 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 88 | function probe_docker { |
| 89 | |
| 90 | match_result=false |
| 91 | MATCH=`docker logs --tail 30 $1 | grep "DOCKER STARTED"` |
| 92 | echo MATCH is -- $MATCH |
| 93 | |
| 94 | if [ -n "$MATCH" ]; then |
| 95 | echo DOCKER start finished in $2 seconds |
| 96 | match_result=true |
| 97 | fi |
| 98 | } |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 99 | function monitor_docker { |
| 100 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 101 | echo monitor $1 Docker |
| 102 | sleep 5 |
| 103 | TIME_OUT=900 |
| 104 | INTERVAL=20 |
| 105 | TIME=0 |
| 106 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 107 | if [ "$1" == "sdc-cs" ]; then |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 108 | probe_cs $1 $TIME |
| 109 | if [[ $cs_stat == true ]]; then break; fi |
| 110 | elif [ "$1" == "sdc-es" ]; then |
| 111 | probe_es $1 $TIME |
| 112 | if [[ $es_stat == true ]]; then break; fi |
| 113 | elif [ "$1" == "sdc-BE" ]; then |
| 114 | probe_be $1 $TIME |
| 115 | if [[ $be_stat == true ]]; then break; fi |
| 116 | elif [ "$1" == "sdc-FE" ]; then |
| 117 | probe_fe $1 $TIME |
| 118 | if [[ $fe_stat == true ]]; then break; fi |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 119 | else |
| 120 | probe_docker $1 $TIME |
| 121 | if [[ $match_result == true ]]; then break; fi |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 122 | fi |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 123 | echo Sleep: $INTERVAL seconds before testing if $1 DOCKER is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 124 | sleep $INTERVAL |
| 125 | TIME=$(($TIME+$INTERVAL)) |
| 126 | done |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 127 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 128 | if [ "$TIME" -ge "$TIME_OUT" ]; then |
| 129 | echo -e "\e[1;31mTIME OUT: DOCKER was NOT fully started in $TIME_OUT seconds... Could cause problems ...\e[0m" |
| 130 | fi |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 131 | |
| 132 | } |
| 133 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 134 | function healthCheck { |
| 135 | curl localhost:9200/_cluster/health?pretty=true |
| 136 | |
| 137 | echo "BE health-Check:" |
| 138 | curl http://localhost:8080/sdc2/rest/healthCheck |
| 139 | |
| 140 | echo "" |
| 141 | echo "" |
| 142 | echo "FE health-Check:" |
| 143 | curl http://localhost:8181/sdc1/rest/healthCheck |
| 144 | |
| 145 | |
| 146 | echo "" |
| 147 | echo "" |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 148 | healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' -H "Accept: application/json" -H "Content-Type: application/json" -H "USER_ID: jh0003" http://localhost:8080/sdc2/rest/v1/user/demo;) |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 149 | if [[ ${healthCheck_http_code} != 200 ]] |
| 150 | then |
| 151 | echo "Error [${healthCheck_http_code}] while user existance check" |
| 152 | return ${healthCheck_http_code} |
| 153 | fi |
| 154 | echo "check user existance: OK" |
| 155 | return ${healthCheck_http_code} |
| 156 | } |
| 157 | |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 158 | function elasticHealthCheck { |
| 159 | echo "Elastic Health-Check:" |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 160 | |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 161 | COUNTER=0 |
| 162 | while [ $COUNTER -lt 20 ]; do |
| 163 | echo "Waiting ES docker to start" |
| 164 | health_Check_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s) |
| 165 | if [[ "$health_Check_http_code" -eq 200 ]] |
| 166 | then |
| 167 | break |
| 168 | fi |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 169 | let COUNTER=COUNTER+1 |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 170 | sleep 4 |
| 171 | done |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 172 | |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 173 | healthCheck_http_code=$(curl -o /dev/null -w '%{http_code}' http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=120s) |
| 174 | if [[ "$health_Check_http_code" != 200 ]] |
| 175 | then |
| 176 | echo "Error [${healthCheck_http_code}] ES NOT started correctly" |
| 177 | exit ${healthCheck_http_code} |
| 178 | fi |
| 179 | echo "ES started correctly" |
| 180 | curl localhost:9200/_cluster/health?pretty=true |
| 181 | return ${healthCheck_http_code} |
| 182 | } |
| 183 | |
Grinberg Moti | 9724621 | 2017-02-21 19:30:31 +0200 | [diff] [blame] | 184 | RELEASE=latest |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 185 | LOCAL=false |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 186 | RUNTESTS=false |
Tal Gitelman | 8e5fc51 | 2017-10-23 13:49:06 +0300 | [diff] [blame] | 187 | DEBUG_PORT="--publish 4000:4000" |
Tal Gitelman | e224d0b | 2017-10-17 15:24:25 +0300 | [diff] [blame] | 188 | |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 189 | while [ $# -gt 0 ]; do |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 190 | case $1 in |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 191 | # -r | --release - The specific docker version to pull and deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 192 | -r | --release ) |
| 193 | shift 1 ; |
| 194 | RELEASE=$1; |
| 195 | shift 1;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 196 | # -e | --environment - The environment name you want to deploy |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 197 | -e | --environment ) |
| 198 | shift 1; |
| 199 | DEP_ENV=$1; |
| 200 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 201 | # -p | --port - The port from which to connect to the docker nexus |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 202 | -p | --port ) |
| 203 | shift 1 ; |
| 204 | PORT=$1; |
| 205 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 206 | # -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] | 207 | -l | --local ) |
| 208 | LOCAL=true; |
| 209 | shift 1;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 210 | # -t | --runTests - Use this for running the sanity tests docker after all other dockers have been deployed |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 211 | -t | --runTests ) |
| 212 | RUNTESTS=true; |
| 213 | shift 1 ;; |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 214 | # -d | --docker - The init specified docker |
| 215 | -d | --docker ) |
| 216 | shift 1 ; |
| 217 | DOCKER=$1; |
| 218 | shift 1 ;; |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 219 | # -h | --help - Display the help message with all the available run options |
Yuli Shlosberg | 0566f58 | 2017-11-26 19:05:23 +0200 | [diff] [blame] | 220 | -h | --help ) |
| 221 | usage; |
| 222 | exit 0;; |
| 223 | * ) |
| 224 | usage; |
| 225 | exit 1;; |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 226 | esac |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 227 | done |
| 228 | |
Yuli Shlosberg | 3301bec | 2017-11-08 15:31:27 +0200 | [diff] [blame] | 229 | |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 230 | [ -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] | 231 | [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release |
| 232 | [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW |
| 233 | [ -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] | 234 | [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO |
| 235 | |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 236 | 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] | 237 | export PREFIX=${NEXUS_DOCKER_REPO}'/onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 238 | |
| 239 | if [ ${LOCAL} = true ]; then |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 240 | PREFIX='onap' |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 241 | fi |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 242 | |
| 243 | echo "" |
| 244 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 245 | |
| 246 | |
| 247 | function sdc-es { |
| 248 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 249 | # Elastic-Search |
| 250 | echo "docker run sdc-elasticsearch..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 251 | if [ ${LOCAL} = false ]; then |
| 252 | echo "pulling code" |
| 253 | docker pull ${PREFIX}/sdc-elasticsearch:${RELEASE} |
| 254 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 255 | 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] | 256 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 257 | echo "please wait while ES is starting..." |
| 258 | monitor_docker sdc-es |
| 259 | } |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 260 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 261 | function sdc-init-es { |
Tal Gitelman | 38211c8 | 2018-01-24 17:59:53 +0200 | [diff] [blame] | 262 | # Init-Elastic-Search |
| 263 | echo "docker run sdc-init-elasticsearch..." |
| 264 | if [ ${LOCAL} = false ]; then |
| 265 | echo "pulling code" |
| 266 | docker pull ${PREFIX}/sdc-init-elasticsearch:${RELEASE} |
| 267 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 268 | 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 |
| 269 | rc=$? |
| 270 | if [[ $rc != 0 ]]; then exit $rc; fi |
Tal Gitelman | f192759 | 2018-01-29 17:24:56 +0200 | [diff] [blame] | 271 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 272 | } |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 273 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 274 | function sdc-cs { |
Tal Gitelman | 38211c8 | 2018-01-24 17:59:53 +0200 | [diff] [blame] | 275 | # Cassandra |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 276 | echo "docker run sdc-cassandra..." |
| 277 | if [ ${LOCAL} = false ]; then |
| 278 | docker pull ${PREFIX}/sdc-cassandra:${RELEASE} |
| 279 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 280 | 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="2024M" --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] | 281 | |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 282 | |
| 283 | echo "please wait while CS is starting..." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 284 | monitor_docker sdc-cs |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 285 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 286 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 287 | function sdc-cs-init { |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 288 | # cassandra-init |
| 289 | echo "docker run sdc-cassandra-init..." |
| 290 | if [ ${LOCAL} = false ]; then |
| 291 | docker pull ${PREFIX}/sdc-cassandra-init:${RELEASE} |
| 292 | fi |
| 293 | 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 |
| 294 | rc=$? |
| 295 | if [[ $rc != 0 ]]; then exit $rc; fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 296 | } |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 297 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 298 | function sdc-kbn { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 299 | # kibana |
| 300 | echo "docker run sdc-kibana..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 301 | if [ ${LOCAL} = false ]; then |
| 302 | docker pull ${PREFIX}/sdc-kibana:${RELEASE} |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 303 | docker run --detach --name sdc-kbn --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 --publish 5601:5601 ${PREFIX}/sdc-kibana:${RELEASE} |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 304 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 305 | |
| 306 | } |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 307 | |
| 308 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 309 | function sdc-BE { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 310 | |
Grinberg Moti | c3bda48 | 2017-02-23 11:24:34 +0200 | [diff] [blame] | 311 | dir_perms |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 312 | # Back-End |
| 313 | echo "docker run sdc-backend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 314 | if [ ${LOCAL} = false ]; then |
| 315 | docker pull ${PREFIX}/sdc-backend:${RELEASE} |
Tal Gitelman | e224d0b | 2017-10-17 15:24:25 +0300 | [diff] [blame] | 316 | else |
Tal Gitelman | 8e5fc51 | 2017-10-23 13:49:06 +0300 | [diff] [blame] | 317 | ADDITIONAL_ARGUMENTS=${DEBUG_PORT} |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 318 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 319 | docker run --detach --name sdc-BE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --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] | 320 | |
| 321 | echo "please wait while BE is starting..." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 322 | monitor_docker sdc-BE |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 323 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 324 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 325 | function sdc-BE-init { |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 326 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 327 | dir_perms |
| 328 | # Back-End-Init |
| 329 | echo "docker run sdc-backend-init..." |
| 330 | if [ ${LOCAL} = false ]; then |
| 331 | docker pull ${PREFIX}/sdc-backend-init:${RELEASE} |
| 332 | fi |
| 333 | 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 |
| 334 | rc=$? |
| 335 | if [[ $rc != 0 ]]; then exit $rc; fi |
| 336 | } |
| 337 | |
| 338 | function sdc-FE { |
| 339 | dir_perms |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 340 | # Front-End |
| 341 | echo "docker run sdc-frontend..." |
Idan Amit | c7f57ec | 2017-08-31 14:26:21 +0300 | [diff] [blame] | 342 | if [ ${LOCAL} = false ]; then |
| 343 | docker pull ${PREFIX}/sdc-frontend:${RELEASE} |
| 344 | fi |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 345 | docker run --detach --name sdc-FE --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --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] | 346 | |
| 347 | echo "please wait while FE is starting....." |
Yuli Shlosberg | 5571a86 | 2017-10-03 18:18:51 +0300 | [diff] [blame] | 348 | monitor_docker sdc-FE |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 349 | } |
Michael Lando | 451a340 | 2017-02-19 10:28:42 +0200 | [diff] [blame] | 350 | |
ml636r | 0649e65 | 2017-02-20 21:10:54 +0200 | [diff] [blame] | 351 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 352 | |
| 353 | function sdc-sanity { |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 354 | # sanityDocker |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 355 | if [[ (${RUNTESTS} = true) && (${healthCheck_http_code} == 200) ]]; then |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 356 | echo "docker run sdc-sanity..." |
| 357 | echo "Triger sanity docker, please wait..." |
Yuli Shlosberg | 0875ce0 | 2018-01-25 13:53:36 +0200 | [diff] [blame] | 358 | |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 359 | if [ ${LOCAL} = false ]; then |
Idan Amit | db3d554 | 2017-12-07 11:33:32 +0200 | [diff] [blame] | 360 | docker pull ${PREFIX}/sdc-sanity:${RELEASE} |
Yuli Shlosberg | 9dde926 | 2017-09-12 14:11:48 +0300 | [diff] [blame] | 361 | fi |
Yuli Shlosberg | 316bb25 | 2017-11-14 11:47:17 +0200 | [diff] [blame] | 362 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 363 | docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --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-sanity/target:/var/lib/tests/target --volume ${WORKSPACE}/data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume ${WORKSPACE}/data/logs/sdc-sanity/outputCsar:/var/lib/tests/outputCsar --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE} |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 364 | echo "please wait while SANITY is starting....." |
Yuli Shlosberg | d1bb2e5 | 2018-01-15 11:51:21 +0200 | [diff] [blame] | 365 | monitor_docker sdc-sanity |
Yuli Shlosberg | 137cf5c | 2018-01-15 17:32:30 +0200 | [diff] [blame] | 366 | |
Yuli Shlosberg | 958c32d | 2018-02-15 12:04:46 +0200 | [diff] [blame^] | 367 | fi |
| 368 | } |
| 369 | |
| 370 | if [ -z "${DOCKER}" ]; then |
| 371 | cleanup all |
| 372 | sdc-es |
| 373 | sdc-init-es |
| 374 | sdc-cs |
| 375 | sdc-cs-init |
| 376 | sdc-kbn |
| 377 | sdc-BE |
| 378 | sdc-BE-init |
| 379 | sdc-FE |
| 380 | else |
| 381 | cleanup ${DOCKER} |
| 382 | ${DOCKER} |
| 383 | fi |
| 384 | |
| 385 | # healthCheck |
| 386 | healthCheck |