blob: db5b5155a2280d18821064c82a8e3731728ad39d [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
73git clone http://gerrit.onap.org/r/policy/docker
74cd docker
75
76${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install prepare-package --settings ../oparent/settings.xml
77cp policy-pe/* target/policy-pe
78cp policy-drools/* target/policy-drools
79
80docker build -t onap/policy/policy-os policy-os
81docker build -t onap/policy/policy-db policy-db
82docker build -t onap/policy/policy-nexus policy-nexus
83docker build -t onap/policy/policy-base policy-base
84docker build -t onap/policy/policy-pe target/policy-pe
85docker build -t onap/policy/policy-drools target/policy-drools
86
87chmod +x config/drools/drools-tweaks.sh
88
89echo $IP > config/pe/ip_addr.txt
90ls -l config/pe/ip_addr.txt
91cat config/pe/ip_addr.txt
92
93export MTU=9126
94
RAJUbb7d13c2017-10-19 15:59:57 -050095export PRELOAD_POLICIES=false
ma987de38164b2017-09-28 16:33:03 -050096docker-compose -f docker-compose-integration.yml up -d
97
Pamela Dragosh6dc696f2017-10-10 19:50:44 +000098if [ ! $? -eq 0 ]; then
99 echo "Docker compose failed"
100 exit 1
101fi
102
ma987de38164b2017-09-28 16:33:03 -0500103docker ps
104
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000105#sleep 4m
ma987de38164b2017-09-28 16:33:03 -0500106
107POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
108echo ${POLICY_IP}
109
ma987de38164b2017-09-28 16:33:03 -0500110PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
111echo ${PDP_IP}
112
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000113PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
114echo ${PAP_IP}
ma987de38164b2017-09-28 16:33:03 -0500115
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000116BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
117echo ${BRMS_IP}
118
119NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
120echo ${NEXUS_IP}
121
122MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
123echo ${MARIADB_IP}
124
125${DIR}/wait_for_port.sh ${MARIADB_IP} 3306
126${DIR}/wait_for_port.sh ${PAP_IP} 9091
127${DIR}/wait_for_port.sh ${PDP_IP} 8081
128${DIR}/wait_for_port.sh ${BRMS_IP} 9989
129${DIR}/wait_for_port.sh ${NEXUS_IP} 8081
130${DIR}/wait_for_port.sh ${POLICY_IP} 6969
131
132TIME_OUT=600
ma987de38164b2017-09-28 16:33:03 -0500133INTERVAL=20
134TIME=0
135while [ "$TIME" -lt "$TIME_OUT" ]; do
136 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 -0500137
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000138 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 -0500139 sleep $INTERVAL
140 TIME=$(($TIME+$INTERVAL))
141
142done
143
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000144TIME_OUT=600
ma987de38164b2017-09-28 16:33:03 -0500145INTERVAL=20
146TIME=0
147while [ "$TIME" -lt "$TIME_OUT" ]; do
148
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000149 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 -0500150
151echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
152 sleep $INTERVAL
153 TIME=$(($TIME+$INTERVAL))
154
155done
156
Pamela Dragosh6dc696f2017-10-10 19:50:44 +0000157#
158# Add more sleep for everything to settle
159#
160sleep 3m