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 | |
SagarS | 807c7cd | 2022-03-09 15:51:04 +0000 | [diff] [blame^] | 8 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d db aai mr-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 | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 24 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 25 | |
| 26 | PMSH_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 |
| 29 | echo "Waiting for PMSH to come up..." |
| 30 | for i in {1..30}; do |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 31 | pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck) |
| 32 | if [[ "$pmsh_response" == "200" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 33 | then |
| 34 | break |
| 35 | else |
| 36 | sleep 2 |
| 37 | fi |
| 38 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 39 | [[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1 |
| 40 | |
| 41 | # Set log level to DEBUG |
| 42 | docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF |
| 43 | version: 1 |
| 44 | |
| 45 | disable_existing_loggers: true |
| 46 | |
| 47 | loggers: |
| 48 | onap_logger: |
| 49 | level: DEBUG |
| 50 | handlers: [onap_log_handler, stdout_handler] |
| 51 | propagate: false |
| 52 | handlers: |
| 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 |
| 63 | formatters: |
| 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 |
| 70 | EOF" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 71 | |
| 72 | # Wait for initialization of Docker containers |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 73 | containers_ok="false" |
| 74 | for i in {0..5}; do |
| 75 | if [[ "$containers_ok" == "true" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 76 | then |
| 77 | echo "All required docker containers are up." |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 78 | break |
| 79 | else |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 80 | sleep ${i} |
| 81 | fi |
SagarS | 807c7cd | 2022-03-09 15:51:04 +0000 | [diff] [blame^] | 82 | if [[ $(docker inspect --format '{{ .State.Running }}' aai-sim) ]] && \ |
efiacor | 5e83a4b | 2022-02-28 17:27:23 +0000 | [diff] [blame] | 83 | [[ $(docker inspect --format '{{ .State.Running }}' mr-sim) ]] && \ |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 84 | [[ $(docker inspect --format '{{ .State.Running }}' db) ]] && \ |
| 85 | [[ $(docker inspect --format '{{ .State.Running }}' pmsh) ]] |
| 86 | then |
| 87 | containers_ok="true" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 88 | fi |
| 89 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 90 | [[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1 |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 91 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 92 | DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db) |
efiacor | 5e83a4b | 2022-02-28 17:27:23 +0000 | [diff] [blame] | 93 | MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim) |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 94 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 95 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
SagarS | 807c7cd | 2022-03-09 15:51:04 +0000 | [diff] [blame^] | 96 | ROBOT_VARIABLES="-v PMSH_IP:${PMSH_IP} -v MR_SIM_IP_ADDRESS:${MR_SIM_IP_ADDRESS} -v DB_IP_ADDRESS:${DB_IP_ADDRESS}" |