Fix Apex-PDP postgres CSIT failures
[policy/docker.git] / csit / resources / scripts / setup-apex-pdp-postgres.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2023 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 source "${SCRIPTS}"/node-templates.sh
21
22 source "${WORKSPACE}"/compose/start-postgres-tests.sh 1
23
24 sleep 10
25 unset http_proxy https_proxy
26
27 # wait for the app to start up
28 bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT}
29 bash "${SCRIPTS}"/wait_for_rest.sh localhost ${APEX_PORT}
30
31 sleep 20
32
33 healthy=false
34
35 while [ $healthy = false ]
36 do
37     msg=`curl -s -k --user 'policyadmin:zb!XztG34' http://localhost:${APEX_PORT}/policy/apex-pdp/v1/healthcheck`
38     echo "${msg}" | grep -q true
39     if [ "${?}" -eq 0 ]
40     then
41         healthy=true
42         break
43     fi
44     sleep 10s
45 done
46
47 export DMAAP_IP="localhost:${DMAAP_PORT}"
48 export SUITES="apex-pdp-test.robot"
49
50 ROBOT_VARIABLES="-v POLICY_PAP_IP:localhost:${PAP_PORT} -v POLICY_API_IP:localhost:${API_PORT}
51 -v PROMETHEUS_IP:localhost:${PROMETHEUS_PORT} -v DATA:${DATA} -v NODETEMPLATES:${NODETEMPLATES}
52 -v APEX_IP:localhost:${APEX_PORT} -v DMAAP_IP:${DMAAP_IP}
53 -v APEX_EVENTS_IP:localhost:${APEX_EVENTS_PORT}"