Upgrade SDN-C
[cps.git] / csit / plans / cps / sdnc / sdnc_setup.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START=======================================================
4 #   Copyright (C) 2021-2022 Nordix Foundation.
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 #
18 #  SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
20
21 # @author Rahul Tyagi (rahul.tyagi@est.tech)
22 # setup sdnc
23
24 export SDNC_CERT_PATH=$WORKSPACE/plans/cps/sdnc/certs
25
26 #start SDNC containers with docker compose and configuration from docker-compose.yml
27 docker-compose -f $WORKSPACE/plans/cps/sdnc/docker-compose.yml up -d
28
29 # WAIT 10 minutes maximum and test every 30 seconds if SDNC is up using HealthCheck API
30 TIME_OUT=600
31 INTERVAL=30
32 TIME=0
33 while [ "$TIME" -lt "$TIME_OUT" ]; do
34   response=$(curl --write-out '%{http_code}' --silent --output /dev/null -H "Authorization: Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==" -X POST -H "X-FromAppId: csit-sdnc" -H "X-TransactionId: csit-sdnc" -H "Accept: application/json" -H "Content-Type: application/json" http://$SDNC_HOST:$SDNC_PORT/restconf/operations/SLI-API:healthcheck );
35   echo $response
36
37   if [ "$response" == "200" ]; then
38     echo SDNC started in $TIME seconds
39     break;
40   fi
41
42   echo Sleep: $INTERVAL seconds before testing if SDNC is up. Total wait time up now is: $TIME seconds. Timeout is: $TIME_OUT seconds
43   sleep $INTERVAL
44   TIME=$(($TIME+$INTERVAL))
45 done
46
47 if [ "$TIME" -ge "$TIME_OUT" ]; then
48    echo TIME OUT: karaf session not started in $TIME_OUT seconds... Could cause problems for testing activities...
49 fi