blob: d96b62a136bb4ec383d6c5b71fc97fab3d887faa [file] [log] [blame]
AndyWalsheb412c7b2020-02-13 15:05:21 +00001#!/bin/bash
efiacor830e11d2021-01-29 14:28:34 +00002
AndyWalsheb412c7b2020-02-13 15:05:21 +00003export DB_USER=pmsh
4export DB_PASSWORD=pmsh
5
AndyWalsheb412c7b2020-02-13 15:05:21 +00006TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite
7
SagarS807c7cd2022-03-09 15:51:04 +00008docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d db aai mr-sim
AndyWalsheb412c7b2020-02-13 15:05:21 +00009
10# Slow machine running CSITs can affect db coming up in time for PMSH
11echo "Waiting for postgres db to come up..."
12for i in {1..30}; do
13 docker exec -i db bash -c "PGPASSWORD=$DB_PASSWORD;psql -U $DB_USER -c '\q'"
14 db_response=$?
efiacorb67a0932020-05-22 13:48:52 +010015 if [[ "$db_response" == "0" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000016 then
17 break
18 else
19 sleep 2
20 fi
21done
efiacorb67a0932020-05-22 13:48:52 +010022[[ "$db_response" != "0" ]] && echo "Error: postgres db not accessible" && exit 1
AndyWalsheb412c7b2020-02-13 15:05:21 +000023
efiacorb67a0932020-05-22 13:48:52 +010024docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh
AndyWalsheb412c7b2020-02-13 15:05:21 +000025
26PMSH_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" pmsh)
27
28# Slow machine running CSITs can affect PMSH coming up before CSITs are run
29echo "Waiting for PMSH to come up..."
30for i in {1..30}; do
efiacorb67a0932020-05-22 13:48:52 +010031 pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck)
32 if [[ "$pmsh_response" == "200" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000033 then
34 break
35 else
36 sleep 2
37 fi
38done
efiacorb67a0932020-05-22 13:48:52 +010039[[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1
40
41# Set log level to DEBUG
42docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF
43version: 1
44
45disable_existing_loggers: true
46
47loggers:
48 onap_logger:
49 level: DEBUG
50 handlers: [onap_log_handler, stdout_handler]
51 propagate: false
52handlers:
53 onap_log_handler:
54 class: logging.handlers.RotatingFileHandler
55 filename: /var/log/ONAP/dcaegen2/services/pmsh/application.log
56 mode: a
57 maxBytes: 10000000
58 backupCount: 10
59 formatter: mdcFormatter
60 stdout_handler:
61 class: logging.StreamHandler
62 formatter: mdcFormatter
63formatters:
64 mdcFormatter:
65 format: '%(asctime)s | %(threadName)s | %(thread)d | %(levelname)s | %(module)s
66 | %(funcName)s | %(mdc)s | %(message)s'
67 mdcfmt: '{ServiceName} | {RequestID} | {InvocationID}'
68 datefmt: '%Y-%m-%dT%H:%M:%S%z'
69 (): onaplogging.mdcformatter.MDCFormatter
70EOF"
AndyWalsheb412c7b2020-02-13 15:05:21 +000071
72# Wait for initialization of Docker containers
efiacorb67a0932020-05-22 13:48:52 +010073containers_ok="false"
74for i in {0..5}; do
75 if [[ "$containers_ok" == "true" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000076 then
77 echo "All required docker containers are up."
AndyWalsheb412c7b2020-02-13 15:05:21 +000078 break
79 else
efiacorb67a0932020-05-22 13:48:52 +010080 sleep ${i}
81 fi
SagarS807c7cd2022-03-09 15:51:04 +000082 if [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \
efiacor5e83a4b2022-02-28 17:27:23 +000083 [[ $(docker inspect --format '{{ .State.Running }}' mr-sim) ]] && \
efiacorb67a0932020-05-22 13:48:52 +010084 [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \
85 [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]]
86 then
87 containers_ok="true"
AndyWalsheb412c7b2020-02-13 15:05:21 +000088 fi
89done
efiacorb67a0932020-05-22 13:48:52 +010090[[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1
AndyWalsheb412c7b2020-02-13 15:05:21 +000091
AndyWalshe48496a52020-03-12 12:52:19 +000092DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db)
efiacor5e83a4b2022-02-28 17:27:23 +000093MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim)
AndyWalshe48496a52020-03-12 12:52:19 +000094
AndyWalsheb412c7b2020-02-13 15:05:21 +000095#Pass any variables required by Robot test suites in ROBOT_VARIABLES
SagarS807c7cd2022-03-09 15:51:04 +000096ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP} -v MR_SIM_IP_ADDRESS:${MR_SIM_IP_ADDRESS} -v DB_IP_ADDRESS:${DB_IP_ADDRESS}"