blob: 3385bc031c5026ec95d5a021a7e5bb6e730de526 [file] [log] [blame]
puthuparambil.aditya8d443ef2021-09-13 18:01:11 +01001#!/bin/bash
2#
3# ============LICENSE_START=======================================================
Bruno Sakotof7dd1c82022-03-03 12:57:42 -05004# Copyright (C) 2021-2022 Bell Canada.
puthuparambil.aditya8d443ef2021-09-13 18:01:11 +01005# ================================================================================
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
22mkdir -p $WORKSPACE/archives/docker-compose
23cp $WORKSPACE/../*.yml $WORKSPACE/archives/docker-compose
24cd $WORKSPACE/archives/docker-compose
25
26# properties file with docker-compose service properties
27source $WORKSPACE/plans/default/setup.properties
28
29# download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
30curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
31chmod +x docker-compose
32
Bruno Sakotof7dd1c82022-03-03 12:57:42 -050033# Set environment variables for docker compose
34export CPS_TEMPORAL_DOCKER_REPO=
35export STABLE_CPS_CORE_VERSION=3.0.0-SNAPSHOT-20220303T233031Z
puthuparambil.aditya8d443ef2021-09-13 18:01:11 +010036# start CPS Temporal, cps-core, timescaledb, PostgresSQL and kafka containers with docker compose
37./docker-compose up -d
38python3 --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
42while [ "$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))
54done
55
56if [ "$TIME" -gt "$TIME_OUT" ]; then
57 echo "TIME OUT: CPS services did not start in $TIME_OUT seconds, setup failed."
58 exit 1;
59fi
60
61# Pass variables required for Robot test suites in ROBOT_VARIABLES
62ROBOT_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"