Pamela Dragosh | f1f7c51 | 2017-08-03 13:31:15 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Jorge Hernandez | fb15126 | 2018-09-12 08:59:52 -0500 | [diff] [blame] | 3 | # Copyright 2017-2018 AT&T Intellectual Property. All rights reserved. |
Pamela Dragosh | f1f7c51 | 2017-08-03 13:31:15 +0000 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | echo "This is ${WORKSPACE}/test/csit/scripts/policy/script1.sh" |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 18 | |
| 19 | |
| 20 | # the directory of the script |
| 21 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 22 | echo ${DIR} |
| 23 | |
| 24 | # the temp directory used, within $DIR |
| 25 | # omit the -p parameter to create a temporal directory in the default location |
| 26 | WORK_DIR=`mktemp -d -p "$DIR"` |
| 27 | echo ${WORK_DIR} |
| 28 | |
| 29 | cd ${WORK_DIR} |
| 30 | |
| 31 | # check if tmp dir was created |
| 32 | if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then |
| 33 | echo "Could not create temp dir" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | # bring down maven |
| 38 | mkdir maven |
| 39 | cd maven |
| 40 | curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz |
| 41 | tar -xzvf apache-maven-3.3.9-bin.tar.gz |
| 42 | ls -l |
| 43 | export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin |
| 44 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v |
| 45 | cd .. |
| 46 | |
| 47 | ifconfig |
| 48 | |
| 49 | if ! ifconfig eth0; then |
| 50 | if ! ifconfig ens3; then |
| 51 | echo "Could not determine IP address" |
| 52 | exit 1 |
| 53 | fi |
| 54 | export IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 55 | else |
| 56 | export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 57 | fi |
| 58 | echo $IP |
| 59 | |
| 60 | if ! ifconfig docker0; then |
| 61 | if ! ifconfig ens3; then |
| 62 | echo "Could not determine IP address" |
| 63 | exit 1 |
| 64 | fi |
| 65 | export DOCKER_IP_IP=`ifconfig ens3 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 66 | else |
| 67 | export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` |
| 68 | fi |
| 69 | echo $DOCKER_IP |
| 70 | |
| 71 | git clone http://gerrit.onap.org/r/oparent |
| 72 | |
mmis | 1b40e3b | 2018-03-06 16:54:14 +0000 | [diff] [blame] | 73 | git clone http://gerrit.onap.org/r/policy/engine |
| 74 | cd engine/packages/docker |
| 75 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml |
mmis | 0ada614 | 2018-03-16 17:00:03 +0000 | [diff] [blame] | 76 | docker build -t onap/policy-pe target/policy-pe |
mmis | 1b40e3b | 2018-03-06 16:54:14 +0000 | [diff] [blame] | 77 | |
| 78 | cd ${WORK_DIR} |
| 79 | git clone http://gerrit.onap.org/r/policy/drools-pdp |
| 80 | cd drools-pdp/packages/docker |
| 81 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml |
mmis | 0ada614 | 2018-03-16 17:00:03 +0000 | [diff] [blame] | 82 | docker build -t onap/policy-drools target/policy-drools |
mmis | 1b40e3b | 2018-03-06 16:54:14 +0000 | [diff] [blame] | 83 | |
| 84 | cd ${WORK_DIR} |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 85 | git clone http://gerrit.onap.org/r/policy/docker |
| 86 | cd docker |
| 87 | |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 88 | chmod +x config/drools/drools-tweaks.sh |
| 89 | |
| 90 | echo $IP > config/pe/ip_addr.txt |
| 91 | ls -l config/pe/ip_addr.txt |
| 92 | cat config/pe/ip_addr.txt |
| 93 | |
| 94 | export MTU=9126 |
| 95 | |
RAJU | bb7d13c | 2017-10-19 15:59:57 -0500 | [diff] [blame] | 96 | export PRELOAD_POLICIES=false |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 97 | docker-compose -f docker-compose-integration.yml up -d |
| 98 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 99 | if [ ! $? -eq 0 ]; then |
| 100 | echo "Docker compose failed" |
| 101 | exit 1 |
| 102 | fi |
| 103 | |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 104 | docker ps |
| 105 | |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 106 | POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools` |
| 107 | echo ${POLICY_IP} |
| 108 | |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 109 | PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp` |
| 110 | echo ${PDP_IP} |
| 111 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 112 | PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap` |
| 113 | echo ${PAP_IP} |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 114 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 115 | BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw` |
| 116 | echo ${BRMS_IP} |
| 117 | |
| 118 | NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus` |
| 119 | echo ${NEXUS_IP} |
| 120 | |
| 121 | MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb` |
| 122 | echo ${MARIADB_IP} |
| 123 | |
Michael Mokry | c8c6422 | 2018-04-02 00:25:06 -0500 | [diff] [blame] | 124 | sleep 5m |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 125 | |
| 126 | netstat -tnl |
| 127 | |
| 128 | docker logs mariadb |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 129 | ${DIR}/wait_for_port.sh ${MARIADB_IP} 3306 |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 130 | |
| 131 | docker logs pap |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 132 | ${DIR}/wait_for_port.sh ${PAP_IP} 9091 |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 133 | |
| 134 | docker logs pdp |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 135 | ${DIR}/wait_for_port.sh ${PDP_IP} 8081 |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 136 | |
| 137 | docker logs brmsgw |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 138 | ${DIR}/wait_for_port.sh ${BRMS_IP} 9989 |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 139 | |
| 140 | docker logs nexus |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 141 | ${DIR}/wait_for_port.sh ${NEXUS_IP} 8081 |
Jorge Hernandez | b13f63e | 2018-03-30 11:01:03 -0500 | [diff] [blame] | 142 | |
| 143 | docker logs drools |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 144 | ${DIR}/wait_for_port.sh ${POLICY_IP} 6969 |
| 145 | |
| 146 | TIME_OUT=600 |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 147 | INTERVAL=20 |
| 148 | TIME=0 |
| 149 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
Jorge Hernandez | fb15126 | 2018-09-12 08:59:52 -0500 | [diff] [blame] | 150 | curl -k -i --user healthcheck:zb!XztG34 -H "ContentType: application/json" -H "Accept: application/json" https://${POLICY_IP}:6969/healthcheck && break |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 151 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 152 | echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 153 | sleep $INTERVAL |
| 154 | TIME=$(($TIME+$INTERVAL)) |
| 155 | |
| 156 | done |
| 157 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 158 | TIME_OUT=600 |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 159 | INTERVAL=20 |
| 160 | TIME=0 |
| 161 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 162 | |
Michael Mokry | d9592b9 | 2018-08-27 15:35:04 -0500 | [diff] [blame] | 163 | curl -k -i -v -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": ".*"}' https://${PDP_IP}:8081/pdp/api/getConfig && break |
ma987d | e38164b | 2017-09-28 16:33:03 -0500 | [diff] [blame] | 164 | |
| 165 | echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 166 | sleep $INTERVAL |
| 167 | TIME=$(($TIME+$INTERVAL)) |
| 168 | |
| 169 | done |
| 170 | |
Pamela Dragosh | 6dc696f | 2017-10-10 19:50:44 +0000 | [diff] [blame] | 171 | # |
| 172 | # Add more sleep for everything to settle |
| 173 | # |
| 174 | sleep 3m |