Pamela Dragosh | f1f7c51 | 2017-08-03 13:31:15 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright 2017 AT&T Intellectual Property. All rights reserved. |
| 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 | |
| 73 | git clone http://gerrit.onap.org/r/policy/docker |
| 74 | cd docker |
| 75 | |
| 76 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install prepare-package --settings ../oparent/settings.xml |
| 77 | cp policy-pe/* target/policy-pe |
| 78 | cp policy-drools/* target/policy-drools |
| 79 | |
| 80 | docker build -t onap/policy/policy-os policy-os |
| 81 | docker build -t onap/policy/policy-db policy-db |
| 82 | docker build -t onap/policy/policy-nexus policy-nexus |
| 83 | docker build -t onap/policy/policy-base policy-base |
| 84 | docker build -t onap/policy/policy-pe target/policy-pe |
| 85 | docker build -t onap/policy/policy-drools target/policy-drools |
| 86 | |
| 87 | chmod +x config/drools/drools-tweaks.sh |
| 88 | |
| 89 | echo $IP > config/pe/ip_addr.txt |
| 90 | ls -l config/pe/ip_addr.txt |
| 91 | cat config/pe/ip_addr.txt |
| 92 | |
| 93 | export MTU=9126 |
| 94 | |
| 95 | docker-compose -f docker-compose-integration.yml up -d |
| 96 | |
| 97 | docker ps |
| 98 | |
| 99 | docker inspect drools |
| 100 | |
| 101 | POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools` |
| 102 | echo ${POLICY_IP} |
| 103 | |
| 104 | sleep 3m |
| 105 | |
| 106 | docker inspect pdp |
| 107 | |
| 108 | PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp` |
| 109 | echo ${PDP_IP} |
| 110 | |
| 111 | sleep 3m |
| 112 | |
| 113 | #for i in {1..60}; do |
| 114 | TIME_OUT=6000 |
| 115 | INTERVAL=20 |
| 116 | TIME=0 |
| 117 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 118 | curl -i --user healthcheck:zb!XztG34 -H "ContentType: application/json" -H "Accept: application/json" ${POLICY_IP}:6969/healthcheck && break |
| 119 | echo sleep $i |
| 120 | sleep $i |
| 121 | |
| 122 | echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 123 | sleep $INTERVAL |
| 124 | TIME=$(($TIME+$INTERVAL)) |
| 125 | |
| 126 | done |
| 127 | |
| 128 | #curl -v --silent -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": "*.*"}' |
| 129 | |
| 130 | TIME_OUT=6000 |
| 131 | INTERVAL=20 |
| 132 | TIME=0 |
| 133 | while [ "$TIME" -lt "$TIME_OUT" ]; do |
| 134 | |
| 135 | curl -v --silent -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -X POST -d '{"policyName": "*.*"}' http://${PDP_IP}:8081/pdp/api/getConfig && break |
| 136 | echo sleep $i |
| 137 | sleep $i |
| 138 | |
| 139 | echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds |
| 140 | sleep $INTERVAL |
| 141 | TIME=$(($TIME+$INTERVAL)) |
| 142 | |
| 143 | done |
| 144 | |