blob: b38401e39abe02958956a966361c0793e236d705 [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/bin/bash
2#
3# Copyright 2017-2018 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#
Gary Wu13111e92018-09-27 11:31:33 -070017echo "This is ${WORKSPACE}/scripts/policy/script1.sh"
Gary Wu9abb61c2018-09-27 10:38:50 -070018
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/engine
74cd engine/packages/docker
75${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml
76docker build -t onap/policy-pe target/policy-pe
77
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
82docker build -t onap/policy-drools target/policy-drools
83
84cd ${WORK_DIR}
85git clone http://gerrit.onap.org/r/policy/docker
86cd docker
87
88chmod +x config/drools/drools-tweaks.sh
89
90echo $IP > config/pe/ip_addr.txt
91ls -l config/pe/ip_addr.txt
92cat config/pe/ip_addr.txt
93
94export MTU=9126
95
96export PRELOAD_POLICIES=false
97docker-compose -f docker-compose-integration.yml up -d
98
99if [ ! $? -eq 0 ]; then
100 echo "Docker compose failed"
101 exit 1
102fi
103
104docker ps
105
106POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
107echo ${POLICY_IP}
108
109PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
110echo ${PDP_IP}
111
112PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
113echo ${PAP_IP}
114
115BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
116echo ${BRMS_IP}
117
118NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
119echo ${NEXUS_IP}
120
121MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
122echo ${MARIADB_IP}
123
124sleep 5m
125
126netstat -tnl
127
128docker logs mariadb
129${DIR}/wait_for_port.sh ${MARIADB_IP} 3306
130
131docker logs pap
132${DIR}/wait_for_port.sh ${PAP_IP} 9091
133
134docker logs pdp
135${DIR}/wait_for_port.sh ${PDP_IP} 8081
136
137docker logs brmsgw
138${DIR}/wait_for_port.sh ${BRMS_IP} 9989
139
140docker logs nexus
141${DIR}/wait_for_port.sh ${NEXUS_IP} 8081
142
143docker logs drools
144${DIR}/wait_for_port.sh ${POLICY_IP} 6969
145
146TIME_OUT=600
147INTERVAL=20
148TIME=0
149while [ "$TIME" -lt "$TIME_OUT" ]; do
150 curl -k -i --user healthcheck:zb!XztG34 -H "ContentType: application/json" -H "Accept: application/json" https://${POLICY_IP}:6969/healthcheck && break
151
152 echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
153 sleep $INTERVAL
154 TIME=$(($TIME+$INTERVAL))
155
156done
157
158TIME_OUT=600
159INTERVAL=20
160TIME=0
161while [ "$TIME" -lt "$TIME_OUT" ]; do
162
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
164
165echo 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
169done
170
171#
172# Add more sleep for everything to settle
173#
174sleep 3m