Update smo deployment with ICS
[oam.git] / solution / integration / smo / non-rt-ric / test / health_check.sh
1 #!/usr/bin/env bash
2 ###############################################################################
3 # Copyright 2017 Huawei Technologies Co., Ltd.
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 # Modifications copyright (c) 2021 Nordix Foundation
18 #
19 ###############################################################################
20
21 unset http_proxy https_proxy
22 SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
23 docker stop $(docker ps -aq)
24 docker system prune -f
25 docker network create oam
26 docker network create smo
27
28 cd ${SHELL_FOLDER}/../config/pms/
29 cp application_configuration.json.nosdnc application_configuration.json
30
31 cd ${SHELL_FOLDER}/../
32
33 # start NONRTRIC containers with docker compose and configuration from docker-compose.yml
34 docker-compose up -d
35
36 checkStatus(){
37     for i in {1..60}; do
38         res=$($1)
39         echo "$res"
40         expect=$2
41         if [ "$res" == "$expect" ]; then
42             echo -e "$3 is alive!\n"
43             break;
44         else
45             sleep $i
46         fi
47     done
48 }
49 # Healthcheck docker containers
50
51 # check SIM1 status
52 echo "check SIM1 status:"
53 checkStatus "curl -skw %{http_code} http://localhost:30001/" "OK200" "SIM1"
54
55 # check SIM2 status
56 echo "check SIM2 status:"
57 checkStatus "curl -skw %{http_code} http://localhost:30003/" "OK200" "SIM2"
58
59 # check SIM3 status
60 echo "check SIM3 status:"
61 checkStatus "curl -skw %{http_code} http://localhost:30005/" "OK200" "SIM3"
62
63 # check PMS status
64 echo "check PMS status:"
65 checkStatus "curl -skw %{http_code} http://localhost:8091/status" "hunky dory200" "PMS"
66
67 # check ICS status
68 echo "check ICS status:"
69 checkStatus "curl -skw %{http_code} http://localhost:8083/status" '{"status":"hunky dory","no_of_producers":0,"no_of_types":0,"no_of_jobs":0}200' "ICS"
70
71 echo "NONRTRIC health check passed."