AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Place the scripts in run order: |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 3 | |
| 4 | export DB_USER=pmsh |
| 5 | export DB_PASSWORD=pmsh |
| 6 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 7 | TEST_PLANS_DIR=$WORKSPACE/plans/dcaegen2-services-pmsh/testsuite |
| 8 | |
efiacor | 49b4644 | 2020-07-06 11:55:44 +0100 | [diff] [blame] | 9 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d db aai cbs-sim mr-sim |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 10 | |
| 11 | # Slow machine running CSITs can affect db coming up in time for PMSH |
| 12 | echo "Waiting for postgres db to come up..." |
| 13 | for i in {1..30}; do |
| 14 | docker exec -i db bash -c "PGPASSWORD=$DB_PASSWORD;psql -U $DB_USER -c '\q'" |
| 15 | db_response=$? |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 16 | if [[ "$db_response" == "0" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 17 | then |
| 18 | break |
| 19 | else |
| 20 | sleep 2 |
| 21 | fi |
| 22 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 23 | [[ "$db_response" != "0" ]] && echo "Error: postgres db not accessible" && exit 1 |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 24 | |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 25 | docker-compose -f ${TEST_PLANS_DIR}/docker-compose.yml up -d pmsh |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 26 | |
| 27 | PMSH_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 |
| 30 | echo "Waiting for PMSH to come up..." |
| 31 | for i in {1..30}; do |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 32 | pmsh_response=$(curl -k -s -o /dev/null -w "%{http_code}" https://${PMSH_IP}:8443/healthcheck) |
| 33 | if [[ "$pmsh_response" == "200" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 34 | then |
| 35 | break |
| 36 | else |
| 37 | sleep 2 |
| 38 | fi |
| 39 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 40 | [[ "$pmsh_response" != "200" ]] && echo "Error: PMSH container state not healthy" && exit 1 |
| 41 | |
| 42 | # Set log level to DEBUG |
| 43 | docker exec pmsh /bin/sh -c "cat > log_config.yaml <<EOF |
| 44 | version: 1 |
| 45 | |
| 46 | disable_existing_loggers: true |
| 47 | |
| 48 | loggers: |
| 49 | onap_logger: |
| 50 | level: DEBUG |
| 51 | handlers: [onap_log_handler, stdout_handler] |
| 52 | propagate: false |
| 53 | handlers: |
| 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 |
| 64 | formatters: |
| 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 |
| 71 | EOF" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 72 | |
| 73 | # Wait for initialization of Docker containers |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 74 | containers_ok="false" |
| 75 | for i in {0..5}; do |
| 76 | if [[ "$containers_ok" == "true" ]] |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 77 | then |
| 78 | echo "All required docker containers are up." |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 79 | break |
| 80 | else |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 81 | 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" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 90 | fi |
| 91 | done |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 92 | [[ "$containers_ok" == "false" ]] && echo "Error: required container not running." && exit 1 |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 93 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 94 | DB_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" db) |
| 95 | MR_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mr-sim) |
| 96 | CBS_SIM_IP_ADDRESS=$(docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" cbs-sim) |
| 97 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 98 | #Pass any variables required by Robot test suites in ROBOT_VARIABLES |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 99 | ROBOT_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}" |