blob: 399df0e6d9f3bd099a9584a6858f1ba87b1c5a27 [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.sreekumardf7d47f2019-08-29 13:24:04 +00004#
5# Modifications copyright (c) 2019 Nordix Foundation.
6# Modifications Copyright (C) 2019 AT&T Intellectual Property.
Gary Wu9abb61c2018-09-27 10:38:50 -07007# ================================================================================
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
20# SPDX-License-Identifier: Apache-2.0
21# ============LICENSE_END=========================================================
a.sreekumardf7d47f2019-08-29 13:24:04 +000022
Bilal Ad46ab2e2019-06-07 21:25:59 +000023source ${SCRIPTS}/policy/config/policy-csit.conf
a.sreekumardf7d47f2019-08-29 13:24:04 +000024export POLICY_MARIADB_VER
Bilal Ad46ab2e2019-06-07 21:25:59 +000025echo ${GERRIT_BRANCH}
a.sreekumardf7d47f2019-08-29 13:24:04 +000026echo ${POLICY_MARIADB_VER}
Gary Wu9abb61c2018-09-27 10:38:50 -070027
a.sreekumardf7d47f2019-08-29 13:24:04 +000028echo "Uninstall docker-py and reinstall docker."
29pip uninstall -y docker-py
30pip uninstall -y docker
31pip install -U docker==2.7.0
Gary Wu9abb61c2018-09-27 10:38:50 -070032
a.sreekumardf7d47f2019-08-29 13:24:04 +000033# the directory of the script
34DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
35echo ${DIR}
Bilal Ad46ab2e2019-06-07 21:25:59 +000036
a.sreekumardf7d47f2019-08-29 13:24:04 +000037# the temp directory used, within $DIR
38# omit the -p parameter to create a temporal directory in the default location
39WORK_DIR=`mktemp -d -p "$DIR"`
40echo ${WORK_DIR}
41
42cd ${WORK_DIR}
43
44# check if tmp dir was created
45if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
46 echo "Could not create temp dir"
47 exit 1
Bilal Ad46ab2e2019-06-07 21:25:59 +000048fi
Gary Wu9abb61c2018-09-27 10:38:50 -070049
a.sreekumardf7d47f2019-08-29 13:24:04 +000050# bring down maven
51mkdir maven
52cd maven
53curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
54tar -xzvf apache-maven-3.3.9-bin.tar.gz
55ls -l
56export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin
57${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v
58cd ..
59
60git clone http://gerrit.onap.org/r/oparent
61git clone --depth 1 https://gerrit.onap.org/r/policy/models -b ${GERRIT_BRANCH}
62cd models/models-sim/models-sim-dmaap
63${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install -DskipTests --settings ${WORK_DIR}/oparent/settings.xml
64bash ./src/main/package/docker/docker_build.sh
65cd ${WORKSPACE}
66rm -rf ${WORK_DIR}
67sleep 3
68
69sudo apt-get -y install libxml2-utils
70export POLICY_API_VERSION="$(curl -q --silent https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
71export POLICY_PAP_VERSION="$(curl -q --silent https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
72export POLICY_APEX_PDP_VERSION="$(curl -q --silent https://git.onap.org/policy/apex-pdp/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
73export POLICY_DISTRIBUTION_VERSION="$(curl -q --silent https://git.onap.org/policy/distribution/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
74
75echo ${POLICY_API_VERSION}
76echo ${POLICY_PAP_VERSION}
77echo ${POLICY_APEX_PDP_VERSION}
78echo ${POLICY_DISTRIBUTION_VERSION}
79
80SCRIPT_DIR=${WORKSPACE}/scripts/policy/policy-distribution
81
82# Remaking the csar file in case if the file got corrupted
83zip -F ${SCRIPT_DIR}/config/distribution/csar/sample_csar_with_apex_policy.csar --out ${SCRIPT_DIR}/config/distribution/csar/csar_temp.csar
84
85# Adding this waiting container due to race condition between pap and mariadb
86docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_dependencies
87
88#Configure the database
89docker exec -it mariadb chmod +x /docker-entrypoint-initdb.d/db.sh
90docker exec -it mariadb /docker-entrypoint-initdb.d/db.sh
91
92# now bring everything else up
93docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_all
94
95unset http_proxy https_proxy
96
97POLICY_API_IP=`get-instance-ip.sh policy-api`
98POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
99MARIADB_IP=`get-instance-ip.sh mariadb`
100APEX_IP=`get-instance-ip.sh policy-apex-pdp`
101DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
102POLICY_DISTRIBUTION_IP=`get-instance-ip.sh policy-distribution`
103
104echo PAP IP IS ${POLICY_PAP_IP}
105echo MARIADB IP IS ${MARIADB_IP}
106echo API IP IS ${POLICY_API_IP}
107echo APEX IP IS ${APEX_IP}
108echo DMAAP_IP IS ${DMAAP_IP}
109echo POLICY_DISTRIBUTION_IP IS ${POLICY_DISTRIBUTION_IP}
110
111ROBOT_VARIABLES="-v APEX_IP:${APEX_IP} -v SCRIPT_DIR:${SCRIPT_DIR} -v POLICY_DISTRIBUTION_IP:${POLICY_DISTRIBUTION_IP}"