Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 1 | #!/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.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 20 | # Modifications Copyright (C) 2021 Bell Canada. |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 21 | # |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 22 | # Branched from ccsdk/distribution to this repository Feb 23, 2021 |
| 23 | # |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 24 | |
| 25 | # Copy docker-compose.yml and application.yml to archives |
| 26 | mkdir -p $WORKSPACE/archives/docker-compose |
| 27 | cp $WORKSPACE/../docker-compose/*.yml $WORKSPACE/archives/docker-compose |
| 28 | cd $WORKSPACE/archives/docker-compose |
| 29 | |
| 30 | # Set env variables for docker compose |
| 31 | export DB_HOST=dbpostgresql |
| 32 | export DB_USERNAME=cps |
| 33 | export DB_PASSWORD=cps |
| 34 | # Use latest image version |
| 35 | export VERSION=latest |
| 36 | |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 37 | # download docker-compose of a required version (1.25.0 supports configuration of version 3.7) |
| 38 | curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` > docker-compose |
| 39 | chmod +x docker-compose |
| 40 | |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 41 | # start CPS and PostgreSQL containers with docker compose |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 42 | ./docker-compose up -d |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 43 | |
| 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 | |
| 47 | TIME_OUT=300 |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 48 | INTERVAL=5 |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 49 | TIME=0 |
| 50 | |
| 51 | while [ "$TIME" -le "$TIME_OUT" ]; do |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 52 | LOG_FOUND=$( ./docker-compose logs --tail="all" | grep "org.onap.cps.Application" | egrep -c "Started Application in" ) |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 53 | |
| 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)) |
| 62 | done |
| 63 | |
| 64 | if [ "$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; |
| 67 | fi |
| 68 | |
Ruslan Kashapov | d44fcee | 2021-02-26 11:42:29 +0200 | [diff] [blame] | 69 | # The CPS host according to docker-compose.yml |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 70 | CPS_HOST="localhost" |
| 71 | CPS_PORT="8883" |
| 72 | |
| 73 | MANAGEMENT_PORT="8887" |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 74 | |
| 75 | # Pass variables required for Robot test suites in ROBOT_VARIABLES |
puthuparambil.aditya | b46d137 | 2021-07-09 12:51:10 +0100 | [diff] [blame] | 76 | ROBOT_VARIABLES="-v CPS_HOST:$CPS_HOST -v CPS_PORT:$CPS_PORT -v MANAGEMENT_PORT:$MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data" |
Ruslan Kashapov | aad2240 | 2021-02-23 10:08:00 +0200 | [diff] [blame] | 77 | |