Update CPS version from 3.0.0 to 3.1.0
[cps/cps-temporal.git] / csit / plans / default / setup.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2021-2022 Bell Canada.
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 # Copy docker-compose.yml and application.yml to archives
22 mkdir -p $WORKSPACE/archives/docker-compose
23 cp $WORKSPACE/../*.yml $WORKSPACE/archives/docker-compose
24 cd $WORKSPACE/archives/docker-compose
25
26 # properties file with docker-compose service properties
27 source $WORKSPACE/plans/default/setup.properties
28
29 # download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
30 curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
31 chmod +x docker-compose
32
33 # Set environment variables for docker compose
34 export CPS_TEMPORAL_DOCKER_REPO=
35 export STABLE_CPS_CORE_VERSION=3.1.0
36 # start CPS Temporal, cps-core, timescaledb, PostgresSQL and kafka containers with docker compose
37 ./docker-compose up -d
38 python3 --version
39 # Validate CPS service initialization completed via periodic log checking for line like below:
40 # org.onap.cps.temporal.Application ... Started Application in X.XXX seconds
41
42 while [ "$TIME" -le "$TIME_OUT" ]; do
43   LOG_FOUND_CPS_TEMPORAL=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.temporal.Application" | egrep -c "Started Application in" )
44   LOG_FOUND_CPS=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" )
45
46   if [ "$LOG_FOUND_CPS" -gt 0 ] && [ "$LOG_FOUND_CPS_TEMPORAL" -gt 0 ]; then
47     echo "CPS Service started"
48     break;
49   fi
50
51   echo "Sleep $INTERVAL seconds before next check for CPS initialization (waiting $TIME seconds; timeout is $TIME_OUT seconds)"
52   sleep $INTERVAL
53   TIME=$((TIME + INTERVAL))
54 done
55
56 if [ "$TIME" -gt "$TIME_OUT" ]; then
57    echo "TIME OUT: CPS services did not start in $TIME_OUT seconds, setup failed."
58    exit 1;
59 fi
60
61 # Pass variables required for Robot test suites in ROBOT_VARIABLES
62 ROBOT_VARIABLES="-v  CPS_TEMPORAL_HOST:$CPS_TEMPORAL_HOST -v CPS_TEMPORAL_PORT:$CPS_TEMPORAL_PORT -v CPS_HOST:$CPS_HOST -v CPS_PORT:$CPS_PORT -v MANAGEMENT_PORT:$MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data"