blob: a0b4d29c4330dfafc5f31fd989004755c22f6cd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
#!/bin/bash -x
#
# Copyright 2017-2019 AT&T Intellectual Property. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
echo "This is ${WORKSPACE}/scripts/policy/engine.sh"
# the directory of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo ${DIR}
# the temp directory used, within $DIR
# omit the -p parameter to create a temporal directory in the default location
WORK_DIR=`mktemp -d -p "$DIR"`
echo ${WORK_DIR}
cd ${WORK_DIR}
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# bring down maven
mkdir maven
cd maven
curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar -xzvf apache-maven-3.3.9-bin.tar.gz
ls -l
export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin
${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v
cd ..
ifconfig
export IP=`ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $NF}'`
if [ -z "$IP" ]; then
echo "Could not determine IP address"
exit 1
fi
echo $IP
if ! ifconfig docker0; then
export DOCKER_IP="$IP"
else
export DOCKER_IP=`ifconfig docker0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'`
fi
echo $DOCKER_IP
git clone http://gerrit.onap.org/r/oparent
git clone -b dublin http://gerrit.onap.org/r/policy/engine
cd engine/packages/docker
${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml
docker build -t onap/policy-pe target/policy-pe
cd ${WORK_DIR}
git clone -b dublin http://gerrit.onap.org/r/policy/drools-pdp
cd drools-pdp/packages/docker
${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn prepare-package --settings ${WORK_DIR}/oparent/settings.xml
docker build -t onap/policy-drools target/policy-drools
cd ${WORK_DIR}
git clone -b dublin http://gerrit.onap.org/r/policy/docker
cd docker
chmod +x config/drools/drools-tweaks.sh
echo $IP > config/pe/ip_addr.txt
ls -l config/pe/ip_addr.txt
cat config/pe/ip_addr.txt
export MTU=9126
export PRELOAD_POLICIES=false
docker-compose -f docker-compose-integration.yml up -d
if [ ! $? -eq 0 ]; then
echo "Docker compose failed"
exit 1
fi
docker ps
POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
echo ${POLICY_IP}
PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
echo ${PDP_IP}
PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
echo ${PAP_IP}
BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
echo ${BRMS_IP}
NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
echo ${NEXUS_IP}
MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
echo ${MARIADB_IP}
sleep 3m
docker logs mariadb 2>&1 | grep -q "mysqld: ready for connections"
if [ $? -eq 0 ]; then
# mariadb is ok - sleep a little longer for others
sleep 2m
else
echo mariadb is not ready
echo Restarting...
docker kill drools pdp pap brmsgw nexus mariadb
docker rm -f drools pdp pap brmsgw nexus mariadb
docker-compose -f docker-compose-integration.yml up -d
if [ ! $? -eq 0 ]; then
echo "Docker compose failed"
exit 1
fi
docker ps
POLICY_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' drools`
echo ${POLICY_IP}
PDP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pdp`
echo ${PDP_IP}
PAP_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' pap`
echo ${PAP_IP}
BRMS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' brmsgw`
echo ${BRMS_IP}
NEXUS_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' nexus`
echo ${NEXUS_IP}
MARIADB_IP=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress}}' mariadb`
echo ${MARIADB_IP}
sleep 5m
fi
netstat -tnl
${DIR}/wait_for_port.sh ${MARIADB_IP} 3306
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${MARIADB_IP} 3306"
telnet ${MARIADB_IP} 3306 < /dev/null
nc -vz ${MARIADB_IP} 3306
docker logs mariadb
exit $rc
fi
${DIR}/wait_for_port.sh ${NEXUS_IP} 8081
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${NEXUS_IP} 8081"
netstat -tnl
telnet ${NEXUS_IP} 8081 < /dev/null
nc -vz ${NEXUS_IP} 8081
docker logs nexus
exit $rc
fi
${DIR}/wait_for_port.sh ${POLICY_IP} 9696
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${POLICY_IP} 9696"
netstat -tnl
telnet ${POLICY_IP} 9696 < /dev/null
nc -vz ${POLICY_IP} 9696
docker logs drools
exit $rc
fi
${DIR}/wait_for_port.sh ${PAP_IP} 9091
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${PAP_IP} 9091"
netstat -tnl
telnet ${PAP_IP} 9091 < /dev/null
nc -vz ${PAP_IP} 9091
docker logs pap
exit $rc
fi
${DIR}/wait_for_port.sh ${PDP_IP} 8081
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${PDP_IP} 8081"
netstat -tnl
telnet ${PDP_IP} 8081 < /dev/null
nc -vz ${PDP_IP} 8081
docker logs pdp
exit $rc
fi
${DIR}/wait_for_port.sh ${BRMS_IP} 9989
rc=$?
if [[ $rc != 0 ]]; then
echo "cannot open ${BRMS_IP} 9989"
netstat -tnl
telnet ${BRMS_IP} 9989" < /dev/null
nc -vz ${BRMS_IP} 9989"
docker logs brmsgw
exit $rc
fi
docker logs drools
docker logs pap
docker logs pdp
docker logs brmsgw
TIME_OUT=300
INTERVAL=20
TIME=0
while [ "$TIME" -lt "$TIME_OUT" ]; do
curl -k -i --user "demo@people.osaaf.org:demo123456!" -H "ContentType: application/json" -H "Accept: application/json" https://${POLICY_IP}:6969/healthcheck && break
echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
sleep $INTERVAL
TIME=$(($TIME+$INTERVAL))
done
TIME_OUT=300
INTERVAL=20
TIME=0
while [ "$TIME" -lt "$TIME_OUT" ]; do
curl -k -i -v -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'ClientAuth: cHl0aG9uOnRlc3Q=' -H 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' -H 'Environment: TEST' -d '{"policyName": ".*"}' https://${PDP_IP}:8081/pdp/api/getConfig && break
echo Sleep: $INTERVAL seconds before testing if Policy is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
sleep $INTERVAL
TIME=$(($TIME+$INTERVAL))
done
#
# Add more sleep for everything to settle
#
sleep 3m
|