blob: 4d5d1c85c42bf2238c9c22933a2902eca64fb8ac [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
20#
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020021# Branched from ccsdk/distribution to this repository Feb 23, 2021
22#
Ruslan Kashapovaad22402021-02-23 10:08:00 +020023
24# Copy docker-compose.yml and application.yml to archives
25mkdir -p $WORKSPACE/archives/docker-compose
26cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/docker-compose
27cd $WORKSPACE/archives/docker-compose
28
29# Set env variables for docker compose
30export DB_HOST=dbpostgresql
31export DB_USERNAME=cps
32export DB_PASSWORD=cps
33# Use latest image version
34export VERSION=latest
35
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020036# download docker-compose of a required version (1.25.0 supports configuration of version 3.7)
37curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose
38chmod +x docker-compose
39
Ruslan Kashapovaad22402021-02-23 10:08:00 +020040# start CPS and PostgreSQL containers with docker compose
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020041./docker-compose up -d
Ruslan Kashapovaad22402021-02-23 10:08:00 +020042
43# Validate CPS service initialization completed via periodic log checking for line like below:
44# org.onap.cps.Application ... Started Application in X.XXX seconds
45
46TIME_OUT=300
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020047INTERVAL=5
Ruslan Kashapovaad22402021-02-23 10:08:00 +020048TIME=0
49
50while [ "$TIME" -le "$TIME_OUT" ]; do
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020051 LOG_FOUND=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" )
Ruslan Kashapovaad22402021-02-23 10:08:00 +020052
53 if [ "$LOG_FOUND" -gt 0 ]; then
54 echo "CPS Service started"
55 break;
56 fi
57
58 echo "Sleep $INTERVAL seconds before next check for CPS initialization (waiting $TIME seconds; timeout is $TIME_OUT seconds)"
59 sleep $INTERVAL
60 TIME=$((TIME + INTERVAL))
61done
62
63if [ "$TIME" -gt "$TIME_OUT" ]; then
64 echo "TIME OUT: CPS Service wasn't able to start in $TIME_OUT seconds, setup failed."
65 exit 1;
66fi
67
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020068# The CPS host according to docker-compose.yml
Ruslan Kashapovaad22402021-02-23 10:08:00 +020069CPS_HOST="http://localhost:8883"
70
71# Pass variables required for Robot test suites in ROBOT_VARIABLES
Ruslan Kashapovd44fcee2021-02-26 11:42:29 +020072ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v DATADIR:$WORKSPACE/data"
Ruslan Kashapovaad22402021-02-23 10:08:00 +020073