blob: 7bf0340ba615ae47b866b5d9c0b89b5a16c1575e [file] [log] [blame]
puthuparambil.aditya8d443ef2021-09-13 18:01:11 +01001#!/bin/bash
2#
3# ============LICENSE_START=======================================================
4# Copyright (C) 2021 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
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
33# start CPS Temporal, cps-core, timescaledb, PostgresSQL and kafka containers with docker compose
34./docker-compose up -d
35python3 --version
36# Validate CPS service initialization completed via periodic log checking for line like below:
37# org.onap.cps.temporal.Application ... Started Application in X.XXX seconds
38
39while [ "$TIME" -le "$TIME_OUT" ]; do
40 LOG_FOUND_CPS_TEMPORAL=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.temporal.Application" | egrep -c "Started Application in" )
41 LOG_FOUND_CPS=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" )
42
43 if [ "$LOG_FOUND_CPS" -gt 0 ] && [ "$LOG_FOUND_CPS_TEMPORAL" -gt 0 ]; then
44 echo "CPS Service started"
45 break;
46 fi
47
48 echo "Sleep $INTERVAL seconds before next check for CPS initialization (waiting $TIME seconds; timeout is $TIME_OUT seconds)"
49 sleep $INTERVAL
50 TIME=$((TIME + INTERVAL))
51done
52
53if [ "$TIME" -gt "$TIME_OUT" ]; then
54 echo "TIME OUT: CPS services did not start in $TIME_OUT seconds, setup failed."
55 exit 1;
56fi
57
58# Pass variables required for Robot test suites in ROBOT_VARIABLES
59ROBOT_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"