AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Place the scripts in run order: |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 3 | |
| 4 | export DB_USER=pmsh |
| 5 | export DB_PASSWORD=pmsh |
| 6 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 7 | TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite |
| 8 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 9 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d db aai-sim cbs-sim mr-sim |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 10 | |
| 11 | # Slow machine running CSITs can affect db coming up in time for PMSH |
| 12 | echo "Waiting for postgres db to come up..." |
| 13 | for 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 |
| 22 | done |
| 23 | [ "$db_response" != "0" ] && echo "Error: postgres db not accessible" && exit 1 |
| 24 | |
| 25 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmsh |
| 26 | |
| 27 | PMSH_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 |
| 30 | echo "Waiting for PMSH to come up..." |
| 31 | for 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 |
| 39 | done |
| 40 | [ "$pmsh_response" != "200" ] && echo "Error: PMSH container state not healthy" && exit 1 |
| 41 | |
| 42 | # Wait for initialization of Docker containers |
| 43 | containers_ok=false |
| 44 | for i in {1..5}; do |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 45 | 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) ] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 50 | then |
| 51 | echo "All required docker containers are up." |
| 52 | containers_ok=true |
| 53 | break |
| 54 | else |
| 55 | sleep $i |
| 56 | fi |
| 57 | done |
| 58 | [ "$containers_ok" = "false" ] && echo "Error: required container not running." && exit 1 |
| 59 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 60 | DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db) |
| 61 | MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim) |
| 62 | CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim) |
| 63 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 64 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 65 | ROBOT_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}" |