blob: c70e02a195f1d26eacc851c58dfc861dbbfa3d8a [file] [log] [blame]
AndyWalsheb412c7b2020-02-13 15:05:21 +00001#!/bin/bash
2# Place the scripts in run order:
3source ${SCRIPTS}/common_functions.sh
4
5export DB_USER=pmsh
6export DB_PASSWORD=pmsh
7
8docker login -u docker -p docker nexus3.onap.org:10001
9
10TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite
11
12docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d mockserver db
13
14# Slow machine running CSITs can affect db coming up in time for PMSH
15echo "Waiting for postgres db to come up..."
16for i in {1..30}; do
17 docker exec -i db bash -c "PGPASSWORD=$DB_PASSWORD;psql -U $DB_USER -c '\q'"
18 db_response=$?
19 if [ "$db_response" = "0" ]
20 then
21 break
22 else
23 sleep 2
24 fi
25done
26[ "$db_response" != "0" ] && echo "Error: postgres db not accessible" && exit 1
27
28docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmsh
29
30PMSH_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" pmsh)
31
32# Slow machine running CSITs can affect PMSH coming up before CSITs are run
33echo "Waiting for PMSH to come up..."
34for i in {1..30}; do
35 pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://$PMSH_IP:8443/healthcheck)
36 if [ "$pmsh_response" = "200" ]
37 then
38 break
39 else
40 sleep 2
41 fi
42done
43[ "$pmsh_response" != "200" ] && echo "Error: PMSH container state not healthy" && exit 1
44
45# Wait for initialization of Docker containers
46containers_ok=false
47for i in {1..5}; do
48 if [ $(docker inspect --format '{{ .State.Running }}' mockserver) ] && \
49 [ $(docker inspect --format '{{ .State.Running }}' db) ] && \
50 [ $(docker inspect --format '{{ .State.Running }}' pmsh) ]
51 then
52 echo "All required docker containers are up."
53 containers_ok=true
54 break
55 else
56 sleep $i
57 fi
58done
59[ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1
60
61#Pass any variables required by Robot test suites in ROBOT_VARIABLES
62ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP}"