blob: 96396462a46d97ce09d8414825c4848a54bc6cfa [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001#!/bin/bash
2# ============LICENSE_START=======================================================
3# Copyright (C) 2018 Ericsson. All rights reserved.
a.sreekumar7d80c382019-05-07 13:36:39 +00004#
5# Modifications copyright (c) 2019 Nordix Foundation.
Gary Wu9abb61c2018-09-27 10:38:50 -07006# ================================================================================
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19# SPDX-License-Identifier: Apache-2.0
20# ============LICENSE_END=========================================================
21
a.sreekumar7d80c382019-05-07 13:36:39 +000022echo "Uninstall docker-py and reinstall docker."
23pip uninstall -y docker-py
24pip uninstall -y docker
25pip install -U docker==2.7.0
Gary Wu9abb61c2018-09-27 10:38:50 -070026
a.sreekumar7d80c382019-05-07 13:36:39 +000027# the directory of the script
28DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
29echo ${DIR}
30
31# the temp directory used, within $DIR
32# omit the -p parameter to create a temporal directory in the default location
33WORK_DIR=`mktemp -d -p "$DIR"`
34echo ${WORK_DIR}
35
36cd ${WORK_DIR}
37
38# check if tmp dir was created
39if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
40 echo "Could not create temp dir"
41 exit 1
42fi
43
44# bring down maven
45mkdir maven
46cd maven
47curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
48tar -xzvf apache-maven-3.3.9-bin.tar.gz
49ls -l
50export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin
51${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v
52cd ..
53
54git clone http://gerrit.onap.org/r/oparent
55git clone --depth 1 https://gerrit.onap.org/r/policy/models -b master
56cd models/models-sim/models-sim-dmaap
57${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install -DskipTests --settings ${WORK_DIR}/oparent/settings.xml
58bash ./src/main/package/docker/docker_build.sh
59cd ${WORKSPACE}
60rm -rf ${WORK_DIR}
61sleep 3
62
63# Adding this waiting container due to race condition between pap and mariadb
64docker-compose -f ${WORKSPACE}/scripts/policy/policy-apex-pdp/docker-compose-apex.yml run --rm start_dependencies
65docker-compose -f ${WORKSPACE}/scripts/policy/policy-apex-pdp/docker-compose-apex.yml up -d
66
67POLICY_API_IP=`get-instance-ip.sh policy-api`
68POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
69MARIADB_IP=`get-instance-ip.sh mariadb`
70APEX_IP=`get-instance-ip.sh policy-apex-pdp`
71DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
72
73echo PAP IP IS ${POLICY_PAP_IP}
74echo MARIADB IP IS ${MARIADB_IP}
75echo API IP IS ${POLICY_API_IP}
Gary Wu9abb61c2018-09-27 10:38:50 -070076echo APEX IP IS ${APEX_IP}
a.sreekumar7d80c382019-05-07 13:36:39 +000077echo DMAAP_IP IS ${DMAAP_IP}
78
Jorge Hernandezfd98e3c2018-10-01 09:57:59 -050079# Wait for initialization
Gary Wu9abb61c2018-09-27 10:38:50 -070080for i in {1..10}; do
a.sreekumar7d80c382019-05-07 13:36:39 +000081 curl -sS ${MARIADB_IP}:3306 && break
Gary Wu9abb61c2018-09-27 10:38:50 -070082 echo sleep $i
83 sleep $i
84done
a.sreekumar7d80c382019-05-07 13:36:39 +000085for i in {1..10}; do
86 curl -sS ${APEX_IP}:6969 && break
87 echo sleep $i
88 sleep $i
89done
90for i in {1..10}; do
91 curl -sS ${DMAAP_IP}:3904 && break
92 echo sleep $i
93 sleep $i
94done
95#Configure the database
96docker exec -it mariadb chmod +x /docker-entrypoint-initdb.d/db.sh
97docker exec -it mariadb /docker-entrypoint-initdb.d/db.sh
Gary Wu9abb61c2018-09-27 10:38:50 -070098
a.sreekumar7d80c382019-05-07 13:36:39 +000099ROBOT_VARIABLES="-v APEX_IP:${APEX_IP} -v POLICY_API_IP:${POLICY_API_IP} -v POLICY_PAP_IP:${POLICY_PAP_IP}"