Add script to start PMS and add policy type
[nonrtric/rapp/healthcheck.git] / test / start.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2022 Nordix Foundation. 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 docker network create nonrtric-docker-net 2> /dev/null
21
22 DIR="$( cd "$( dirname "$0" )" && pwd )"
23
24 PMS_PORT=8081
25 docker run --detach --rm -v $DIR/application_configuration.json:/opt/app/policy-agent/data/application_configuration.json -p $PMS_PORT:$PMS_PORT -p 8433:8433 --network=nonrtric-docker-net --name=policy-agent-container nexus3.o-ran-sc.org:10002/o-ran-sc/nonrtric-plt-a1policymanagementservice:2.5.0
26 SIM_PORT=8085
27 docker run --detach --rm -p $SIM_PORT:$SIM_PORT -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e ALLOW_HTTP=true --network=nonrtric-docker-net --name=ric1 nexus3.o-ran-sc.org:10002/o-ran-sc/a1-simulator:2.3.1
28
29 docker run --detach --rm -p 8086:$SIM_PORT -p 8186:8185 -e A1_VERSION=STD_1.1.3 -e ALLOW_HTTP=true --network=nonrtric-docker-net --name=ric2 nexus3.o-ran-sc.org:10002/o-ran-sc/a1-simulator:2.3.1
30
31 retcode=1
32 while [ $retcode -ne 0 ]; do
33     RES=$(curl -s -w '%{http_code}'  -X PUT -v http://localhost:$SIM_PORT/a1-p/policytypes/2 -H Content-Type:application/json --data-binary @sim_hw.json)
34     retcode=$?
35     if [ $retcode -eq 0 ]; then
36         status=${RES:${#RES}-3}
37         if [ $status -ne 201 ]; then
38             retcode=1
39         fi
40     fi
41
42     if [ $retcode -ne 0 ]; then
43         echo "Retrying..."
44         sleep 1
45     fi
46 done
47
48 retcode=1
49 while [ $retcode -ne 0 ]; do
50     echo "Checking that type is available"
51     RES=$(curl -s -w '%{http_code}' localhost:$PMS_PORT/a1-policy/v2/rics)
52     retcode=$?
53     if [ $retcode -eq 0 ]; then
54         if [[ "$RES" != *'"policytype_ids":["2"]'* ]]; then
55             retcode=1
56         fi
57     fi
58     if [ $retcode -ne 0 ]; then
59         echo "Retrying..."
60         sleep 1
61     fi
62 done