From d97e97cba78f928deda72cb42ca85792b0a91d29 Mon Sep 17 00:00:00 2001 From: Joanna Jeremicz Date: Wed, 1 Sep 2021 16:03:41 +0200 Subject: Use configMap instead of Consul to configure hv-ves Issue-ID: DCAEGEN2-2718 Signed-off-by: Joanna Jeremicz Change-Id: I58a5639e7bc224afb9e30ae4ea97518faa3bd42f --- robot/assets/dcae/hvves_test_config.yaml | 20 +++++++++ robot/resources/dcae/hvves.robot | 70 ++++++++++++++++++++++++++++---- robot/testsuites/hvves-ci.robot | 4 +- robot/testsuites/hvves.robot | 6 +-- 4 files changed, 87 insertions(+), 13 deletions(-) create mode 100644 robot/assets/dcae/hvves_test_config.yaml (limited to 'robot') diff --git a/robot/assets/dcae/hvves_test_config.yaml b/robot/assets/dcae/hvves_test_config.yaml new file mode 100644 index 00000000..8e0733c4 --- /dev/null +++ b/robot/assets/dcae/hvves_test_config.yaml @@ -0,0 +1,20 @@ +data: + application_config.yaml: | + security.sslDisable: false + logLevel: INFO + security.keys.trustStoreFile: /tmp/ca.p12 + server.listenPort: 6061 + server.idleTimeoutSec: 300 + cbs.requestIntervalSec: 5 + streams_publishes: + perf3gpp: + type: kafka + aaf_credentials: + username: admin + password: admin_secret + kafka_info: + bootstrap_servers: message-router-kafka:9092 + topic_name: HV_VES_PERF3GPP_SSL + security.keys.keyStoreFile: /tmp/server.p12 + security.keys.trustStorePasswordFile: /dev/null + security.keys.keyStorePasswordFile: /dev/null diff --git a/robot/resources/dcae/hvves.robot b/robot/resources/dcae/hvves.robot index ac43bae0..e8a0e6e6 100644 --- a/robot/resources/dcae/hvves.robot +++ b/robot/resources/dcae/hvves.robot @@ -8,16 +8,27 @@ Library ONAPLibrary.Utilities Library String Library ONAPLibrary.Kafka Resource ../mr_interface.robot -Resource ../consul_interface.robot *** Variables *** ${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 -${HVVES_CONFIG_SSL} {"security.sslDisable": false, "logLevel": "INFO", "security.keys.trustStoreFile": "/tmp/ca.p12", "server.listenPort": 6061, "server.idleTimeoutSec": 300, "cbs.requestIntervalSec": 5, "streams_publishes": {"perf3gpp": {"type": "kafka", "aaf_credentials": {"username": "admin", "password": "admin_secret"}, "kafka_info": {"bootstrap_servers": "message-router-kafka:9092", "topic_name": "HV_VES_PERF3GPP_SSL"}}}, "security.keys.keyStoreFile": "/tmp/server.p12", "security.keys.trustStorePasswordFile": "/dev/null", "security.keys.keyStorePasswordFile": "/dev/null"} -${HVVES_CONFIG} {"security.sslDisable": false, "logLevel": "INFO", "security.keys.trustStoreFile": "/etc/ves-hv/ssl/trust.jks", "server.listenPort": 6061, "server.idleTimeoutSec": 300, "cbs.requestIntervalSec": 5, "streams_publishes": {"perf3gpp": {"type": "kafka", "aaf_credentials": {"username": "admin", "password": "admin_secret"}, "kafka_info": {"bootstrap_servers": "message-router-kafka:9092", "topic_name": "HV_VES_PERF3GPP"}}}, "security.keys.keyStoreFile": "/etc/ves-hv/ssl/cert.jks", "security.keys.trustStorePasswordFile": "/etc/ves-hv/ssl/trust.pass", "security.keys.keyStorePasswordFile": "/etc/ves-hv/ssl/jks.pass"} ${CA_CERT} /tmp/ca.pem ${CLIENT_CERT} /tmp/client.pem ${CLIENT_KEY} /tmp/client.key +${PREV_CM_FILE} /tmp/prevCm.json +${CURRENT_CONFIG_FILE} /tmp/currentConfig.yaml +${CM_NAME} dev-dcae-hv-ves-collector-application-config-configmap +${GET_PREV_CM} kubectl -n onap get cm ${CM_NAME} -o json + +${TEST_TRUSTSTORE_PASS_PATH} security.keys.trustStorePasswordFile: /dev/null + +${COPY_CURRENT_CONFIG} kubectl -n onap cp $(kubectl get pods -n onap | grep hv-ves | awk '{print $1}' | grep -v NAME):/app-config-input/..data/application_config.yaml ${CURRENT_CONFIG_FILE} +${GET_TRUSTSTORE_PASS_PATH} cat ${CURRENT_CONFIG_FILE} | grep security.keys.trustStorePasswordFile + +${GET_CONFIG_FROM_CM} kubectl -n onap get cm ${CM_NAME} -o jsonpath="{.data.application_config\\.yaml}" +${TEST_CONFIG_YAML_PATH} ${EXECDIR}/robot/assets/dcae/hvves_test_config.yaml + + *** Keywords *** Check Message Router Api [Documentation] Checks message via message router API. @@ -54,9 +65,52 @@ Decode Last Message From Topic ${msg}= Consume kafka ${kafka_topic} [Return] ${msg} -Mode +Set Test Config [Documentation] Changes HV-VES config. - [Arguments] ${config} - ${resp}= Run Consul Put Request /v1/kv/dcae-hv-ves-collector?dc=dc1 ${config} - Should Be Equal As Strings ${resp.status_code} 200 - Sleep 10s + + ${TEST_CONFIG}= Get File ${TEST_CONFIG_YAML_PATH} encoding=UTF-8 + + ${rc} ${prev_conf} = Run and Return RC and Output ${GET_PREV_CM} + Should Be Equal As Integers ${rc} 0 + Create File ${PREV_CM_FILE} ${prev_conf} + + ${rc} ${prev_conf_yaml} = Run and Return RC and Output ${GET_CONFIG_FROM_CM} + Should Be Equal As Integers ${rc} 0 + Set Environment Variable OLD_CONFIG_YAML ${prev_conf_yaml} + + Set Environment Variable TEST_CONFIG ${TEST_CONFIG} + + ${rc} = Run and Return RC kubectl -n onap patch cm ${CM_NAME} --type strategic -p "%{TEST_CONFIG}" + Should Be Equal As Integers ${rc} 0 + + Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${TEST_TRUSTSTORE_PASS_PATH} + Sleep 5s + + +Check If Config Is Applied + [Documentation] Checks if the config is applied. + [Arguments] ${truststore_pass_path} + + ${rc} = Run and Return RC ${COPY_CURRENT_CONFIG} + Should Be Equal As Integers ${rc} 0 + + ${rc} ${current_trust_pass_path} = Run and Return RC and Output ${GET_TRUSTSTORE_PASS_PATH} + Should Be Equal As Integers ${rc} 0 + + Should Be Equal As Strings ${truststore_pass_path} ${current_trust_pass_path} + +Set Old Config + [Documentation] Changes HV-VES config back to normal mode. + + ${rc} = Run and Return RC kubectl -n onap replace --force -f ${PREV_CM_FILE} + Should Be Equal As Integers ${rc} 0 + + ${rc} ${old_trust_pass_path} = Run and Return RC and Output echo "%{OLD_CONFIG_YAML}" | grep security.keys.trustStorePasswordFile + Should Be Equal As Integers ${rc} 0 + + Remove File ${PREV_CM_FILE} + Remove File ${CURRENT_CONFIG_FILE} + + Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${old_trust_pass_path} + + Sleep 10s diff --git a/robot/testsuites/hvves-ci.robot b/robot/testsuites/hvves-ci.robot index ac330901..0e08ff6e 100644 --- a/robot/testsuites/hvves-ci.robot +++ b/robot/testsuites/hvves-ci.robot @@ -14,11 +14,11 @@ ${HVVES_KAFKA_TOPIC_SSL} HV_VES_PERF3GPP_SSL *** Test Cases *** HV-VES SSL test case [Setup] Run Process /app/setup-hvves.sh shell=yes - Mode ${HVVES_CONFIG_SSL} + Set Test Config Send Message Over Ssl ${GLOBAL_DCAE_HVVES_SERVER_NAME} ${GLOBAL_DCAE_HVVES_SERVER_PORT} Wait Until Keyword Succeeds 10s 2s Check If Topic Exists ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_NAME} ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} Check Message Router Api ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_NAME} ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} ${msg}= Decode Last Message From Topic ${GLOBAL_DMAAP_KAFKA_SERVER_NAME} ${GLOBAL_DMAAP_KAFKA_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} ${GLOBAL_DMAAP_KAFKA_JAAS_USERNAME} ${GLOBAL_DMAAP_KAFKA_JAAS_PASSWORD} ${results}= Compare File To Message ${EXECDIR}/robot/assets/dcae/hvves_msg.raw ${msg} Should Be True ${results} - [Teardown] Mode ${HVVES_CONFIG} + [Teardown] Set Old Config diff --git a/robot/testsuites/hvves.robot b/robot/testsuites/hvves.robot index 4bb6d4ac..417454ac 100644 --- a/robot/testsuites/hvves.robot +++ b/robot/testsuites/hvves.robot @@ -1,7 +1,7 @@ *** Settings *** Documentation HV-VES 'Sunny Scenario' Robot Framework test - message is sent to the collector and Kafka topic is checked if the message has been published. Content is decoded and checked. Default Tags hvves ete -Test Timeout 1m +Test Timeout 5m Resource ../resources/global_properties.robot Resource ../resources/dcae/hvves.robot Library OperatingSystem @@ -13,11 +13,11 @@ ${HVVES_KAFKA_TOPIC_SSL} HV_VES_PERF3GPP_SSL *** Test Cases *** HV-VES SSL test case - Mode ${HVVES_CONFIG_SSL} + Set Test Config Send Message Over Ssl ${GLOBAL_DCAE_HVVES_SERVER_NAME} ${GLOBAL_DCAE_HVVES_SERVER_PORT} Wait Until Keyword Succeeds 10s 2s Check If Topic Exists ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_NAME} ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} Check Message Router Api ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_NAME} ${GLOBAL_DMAAP_MESSAGE_ROUTER_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} ${msg}= Decode Last Message From Topic ${GLOBAL_DMAAP_KAFKA_SERVER_NAME} ${GLOBAL_DMAAP_KAFKA_SERVER_PORT} ${HVVES_KAFKA_TOPIC_SSL} ${GLOBAL_DMAAP_KAFKA_JAAS_USERNAME} ${GLOBAL_DMAAP_KAFKA_JAAS_PASSWORD} ${results}= Compare File To Message ${EXECDIR}/robot/assets/dcae/hvves_msg.raw ${msg} Should Be True ${results} - [Teardown] Mode ${HVVES_CONFIG} + [Teardown] Set Old Config -- cgit 1.2.3-korg