blob: 73a219f7c3dbc27d364a95da4dcfda77b6c6bb25 [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
efiacor69377612021-07-20 15:53:48 +01008docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d zookeeper kafka dmaap-mr db aai cbs-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
efiacor69377612021-07-20 15:53:48 +010024DMAAP_MR_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" dmaap-mr)
25
26echo "Waiting for dmaap-message-router to come up ..."
27for i in {1..20}; do
28 dmaap_state=$(curl --write-out '%{http_code}' --silent --output /dev/null $DMAAP_MR_IP:3904/topics)
29 if [[ ${dmaap_state} == "200" ]]
30 then
31 break
32 else
33 sleep 5
34 fi
35done
36[[ "$dmaap_state" != "200" ]] && echo "Error: DMaaP MR container state not healthy" && exit 1
37
efiacorb67a0932020-05-22 13:48:52 +010038docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh
AndyWalsheb412c7b2020-02-13 15:05:21 +000039
40PMSH_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" pmsh)
41
42# Slow machine running CSITs can affect PMSH coming up before CSITs are run
43echo "Waiting for PMSH to come up..."
44for i in {1..30}; do
efiacorb67a0932020-05-22 13:48:52 +010045 pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck)
46 if [[ "$pmsh_response" == "200" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000047 then
48 break
49 else
50 sleep 2
51 fi
52done
efiacorb67a0932020-05-22 13:48:52 +010053[[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1
54
55# Set log level to DEBUG
56docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF
57version: 1
58
59disable_existing_loggers: true
60
61loggers:
62 onap_logger:
63 level: DEBUG
64 handlers: [onap_log_handler, stdout_handler]
65 propagate: false
66handlers:
67 onap_log_handler:
68 class: logging.handlers.RotatingFileHandler
69 filename: /var/log/ONAP/dcaegen2/services/pmsh/application.log
70 mode: a
71 maxBytes: 10000000
72 backupCount: 10
73 formatter: mdcFormatter
74 stdout_handler:
75 class: logging.StreamHandler
76 formatter: mdcFormatter
77formatters:
78 mdcFormatter:
79 format: '%(asctime)s | %(threadName)s | %(thread)d | %(levelname)s | %(module)s
80 | %(funcName)s | %(mdc)s | %(message)s'
81 mdcfmt: '{ServiceName} | {RequestID} | {InvocationID}'
82 datefmt: '%Y-%m-%dT%H:%M:%S%z'
83 (): onaplogging.mdcformatter.MDCFormatter
84EOF"
AndyWalsheb412c7b2020-02-13 15:05:21 +000085
86# Wait for initialization of Docker containers
efiacorb67a0932020-05-22 13:48:52 +010087containers_ok="false"
88for i in {0..5}; do
89 if [[ "$containers_ok" == "true" ]]
AndyWalsheb412c7b2020-02-13 15:05:21 +000090 then
91 echo "All required docker containers are up."
AndyWalsheb412c7b2020-02-13 15:05:21 +000092 break
93 else
efiacorb67a0932020-05-22 13:48:52 +010094 sleep ${i}
95 fi
96 if [[ $(docker inspect --format '{{ .State.Running }}' cbs-sim) ]] && \
97 [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \
efiacorb67a0932020-05-22 13:48:52 +010098 [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \
99 [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]]
100 then
101 containers_ok="true"
AndyWalsheb412c7b2020-02-13 15:05:21 +0000102 fi
103done
efiacorb67a0932020-05-22 13:48:52 +0100104[[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1
AndyWalsheb412c7b2020-02-13 15:05:21 +0000105
efiacor830e11d2021-01-29 14:28:34 +0000106# Create topics on MR
107curl -X POST http://${DMAAP_MR_IP}:3904/events/AAI_EVENT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}'
108sleep 2
109curl -X POST http://${DMAAP_MR_IP}:3904/events/unauthenticated.PMSH_CL_INPUT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}'
110
111
AndyWalshe48496a52020-03-12 12:52:19 +0000112DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db)
AndyWalshe48496a52020-03-12 12:52:19 +0000113CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim)
114
AndyWalsheb412c7b2020-02-13 15:05:21 +0000115#Pass any variables required by Robot test suites in ROBOT_VARIABLES
efiacor830e11d2021-01-29 14:28:34 +0000116ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP} -v MR_IP_ADDRESS:${DMAAP_MR_IP} -v DB_IP_ADDRESS:${DB_IP_ADDRESS} -v CBS_SIM_IP_ADDRESS:${CBS_SIM_IP_ADDRESS}"