marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 1 | *** Settings *** |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 2 | Documentation Template contains stuff for HV-VES use case. |
| 3 | Library OperatingSystem |
| 4 | Library RequestsLibrary |
| 5 | Library BuiltIn |
| 6 | Library Collections |
| 7 | Library ONAPLibrary.Utilities |
DR695H | 2742633 | 2019-05-21 11:26:28 -0400 | [diff] [blame] | 8 | Library String |
DR695H | 02293ad | 2019-06-13 17:24:01 -0400 | [diff] [blame] | 9 | Library ONAPLibrary.Kafka |
DR695H | 2742633 | 2019-05-21 11:26:28 -0400 | [diff] [blame] | 10 | Resource ../mr_interface.robot |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 11 | |
| 12 | *** Variables *** |
DR695H | 9d810d0 | 2019-06-18 17:16:25 -0400 | [diff] [blame] | 13 | ${HVVES_MESSAGE} \xaa\x01\x00\x00\x00\x00\x00\x01\x00\x00\x01'\n\x94\x02\n\x0esample-version\x12\x08perf3gpp\x18\x01 \x01*\nperf3GPP222\x11sample-event-name:\x11sample-event-type@\xf1\x9a\xfd\xdd\x05H\xf1\x9a\xfd\xdd\x05R\x15sample-nf-naming-codeZ\x16sample-nfc-naming-codeb\x15sample-nf-vendor-namej\x1asample-reporting-entity-idr\x1csample-reporting-entity-namez\x10sample-source-id\x82\x01\x0fsample-xnf-name\x8a\x01\tUTC+02:00\x92\x01\x057.0.2\x12\x0etest test test |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 14 | ${CA_CERT} /tmp/ca.pem |
| 15 | ${CLIENT_CERT} /tmp/client.pem |
| 16 | ${CLIENT_KEY} /tmp/client.key |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 17 | |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 18 | ${PREV_CM_FILE} /tmp/prevCm.json |
Krzysztof Kuzmicki | 359e363 | 2022-05-05 12:10:40 +0200 | [diff] [blame] | 19 | ${CURRENT_CONFIG_FILE} /tmp/xz.yaml |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 20 | ${COPY_CURRENT_CONFIG} kubectl -n onap cp $(kubectl -n onap get --no-headers pods -l app.kubernetes.io/name=dcae-hv-ves-collector --field-selector status.phase=Running -o custom-columns=NAME:.metadata.name):/app-config-input/..data/application_config.yaml ${CURRENT_CONFIG_FILE} |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 21 | ${GET_TRUSTSTORE_PASS_PATH} cat ${CURRENT_CONFIG_FILE} | grep security.keys.trustStorePasswordFile |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 22 | ${TEST_TRUSTSTORE_PASS_PATH} security.keys.trustStorePasswordFile: /dev/null |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 23 | ${TEST_CONFIG_YAML_PATH} ${EXECDIR}/robot/assets/dcae/hvves_test_config.yaml |
Joanna Jeremicz | 109764d | 2021-09-13 08:03:43 +0200 | [diff] [blame] | 24 | ${GET_CM_NAME} kubectl -n onap get --no-headers cm -l app.kubernetes.io/name=dcae-hv-ves-collector -o custom-columns=NAME:.metadata.name | grep application-config-configmap |
Krzysztof Kuzmicki | 359e363 | 2022-05-05 12:10:40 +0200 | [diff] [blame] | 25 | ${KAFKA_GET_PASSWORD} kubectl -n onap get secret strimzi-kafka-admin -o jsonpath="{.data.password}" | base64 --decode |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 26 | |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 27 | *** Keywords *** |
marekpl | f989890 | 2019-05-14 15:14:51 +0200 | [diff] [blame] | 28 | Check Message Router Api |
marekpl | 615214f | 2019-05-07 17:03:56 +0200 | [diff] [blame] | 29 | [Documentation] Checks message via message router API. |
marekpl | f989890 | 2019-05-14 15:14:51 +0200 | [diff] [blame] | 30 | [Arguments] ${message_router} ${message_router_port} ${topic} |
DR695H | 0ca56d1 | 2019-05-14 11:48:20 -0400 | [diff] [blame] | 31 | ${session}= Create Session session http://${message_router}:${message_router_port}/events |
| 32 | ${resp}= Get Request session /${topic}/1/1 |
| 33 | Run Keyword If 400 <= ${resp.status_code} < 500 Log Topic ${topic} does not exist. |
| 34 | Run Keyword If 200 <= ${resp.status_code} < 300 Log Topic ${topic} exists. |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 35 | |
marekpl | 62c91a9 | 2018-10-29 12:13:58 +0100 | [diff] [blame] | 36 | Check If Topic Exists |
| 37 | [Documentation] Checks if specific topic exists on kafka. |
marekpl | 615214f | 2019-05-07 17:03:56 +0200 | [diff] [blame] | 38 | [Arguments] ${message_router} ${message_router_port} ${topic} |
DR695H | 0ca56d1 | 2019-05-14 11:48:20 -0400 | [diff] [blame] | 39 | ${session}= Create Session session http://${message_router}:${message_router_port}/topics |
| 40 | ${resp}= Get Request session / |
mrichomme | 3256fa2 | 2020-03-09 11:23:35 +0100 | [diff] [blame] | 41 | ${value}= Catenate ${resp.json()['topics']} |
marekpl | 615214f | 2019-05-07 17:03:56 +0200 | [diff] [blame] | 42 | Should Contain ${value} ${topic} |
marekpl | 62c91a9 | 2018-10-29 12:13:58 +0100 | [diff] [blame] | 43 | |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 44 | Send Message |
| 45 | [Documentation] Sends message to HV-VES over TCP. |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 46 | [Arguments] ${hvves_server_ip} ${hvves_server_port} |
marekpl | fe13125 | 2019-07-22 17:06:35 +0200 | [diff] [blame] | 47 | ${msg}= Convert To Bytes ${HVVES_MESSAGE} |
Krzysztof Kuzmicki | 55d91bc | 2022-03-17 15:00:46 +0100 | [diff] [blame] | 48 | Wait Until Keyword Succeeds 300 sec 15 sec Send Binary Data ${hvves_server_ip} ${hvves_server_port} ${msg} |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 49 | |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 50 | Send Message Over Ssl |
| 51 | [Documentation] Sends message to HV-VES over TCP wih SSL enabled. |
| 52 | [Arguments] ${hvves_server_ip} ${hvves_server_port} |
| 53 | ${msg}= Convert To Bytes ${HVVES_MESSAGE} |
Krzysztof Kuzmicki | 55d91bc | 2022-03-17 15:00:46 +0100 | [diff] [blame] | 54 | Wait Until Keyword Succeeds 300 sec 15 sec Send Binary Data ${hvves_server_ip} ${hvves_server_port} ${msg} ${TRUE} ${TRUE} ${CA_CERT} ${CLIENT_CERT} ${CLIENT_KEY} |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 55 | |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 56 | Decode Last Message From Topic |
| 57 | [Documentation] Decode last message from Kafka topic. |
DR695H | 9d810d0 | 2019-06-18 17:16:25 -0400 | [diff] [blame] | 58 | [Arguments] ${kafka_server} ${kafka_port} ${kafka_topic} ${username} ${password} |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 59 | Connect kafka ${kafka_server}:${kafka_port} ${username} ${password} |
| 60 | ${msg}= Consume kafka ${kafka_topic} |
marekpl | 503647c | 2018-10-24 14:33:25 +0200 | [diff] [blame] | 61 | [Return] ${msg} |
| 62 | |
Krzysztof Kuzmicki | 359e363 | 2022-05-05 12:10:40 +0200 | [diff] [blame] | 63 | Decode Last Message From Topic STRIMZI User |
| 64 | [Documentation] Decode last message from Kafka topic using STRIMZI User. |
| 65 | [Arguments] ${kafka_server} ${kafka_topic} ${username} |
| 66 | ${command_output} = Run And Return Rc And Output ${KAFKA_GET_PASSWORD} |
| 67 | Should Be Equal As Integers ${command_output[0]} 0 |
| 68 | ${password} Set Variable ${command_output[1]} |
| 69 | Connect kafka ${kafka_server} ${username} ${password} SCRAM-SHA-512 |
| 70 | ${msg}= Consume kafka ${kafka_topic} |
| 71 | [Return] ${msg} |
| 72 | |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 73 | Set Test Config |
marekpl | c78a7e4 | 2019-08-06 18:08:00 +0200 | [diff] [blame] | 74 | [Documentation] Changes HV-VES config. |
Krzysztof Kuzmicki | 5eb7323 | 2022-05-06 14:07:52 +0200 | [diff] [blame] | 75 | [Arguments] ${kafka_server} |
| 76 | ${SED}= Set Variable sed -i 's/placeholder/${kafka_server}/g' ${TEST_CONFIG_YAML_PATH} |
| 77 | Run ${SED} |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 78 | ${TEST_CONFIG}= Get File ${TEST_CONFIG_YAML_PATH} encoding=UTF-8 |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 79 | Save Configuration From Config Map |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 80 | Set Environment Variable TEST_CONFIG ${TEST_CONFIG} |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 81 | ${cm_name} = Get Config Map Name |
| 82 | ${rc} = Run and Return RC kubectl -n onap patch cm ${cm_name} --type strategic -p "%{TEST_CONFIG}" |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 83 | Should Be Equal As Integers ${rc} 0 |
| 84 | |
| 85 | Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${TEST_TRUSTSTORE_PASS_PATH} |
| 86 | Sleep 5s |
| 87 | |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 88 | Check If Config Is Applied |
| 89 | [Documentation] Checks if the config is applied. |
| 90 | [Arguments] ${truststore_pass_path} |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 91 | ${rc} = Run and Return RC ${COPY_CURRENT_CONFIG} |
| 92 | Should Be Equal As Integers ${rc} 0 |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 93 | ${rc} ${current_trust_pass_path} = Run and Return RC and Output ${GET_TRUSTSTORE_PASS_PATH} |
| 94 | Should Be Equal As Integers ${rc} 0 |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 95 | Should Be Equal As Strings ${truststore_pass_path} ${current_trust_pass_path} |
| 96 | |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 97 | Save Configuration From Config Map |
| 98 | [Documentation] Saves current configuration from hv-ves config map in OLD_CONFIG_YAML env |
| 99 | |
| 100 | ${cm_name} = Get Config Map Name |
| 101 | ${rc} ${prev_conf} = Run and Return RC and Output kubectl -n onap get cm ${cm_name} -o json |
| 102 | Should Be Equal As Integers ${rc} 0 |
| 103 | Create File ${PREV_CM_FILE} ${prev_conf} |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 104 | ${rc} ${prev_conf_yaml} = Run and Return RC and Output kubectl -n onap get cm ${cm_name} -o jsonpath="{.data.application_config\\.yaml}" |
| 105 | Should Be Equal As Integers ${rc} 0 |
| 106 | Set Environment Variable OLD_CONFIG_YAML ${prev_conf_yaml} |
| 107 | |
| 108 | Get Config Map Name |
| 109 | [Documentation] Retrieves HV-VES Config Map name |
| 110 | |
Joanna Jeremicz | 109764d | 2021-09-13 08:03:43 +0200 | [diff] [blame] | 111 | ${rc} ${cm_name} = Run and Return RC and Output ${GET_CM_NAME} |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 112 | Should Be Equal As Integers ${rc} 0 |
Joanna Jeremicz | 9ffedfe | 2021-09-07 12:53:46 +0200 | [diff] [blame] | 113 | [Return] ${cm_name} |
| 114 | |
Joanna Jeremicz | d97e97c | 2021-09-01 16:03:41 +0200 | [diff] [blame] | 115 | Set Old Config |
| 116 | [Documentation] Changes HV-VES config back to normal mode. |
| 117 | |
| 118 | ${rc} = Run and Return RC kubectl -n onap replace --force -f ${PREV_CM_FILE} |
| 119 | Should Be Equal As Integers ${rc} 0 |
| 120 | |
| 121 | ${rc} ${old_trust_pass_path} = Run and Return RC and Output echo "%{OLD_CONFIG_YAML}" | grep security.keys.trustStorePasswordFile |
| 122 | Should Be Equal As Integers ${rc} 0 |
| 123 | |
| 124 | Remove File ${PREV_CM_FILE} |
| 125 | Remove File ${CURRENT_CONFIG_FILE} |
| 126 | |
| 127 | Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${old_trust_pass_path} |
| 128 | |
| 129 | Sleep 10s |