AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Place the scripts in run order: |
| 3 | source ${SCRIPTS}/common_functions.sh |
| 4 | |
| 5 | export DB_USER=pmsh |
| 6 | export DB_PASSWORD=pmsh |
| 7 | |
| 8 | docker login -u docker -p docker nexus3.onap.org:10001 |
| 9 | |
| 10 | TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite |
| 11 | |
| 12 | docker-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 |
| 15 | echo "Waiting for postgres db to come up..." |
| 16 | for 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 |
| 25 | done |
| 26 | [ "$db_response" != "0" ] && echo "Error: postgres db not accessible" && exit 1 |
| 27 | |
| 28 | docker-compose -f $TEST_PLANS_DIR/docker-compose.yml up -d pmsh |
| 29 | |
| 30 | PMSH_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 |
| 33 | echo "Waiting for PMSH to come up..." |
| 34 | for 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 |
| 42 | done |
| 43 | [ "$pmsh_response" != "200" ] && echo "Error: PMSH container state not healthy" && exit 1 |
| 44 | |
| 45 | # Wait for initialization of Docker containers |
| 46 | containers_ok=false |
| 47 | for 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 |
| 58 | done |
| 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 |
| 62 | ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP}" |