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