99b0015c8750b133218e00b8f1f91c5c9a39207b
[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_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()' -)"
38 export POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
39 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()' -)"
40 echo ${POLICY_DROOLS_APPS_VERSION_EXTRACT}
41 export POLICY_DROOLS_APPS_VERSION="${POLICY_DROOLS_APPS_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
42
43 echo ${POLICY_XACML_PDP_VERSION}
44 echo ${POLICY_DROOLS_APPS_VERSION}
45
46 echo "user information: $(id)"
47 echo "docker and docker-compose versions:"
48 docker -v && docker-compose -v
49
50 # Adding this waiting container due to race condition between drools and mariadb
51 docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_dependencies
52
53 # now bring everything else up
54 docker-compose -f ${SCR2}/docker-compose-drools-apps.yml run --rm start_all
55
56 unset http_proxy https_proxy
57
58 DROOLS_IP=`get-instance-ip.sh drools`
59 XACML_IP=`get-instance-ip.sh policy-xacml-pdp`
60 SIM_IP=`get-instance-ip.sh policy.api.simpledemo.onap.org`
61 export SIM_IP
62
63 echo DROOLS IP IS ${DROOLS_IP}
64 echo XACML IP IS ${XACML_IP}
65 echo SIMULATORS IP IS ${SIM_IP}
66
67 # activate xacml
68 ${SCR2}/manage.sh ${SCR2}/activate.xacml.json
69
70 # give enough time for the controllers to come up
71 sleep 15
72
73 # wait for xacml to activate
74 ${SCRIPTS}/policy/wait_for_port.sh ${XACML_IP} 6969
75
76 ROBOT_VARIABLES=""
77 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SCR2:${SCR2}"
78 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DROOLS_IP:${DROOLS_IP}"
79 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v XACML_IP:${XACML_IP}"
80 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SIM_IP:${SIM_IP}"