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