blob: 0db34f080854dcc166a35350c93fe642c3c7a3d3 [file] [log] [blame]
Pamela Dragoshf1f7c512017-08-03 13:31:15 +00001#!/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#
17echo "This is ${WORKSPACE}/test/csit/scripts/policy/script1.sh"
ma987de38164b2017-09-28 16:33:03 -050018
19
20# the directory of the script
21DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
22echo ${DIR}
23
24# the temp directory used, within $DIR
25# omit the -p parameter to create a temporal directory in the default location
26WORK_DIR=`mktemp -d -p "$DIR"`
27echo ${WORK_DIR}
28
29cd ${WORK_DIR}
30
31# check if tmp dir was created
32if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
33 echo "Could not create temp dir"
34 exit 1
35fi
36
37# bring down maven
38mkdir maven
39cd maven
40curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
41tar -xzvf apache-maven-3.3.9-bin.tar.gz
42ls -l
43export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin
44${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v
45cd ..
46
47ifconfig
48
49if ! 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}'`
55else
56 export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
57fi
58echo $IP
59
60if ! 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}'`
66else
67 export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
68fi
69echo $DOCKER_IP
70
71git clone http://gerrit.onap.org/r/oparent
72
mmis1b40e3b2018-03-06 16:54:14 +000073git clone http://gerrit.onap.org/r/policy/engine
74cd engine/packages/docker
75${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml
mmis0ada6142018-03-16 17:00:03 +000076docker build -t onap/policy-pe target/policy-pe
mmis1b40e3b2018-03-06 16:54:14 +000077
78cd ${WORK_DIR}
79git clone http://gerrit.onap.org/r/policy/drools-pdp
80cd drools-pdp/packages/docker
81${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml
mmis0ada6142018-03-16 17:00:03 +000082docker build -t onap/policy-drools target/policy-drools
mmis1b40e3b2018-03-06 16:54:14 +000083
84cd ${WORK_DIR}
ma987de38164b2017-09-28 16:33:03 -050085git clone http://gerrit.onap.org/r/policy/docker
86cd docker
87
mmis0ada6142018-03-16 17:00:03 +000088docker build -t onap/policy-nexus policy-nexus
ma987de38164b2017-09-28 16:33:03 -050089
90chmod +x config/drools/drools-tweaks.sh
91
92echo $IP > config/pe/ip_addr.txt
93ls -l config/pe/ip_addr.txt
94cat config/pe/ip_addr.txt
95
96export MTU=9126
97
RAJUbb7d13c2017-10-19 15:59:57 -050098export PRELOAD_POLICIES=false
ma987de38164b2017-09-28 16:33:03 -050099docker-compose -f docker-compose-integration.yml up -d
100
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000101if [ ! $? -eq 0 ]; then
102 echo "Docker compose failed"
103 exit 1
104fi
105
ma987de38164b2017-09-28 16:33:03 -0500106docker ps
107
ma987de38164b2017-09-28 16:33:03 -0500108POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
109echo ${POLICY_IP}
110
ma987de38164b2017-09-28 16:33:03 -0500111PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
112echo ${PDP_IP}
113
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000114PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
115echo ${PAP_IP}
ma987de38164b2017-09-28 16:33:03 -0500116
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000117BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
118echo ${BRMS_IP}
119
120NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
121echo ${NEXUS_IP}
122
123MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
124echo ${MARIADB_IP}
125
Michael Mokryc8c64222018-04-02 00:25:06 -0500126sleep 5m
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500127
128netstat -tnl
129
130docker logs mariadb
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000131${DIR}/wait_for_port.sh ${MARIADB_IP} 3306
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500132
133docker logs pap
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000134${DIR}/wait_for_port.sh ${PAP_IP} 9091
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500135
136docker logs pdp
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000137${DIR}/wait_for_port.sh ${PDP_IP} 8081
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500138
139docker logs brmsgw
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000140${DIR}/wait_for_port.sh ${BRMS_IP} 9989
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500141
142docker logs nexus
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000143${DIR}/wait_for_port.sh ${NEXUS_IP} 8081
Jorge Hernandezb13f63e2018-03-30 11:01:03 -0500144
145docker logs drools
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000146${DIR}/wait_for_port.sh ${POLICY_IP} 6969
147
148TIME_OUT=600
ma987de38164b2017-09-28 16:33:03 -0500149INTERVAL=20
150TIME=0
151while [ "$TIME" -lt "$TIME_OUT" ]; do
152 curl -i --user healthcheck:zb!XztG34 -H "ContentType: application/json" -H "Accept: application/json" ${POLICY_IP}:6969/healthcheck && break
ma987de38164b2017-09-28 16:33:03 -0500153
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000154 echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
ma987de38164b2017-09-28 16:33:03 -0500155 sleep $INTERVAL
156 TIME=$(($TIME+$INTERVAL))
157
158done
159
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000160TIME_OUT=600
ma987de38164b2017-09-28 16:33:03 -0500161INTERVAL=20
162TIME=0
163while [ "$TIME" -lt "$TIME_OUT" ]; do
164
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000165 curl -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": ".*"}' http://${PDP_IP}:8081/pdp/api/getConfig && break
ma987de38164b2017-09-28 16:33:03 -0500166
167echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
168 sleep $INTERVAL
169 TIME=$(($TIME+$INTERVAL))
170
171done
172
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000173#
174# Add more sleep for everything to settle
175#
176sleep 3m