Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ============LICENSE_START======================================================= |
| 3 | # Copyright (C) 2018 Ericsson. All rights reserved. |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 4 | # |
| 5 | # Modifications copyright (c) 2019 Nordix Foundation. |
| 6 | # Modifications Copyright (C) 2019 AT&T Intellectual Property. |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 7 | # ================================================================================ |
| 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.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 22 | |
Bilal A | d46ab2e | 2019-06-07 21:25:59 +0000 | [diff] [blame] | 23 | source ${SCRIPTS}/policy/config/policy-csit.conf |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 24 | export POLICY_MARIADB_VER |
Bilal A | d46ab2e | 2019-06-07 21:25:59 +0000 | [diff] [blame] | 25 | echo ${GERRIT_BRANCH} |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 26 | echo ${POLICY_MARIADB_VER} |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 27 | |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 28 | echo "Uninstall docker-py and reinstall docker." |
| 29 | pip uninstall -y docker-py |
| 30 | pip uninstall -y docker |
| 31 | pip install -U docker==2.7.0 |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 32 | |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 33 | # the directory of the script |
| 34 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 35 | echo ${DIR} |
Bilal A | d46ab2e | 2019-06-07 21:25:59 +0000 | [diff] [blame] | 36 | |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 37 | # the temp directory used, within $DIR |
| 38 | # omit the -p parameter to create a temporal directory in the default location |
| 39 | WORK_DIR=`mktemp -d -p "$DIR"` |
| 40 | echo ${WORK_DIR} |
| 41 | |
| 42 | cd ${WORK_DIR} |
| 43 | |
| 44 | # check if tmp dir was created |
| 45 | if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then |
| 46 | echo "Could not create temp dir" |
| 47 | exit 1 |
Bilal A | d46ab2e | 2019-06-07 21:25:59 +0000 | [diff] [blame] | 48 | fi |
Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 49 | |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 50 | # bring down maven |
| 51 | mkdir maven |
| 52 | cd maven |
Martin Klozik | f5ae348 | 2019-09-04 10:24:25 +0200 | [diff] [blame] | 53 | # download maven from automatically selected mirror server |
| 54 | curl -vLO "https://www.apache.org/dyn/mirrors/mirrors.cgi?cca2=us&preferred=http://apache.claz.org/&action=download&filename=maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz" |
| 55 | if ! tar -xzvf apache-maven-3.3.9-bin.tar.gz ; then |
| 56 | echo "Installation of maven has failed!" |
| 57 | exit 1 |
| 58 | fi |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 59 | ls -l |
| 60 | export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin |
| 61 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v |
| 62 | cd .. |
| 63 | |
| 64 | git clone http://gerrit.onap.org/r/oparent |
| 65 | git clone --depth 1 https://gerrit.onap.org/r/policy/models -b ${GERRIT_BRANCH} |
| 66 | cd models/models-sim/models-sim-dmaap |
| 67 | ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install -DskipTests --settings ${WORK_DIR}/oparent/settings.xml |
| 68 | bash ./src/main/package/docker/docker_build.sh |
| 69 | cd ${WORKSPACE} |
| 70 | rm -rf ${WORK_DIR} |
| 71 | sleep 3 |
| 72 | |
| 73 | sudo apt-get -y install libxml2-utils |
Bilal A | 71e5737 | 2019-12-17 02:17:57 +0000 | [diff] [blame] | 74 | POLICY_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()' -)" |
| 75 | export POLICY_API_VERSION="${POLICY_API_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" |
| 76 | POLICY_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()' -)" |
| 77 | export POLICY_PAP_VERSION="${POLICY_PAP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" |
| 78 | POLICY_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()' -)" |
| 79 | export POLICY_APEX_PDP_VERSION="${POLICY_APEX_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" |
| 80 | POLICY_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()' -)" |
| 81 | export POLICY_DISTRIBUTION_VERSION="${POLICY_DISTRIBUTION_VERSION_EXTRACT:0:3}-SNAPSHOT-latest" |
a.sreekumar | df7d47f | 2019-08-29 13:24:04 +0000 | [diff] [blame] | 82 | |
| 83 | echo ${POLICY_API_VERSION} |
| 84 | echo ${POLICY_PAP_VERSION} |
| 85 | echo ${POLICY_APEX_PDP_VERSION} |
| 86 | echo ${POLICY_DISTRIBUTION_VERSION} |
| 87 | |
| 88 | SCRIPT_DIR=${WORKSPACE}/scripts/policy/policy-distribution |
| 89 | |
| 90 | # Remaking the csar file in case if the file got corrupted |
| 91 | zip -F ${SCRIPT_DIR}/config/distribution/csar/sample_csar_with_apex_policy.csar --out ${SCRIPT_DIR}/config/distribution/csar/csar_temp.csar |
| 92 | |
| 93 | # Adding this waiting container due to race condition between pap and mariadb |
| 94 | docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_dependencies |
| 95 | |
| 96 | #Configure the database |
| 97 | docker exec -it mariadb chmod +x /docker-entrypoint-initdb.d/db.sh |
| 98 | docker exec -it mariadb /docker-entrypoint-initdb.d/db.sh |
| 99 | |
| 100 | # now bring everything else up |
| 101 | docker-compose -f ${SCRIPT_DIR}/docker-compose-distribution.yml run --rm start_all |
| 102 | |
| 103 | unset http_proxy https_proxy |
| 104 | |
| 105 | POLICY_API_IP=`get-instance-ip.sh policy-api` |
| 106 | POLICY_PAP_IP=`get-instance-ip.sh policy-pap` |
| 107 | MARIADB_IP=`get-instance-ip.sh mariadb` |
| 108 | APEX_IP=`get-instance-ip.sh policy-apex-pdp` |
| 109 | DMAAP_IP=`get-instance-ip.sh dmaap-simulator` |
| 110 | POLICY_DISTRIBUTION_IP=`get-instance-ip.sh policy-distribution` |
| 111 | |
| 112 | echo PAP IP IS ${POLICY_PAP_IP} |
| 113 | echo MARIADB IP IS ${MARIADB_IP} |
| 114 | echo API IP IS ${POLICY_API_IP} |
| 115 | echo APEX IP IS ${APEX_IP} |
| 116 | echo DMAAP_IP IS ${DMAAP_IP} |
| 117 | echo POLICY_DISTRIBUTION_IP IS ${POLICY_DISTRIBUTION_IP} |
| 118 | |
| 119 | ROBOT_VARIABLES="-v APEX_IP:${APEX_IP} -v SCRIPT_DIR:${SCRIPT_DIR} -v POLICY_DISTRIBUTION_IP:${POLICY_DISTRIBUTION_IP}" |