blob: eb2196a084519b456134f888d7f6d021d0edb016 [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
efiacorb67a0932020-05-22 13:48:52 +01009docker-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=$?
efiacorb67a0932020-05-22 13:48:52 +010016 if [[ "$db_response" == "0" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000017 then
18 break
19 else
20 sleep 2
21 fi
22done
efiacorb67a0932020-05-22 13:48:52 +010023[[ "$db_response" != "0" ]] && echo "Error: postgres db not accessible" && exit 1
AndyWalsheb412c7b2020-02-13 15:05:21 +000024
efiacorb67a0932020-05-22 13:48:52 +010025docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh
AndyWalsheb412c7b2020-02-13 15:05:21 +000026
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
efiacorb67a0932020-05-22 13:48:52 +010032 pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck)
33 if [[ "$pmsh_response" == "200" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000034 then
35 break
36 else
37 sleep 2
38 fi
39done
efiacorb67a0932020-05-22 13:48:52 +010040[[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1
41
42# Set log level to DEBUG
43docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF
44version: 1
45
46disable_existing_loggers: true
47
48loggers:
49 onap_logger:
50 level: DEBUG
51 handlers: [onap_log_handler, stdout_handler]
52 propagate: false
53handlers:
54 onap_log_handler:
55 class: logging.handlers.RotatingFileHandler
56 filename: /var/log/ONAP/dcaegen2/services/pmsh/application.log
57 mode: a
58 maxBytes: 10000000
59 backupCount: 10
60 formatter: mdcFormatter
61 stdout_handler:
62 class: logging.StreamHandler
63 formatter: mdcFormatter
64formatters:
65 mdcFormatter:
66 format: '%(asctime)s | %(threadName)s | %(thread)d | %(levelname)s | %(module)s
67 | %(funcName)s | %(mdc)s | %(message)s'
68 mdcfmt: '{ServiceName} | {RequestID} | {InvocationID}'
69 datefmt: '%Y-%m-%dT%H:%M:%S%z'
70 (): onaplogging.mdcformatter.MDCFormatter
71EOF"
AndyWalsheb412c7b2020-02-13 15:05:21 +000072
73# Wait for initialization of Docker containers
efiacorb67a0932020-05-22 13:48:52 +010074containers_ok="false"
75for i in {0..5}; do
76 if [[ "$containers_ok" == "true" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000077 then
78 echo "All required docker containers are up."
AndyWalsheb412c7b2020-02-13 15:05:21 +000079 break
80 else
efiacorb67a0932020-05-22 13:48:52 +010081 sleep ${i}
82 fi
83 if [[ $(docker inspect --format '{{ .State.Running }}' cbs-sim) ]] && \
84 [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \
85 [[ $(docker inspect --format '{{ .State.Running }}' mr-sim) ]] && \
86 [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \
87 [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]]
88 then
89 containers_ok="true"
AndyWalsheb412c7b2020-02-13 15:05:21 +000090 fi
91done
efiacorb67a0932020-05-22 13:48:52 +010092[[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1
AndyWalsheb412c7b2020-02-13 15:05:21 +000093
AndyWalshe48496a52020-03-12 12:52:19 +000094DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db)
95MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim)
96CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim)
97
AndyWalsheb412c7b2020-02-13 15:05:21 +000098#Pass any variables required by Robot test suites in ROBOT_VARIABLES
AndyWalshe48496a52020-03-12 12:52:19 +000099ROBOT_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}"