blob: cf29b53ac5e218e95e37853e274d538908c7ed78 [file] [log] [blame]
Ruslan Kashapovaad22402021-02-23 10:08:00 +02001#!/bin/bash
2#
3# Copyright 2016-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) 2017 AT&T Intellectual Property
18# Modifications copyright (c) 2020-2021 Samsung Electronics Co., Ltd.
19# Modifications Copyright (C) 2021 Pantheon.tech
puthuparambil.adityab46d1372021-07-09 12:51:10 +010020# Modifications Copyright (C) 2021 Bell Canada.
Ruslan Kashapovaad22402021-02-23 10:08:00 +020021#
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020022# Branched from ccsdk/distribution to this repository Feb 23, 2021
23#
Ruslan Kashapovaad22402021-02-23 10:08:00 +020024
25# Copy docker-compose.yml and application.yml to archives
26mkdir -p $WORKSPACE/archives/docker-compose
27cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/docker-compose
28cd $WORKSPACE/archives/docker-compose
29
30# Set env variables for docker compose
31export DB_HOST=dbpostgresql
32export DB_USERNAME=cps
33export DB_PASSWORD=cps
34# Use latest image version
35export VERSION=latest
36
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020037# download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
38curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
39chmod +x docker-compose
40
Ruslan Kashapovaad22402021-02-23 10:08:00 +020041# start CPS and PostgreSQL containers with docker compose
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020042./docker-compose up -d
Ruslan Kashapovaad22402021-02-23 10:08:00 +020043
44# Validate CPS service initialization completed via periodic log checking for line like below:
45# org.onap.cps.Application ... Started Application in X.XXX seconds
46
47TIME_OUT=300
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020048INTERVAL=5
Ruslan Kashapovaad22402021-02-23 10:08:00 +020049TIME=0
50
51while [ "$TIME" -le "$TIME_OUT" ]; do
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020052 LOG_FOUND=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" )
Ruslan Kashapovaad22402021-02-23 10:08:00 +020053
54 if [ "$LOG_FOUND" -gt 0 ]; then
55 echo "CPS Service started"
56 break;
57 fi
58
59 echo "Sleep $INTERVAL seconds before next check for CPS initialization (waiting $TIME seconds; timeout is $TIME_OUT seconds)"
60 sleep $INTERVAL
61 TIME=$((TIME + INTERVAL))
62done
63
64if [ "$TIME" -gt "$TIME_OUT" ]; then
65 echo "TIME OUT: CPS Service wasn't able to start in $TIME_OUT seconds, setup failed."
66 exit 1;
67fi
68
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020069# The CPS host according to docker-compose.yml
puthuparambil.adityab46d1372021-07-09 12:51:10 +010070CPS_HOST="localhost"
71CPS_PORT="8883"
72
73MANAGEMENT_PORT="8887"
Ruslan Kashapovaad22402021-02-23 10:08:00 +020074
75# Pass variables required for Robot test suites in ROBOT_VARIABLES
puthuparambil.adityab46d1372021-07-09 12:51:10 +010076ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v CPS_PORT:$CPS_PORT -v MANAGEMENT_PORT:$MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data"
Ruslan Kashapovaad22402021-02-23 10:08:00 +020077