AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 1 | #!/bin/bash |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 2 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 3 | export DB_USER=pmsh |
| 4 | export DB_PASSWORD=pmsh |
| 5 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 6 | TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite |
| 7 | |
efiacor | 6937761 | 2021-07-20 15:53:48 +0100 | [diff] [blame] | 8 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d zookeeper kafka dmaap-mr db aai cbs-sim |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 9 | |
| 10 | # Slow machine running CSITs can affect db coming up in time for PMSH |
| 11 | echo "Waiting for postgres db to come up..." |
| 12 | for i in {1..30}; do |
| 13 | docker exec -i db bash -c "PGPASSWORD=$DB_PASSWORD;psql -U $DB_USER -c '\q'" |
| 14 | db_response=$? |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 15 | if [[ "$db_response" == "0" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 16 | then |
| 17 | break |
| 18 | else |
| 19 | sleep 2 |
| 20 | fi |
| 21 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 22 | [[ "$db_response" != "0" ]] && echo "Error: postgres db not accessible" && exit 1 |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 23 | |
efiacor | 6937761 | 2021-07-20 15:53:48 +0100 | [diff] [blame] | 24 | DMAAP_MR_IP=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" dmaap-mr) |
| 25 | |
| 26 | echo "Waiting for dmaap-message-router to come up ..." |
| 27 | for 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 |
| 35 | done |
| 36 | [[ "$dmaap_state" != "200" ]] && echo "Error: DMaaP MR container state not healthy" && exit 1 |
| 37 | |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 38 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 39 | |
| 40 | PMSH_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 |
| 43 | echo "Waiting for PMSH to come up..." |
| 44 | for i in {1..30}; do |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 45 | pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck) |
| 46 | if [[ "$pmsh_response" == "200" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 47 | then |
| 48 | break |
| 49 | else |
| 50 | sleep 2 |
| 51 | fi |
| 52 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 53 | [[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1 |
| 54 | |
| 55 | # Set log level to DEBUG |
| 56 | docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF |
| 57 | version: 1 |
| 58 | |
| 59 | disable_existing_loggers: true |
| 60 | |
| 61 | loggers: |
| 62 | onap_logger: |
| 63 | level: DEBUG |
| 64 | handlers: [onap_log_handler, stdout_handler] |
| 65 | propagate: false |
| 66 | handlers: |
| 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 |
| 77 | formatters: |
| 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 |
| 84 | EOF" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 85 | |
| 86 | # Wait for initialization of Docker containers |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 87 | containers_ok="false" |
| 88 | for i in {0..5}; do |
| 89 | if [[ "$containers_ok" == "true" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 90 | then |
| 91 | echo "All required docker containers are up." |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 92 | break |
| 93 | else |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 94 | sleep ${i} |
| 95 | fi |
| 96 | if [[ $(docker inspect --format '{{ .State.Running }}' cbs-sim) ]] && \ |
| 97 | [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \ |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 98 | [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \ |
| 99 | [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]] |
| 100 | then |
| 101 | containers_ok="true" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 102 | fi |
| 103 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 104 | [[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1 |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 105 | |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 106 | # Create topics on MR |
| 107 | curl -X POST http://${DMAAP_MR_IP}:3904/events/AAI_EVENT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}' |
| 108 | sleep 2 |
| 109 | curl -X POST http://${DMAAP_MR_IP}:3904/events/unauthenticated.PMSH_CL_INPUT --header 'Content-Type: application/json' --data-raw '{"message": "dummy message"}' |
| 110 | |
| 111 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 112 | DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db) |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 113 | CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim) |
| 114 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 115 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 116 | ROBOT_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}" |