1a1dc331ecfd8415c9d201ca75d533b992986516
[integration/csit.git] / plans / policy / drools-applications / setup.sh
1 #!/bin/bash
2 #
3 # ===========LICENSE_START====================================================
4 #  Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
5 # ============================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=====================================================
18 #
19
20 # OS upgrades
21
22 source ${SCRIPTS}/policy/config/policy-csit.conf
23 export POLICY_MARIADB_VER
24 echo ${GERRIT_BRANCH}
25 echo ${POLICY_MARIADB_VER}
26
27 SCR2=${WORKSPACE}/scripts/policy/drools-apps
28
29 echo "Uninstall docker-py and reinstall docker."
30 pip uninstall -y docker-py
31 pip uninstall -y docker
32 pip install -U docker==2.7.0
33
34 sudo apt-get -y install libxml2-utils
35 ${SCRIPTS}/policy/policy-models-simulators.sh
36
37 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()' -)"
38 export POLICY_API_VERSION="${POLICY_API_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
39 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()' -)"
40 export POLICY_PAP_VERSION="${POLICY_PAP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
41 POLICY_XACML_PDP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/xacml-pdp/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
42 export POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
43 POLICY_DROOLS_APPS_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/drools-applications/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
44 echo ${POLICY_DROOLS_APPS_VERSION_EXTRACT}
45 export POLICY_DROOLS_APPS_VERSION="${POLICY_DROOLS_APPS_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
46
47 echo ${POLICY_XACML_PDP_VERSION}
48 echo ${POLICY_DROOLS_APPS_VERSION}
49
50 echo "user information: $(id)"
51 echo "docker and docker-compose versions:"
52 docker -v && docker-compose -v
53
54 # Adding this waiting container due to race condition between drools and mariadb
55 docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_dependencies
56
57 # Adding this waiting container due to race condition between pap and xacml
58 docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_pap
59
60 # now bring everything else up
61 docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_all
62
63 unset http_proxy https_proxy
64
65 DROOLS_IP=`get-instance-ip.sh drools`
66 API_IP=`get-instance-ip.sh policy-api`
67 PAP_IP=`get-instance-ip.sh policy-pap`
68 XACML_IP=`get-instance-ip.sh policy-xacml-pdp`
69 SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
70 export SIM_IP
71
72 echo DROOLS IP IS ${DROOLS_IP}
73 echo API IP IS ${API_IP}
74 echo PAP IP IS ${PAP_IP}
75 echo XACML IP IS ${XACML_IP}
76 echo SIMULATORS IP IS ${SIM_IP}
77
78 # give enough time for the controllers to come up
79 sleep 15
80
81 DATA=${WORKSPACE}/simulators/models/models-examples/src/main/resources/policies
82
83 ROBOT_VARIABLES=""
84 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SCR2:${SCR2}"
85 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DATA:${DATA}"
86 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DROOLS_IP:${DROOLS_IP}"
87 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v API_IP:${API_IP}"
88 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v PAP_IP:${PAP_IP}"
89 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v XACML_IP:${XACML_IP}"
90 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SIM_IP:${SIM_IP}"