blob: d1a086328f645f4bf4d9a3e1ed7e393018bc901f [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.
Bilal A9f54c002020-01-16 16:12:19 +00006# Modifications Copyright (C) 2020 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=========================================================
Bilal Ad46ab2e2019-06-07 21:25:59 +000022source ${SCRIPTS}/policy/config/policy-csit.conf
a.sreekumardf7d47f2019-08-29 13:24:04 +000023export POLICY_MARIADB_VER
Bilal Ad46ab2e2019-06-07 21:25:59 +000024echo ${GERRIT_BRANCH}
a.sreekumardf7d47f2019-08-29 13:24:04 +000025echo ${POLICY_MARIADB_VER}
Gary Wu9abb61c2018-09-27 10:38:50 -070026
a.sreekumardf7d47f2019-08-29 13:24:04 +000027echo "Uninstall docker-py and reinstall docker."
28pip uninstall -y docker-py
29pip uninstall -y docker
30pip install -U docker==2.7.0
Gary Wu9abb61c2018-09-27 10:38:50 -070031
a.sreekumardf7d47f2019-08-29 13:24:04 +000032# the directory of the script
33DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
34echo ${DIR}
Bilal Ad46ab2e2019-06-07 21:25:59 +000035
a.sreekumardf7d47f2019-08-29 13:24:04 +000036# the temp directory used, within $DIR
37# omit the -p parameter to create a temporal directory in the default location
38WORK_DIR=`mktemp -d -p "$DIR"`
39echo ${WORK_DIR}
40
41cd ${WORK_DIR}
42
43# check if tmp dir was created
44if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
45 echo "Could not create temp dir"
46 exit 1
Bilal Ad46ab2e2019-06-07 21:25:59 +000047fi
Gary Wu9abb61c2018-09-27 10:38:50 -070048
a.sreekumardf7d47f2019-08-29 13:24:04 +000049sudo apt-get -y install libxml2-utils
Bilal A9f54c002020-01-16 16:12:19 +000050bash ${SCRIPTS}/policy/policy-models-dmaap-sim.sh
51
Bilal A71e57372019-12-17 02:17:57 +000052POLICY_API_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
53export POLICY_API_VERSION="${POLICY_API_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
54POLICY_PAP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
55export POLICY_PAP_VERSION="${POLICY_PAP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
56POLICY_APEX_PDP_VERSION_EXTRACT="$(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()' -)"
57export POLICY_APEX_PDP_VERSION="${POLICY_APEX_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
58POLICY_DISTRIBUTION_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/distribution/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
59export POLICY_DISTRIBUTION_VERSION="${POLICY_DISTRIBUTION_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
a.sreekumardf7d47f2019-08-29 13:24:04 +000060
61echo ${POLICY_API_VERSION}
62echo ${POLICY_PAP_VERSION}
63echo ${POLICY_APEX_PDP_VERSION}
64echo ${POLICY_DISTRIBUTION_VERSION}
65
66SCRIPT_DIR=${WORKSPACE}/scripts/policy/policy-distribution
67
68# Remaking the csar file in case if the file got corrupted
69zip -F ${SCRIPT_DIR}/config/distribution/csar/sample_csar_with_apex_policy.csar --out ${SCRIPT_DIR}/config/distribution/csar/csar_temp.csar
70
71# Adding this waiting container due to race condition between pap and mariadb
72docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_dependencies
73
74#Configure the database
75docker exec -it mariadb chmod +x /docker-entrypoint-initdb.d/db.sh
76docker exec -it mariadb /docker-entrypoint-initdb.d/db.sh
77
78# now bring everything else up
79docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_all
80
81unset http_proxy https_proxy
82
83POLICY_API_IP=`get-instance-ip.sh policy-api`
84POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
85MARIADB_IP=`get-instance-ip.sh mariadb`
86APEX_IP=`get-instance-ip.sh policy-apex-pdp`
87DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
88POLICY_DISTRIBUTION_IP=`get-instance-ip.sh policy-distribution`
89
90echo PAP IP IS ${POLICY_PAP_IP}
91echo MARIADB IP IS ${MARIADB_IP}
92echo API IP IS ${POLICY_API_IP}
93echo APEX IP IS ${APEX_IP}
94echo DMAAP_IP IS ${DMAAP_IP}
95echo POLICY_DISTRIBUTION_IP IS ${POLICY_DISTRIBUTION_IP}
96
97ROBOT_VARIABLES="-v APEX_IP:${APEX_IP} -v SCRIPT_DIR:${SCRIPT_DIR} -v POLICY_DISTRIBUTION_IP:${POLICY_DISTRIBUTION_IP}"