2 Documentation Template contains stuff for HV-VES use case.
3 Library OperatingSystem
4 Library RequestsLibrary
7 Library ONAPLibrary.Utilities
9 Library ONAPLibrary.Kafka
10 Resource ../mr_interface.robot
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
14 ${CA_CERT} /tmp/ca.pem
15 ${CLIENT_CERT} /tmp/client.pem
16 ${CLIENT_KEY} /tmp/client.key
18 ${PREV_CM_FILE} /tmp/prevCm.json
19 ${CURRENT_CONFIG_FILE} /tmp/currentConfig.yaml
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}
21 ${GET_PREFIX} echo "%{HOSTNAME}" | awk -F- '{print $1}'
22 ${NO_PREFIX_CM_NAME} -dcae-hv-ves-collector-application-config-configmap
23 ${GET_TRUSTSTORE_PASS_PATH} cat ${CURRENT_CONFIG_FILE} | grep security.keys.trustStorePasswordFile
24 ${TEST_TRUSTSTORE_PASS_PATH} security.keys.trustStorePasswordFile: /dev/null
25 ${TEST_CONFIG_YAML_PATH} ${EXECDIR}/robot/assets/dcae/hvves_test_config.yaml
29 Check Message Router Api
30 [Documentation] Checks message via message router API.
31 [Arguments] ${message_router} ${message_router_port} ${topic}
32 ${session}= Create Session session http://${message_router}:${message_router_port}/events
33 ${resp}= Get Request session /${topic}/1/1
34 Run Keyword If 400 <= ${resp.status_code} < 500 Log Topic ${topic} does not exist.
35 Run Keyword If 200 <= ${resp.status_code} < 300 Log Topic ${topic} exists.
38 [Documentation] Checks if specific topic exists on kafka.
39 [Arguments] ${message_router} ${message_router_port} ${topic}
40 ${session}= Create Session session http://${message_router}:${message_router_port}/topics
41 ${resp}= Get Request session /
42 ${value}= Catenate ${resp.json()['topics']}
43 Should Contain ${value} ${topic}
46 [Documentation] Sends message to HV-VES over TCP.
47 [Arguments] ${hvves_server_ip} ${hvves_server_port}
48 ${msg}= Convert To Bytes ${HVVES_MESSAGE}
49 Send Binary Data ${hvves_server_ip} ${hvves_server_port} ${msg}
52 [Documentation] Sends message to HV-VES over TCP wih SSL enabled.
53 [Arguments] ${hvves_server_ip} ${hvves_server_port}
54 ${msg}= Convert To Bytes ${HVVES_MESSAGE}
55 Send Binary Data ${hvves_server_ip} ${hvves_server_port} ${msg} ${TRUE} ${TRUE} ${CA_CERT} ${CLIENT_CERT} ${CLIENT_KEY}
57 Decode Last Message From Topic
58 [Documentation] Decode last message from Kafka topic.
59 [Arguments] ${kafka_server} ${kafka_port} ${kafka_topic} ${username} ${password}
60 Connect kafka ${kafka_server}:${kafka_port} ${username} ${password}
61 ${msg}= Consume kafka ${kafka_topic}
65 [Documentation] Changes HV-VES config.
67 ${TEST_CONFIG}= Get File ${TEST_CONFIG_YAML_PATH} encoding=UTF-8
69 Save Configuration From Config Map
70 Set Environment Variable TEST_CONFIG ${TEST_CONFIG}
72 ${cm_name} = Get Config Map Name
73 ${rc} = Run and Return RC kubectl -n onap patch cm ${cm_name} --type strategic -p "%{TEST_CONFIG}"
74 Should Be Equal As Integers ${rc} 0
76 Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${TEST_TRUSTSTORE_PASS_PATH}
80 Check If Config Is Applied
81 [Documentation] Checks if the config is applied.
82 [Arguments] ${truststore_pass_path}
84 ${rc} = Run and Return RC ${COPY_CURRENT_CONFIG}
85 Should Be Equal As Integers ${rc} 0
87 ${rc} ${current_trust_pass_path} = Run and Return RC and Output ${GET_TRUSTSTORE_PASS_PATH}
88 Should Be Equal As Integers ${rc} 0
90 Should Be Equal As Strings ${truststore_pass_path} ${current_trust_pass_path}
92 Save Configuration From Config Map
93 [Documentation] Saves current configuration from hv-ves config map in OLD_CONFIG_YAML env
95 ${cm_name} = Get Config Map Name
96 ${rc} ${prev_conf} = Run and Return RC and Output kubectl -n onap get cm ${cm_name} -o json
97 Should Be Equal As Integers ${rc} 0
98 Create File ${PREV_CM_FILE} ${prev_conf}
100 ${rc} ${prev_conf_yaml} = Run and Return RC and Output kubectl -n onap get cm ${cm_name} -o jsonpath="{.data.application_config\\.yaml}"
101 Should Be Equal As Integers ${rc} 0
102 Set Environment Variable OLD_CONFIG_YAML ${prev_conf_yaml}
105 [Documentation] Retrieves HV-VES Config Map name
107 ${rc} ${cm_prefix} = Run and Return RC and Output ${GET_PREFIX}
108 Should Be Equal As Integers ${rc} 0
109 ${cm_name} = Catenate SEPARATOR= ${cm_prefix} ${NO_PREFIX_CM_NAME}
113 [Documentation] Changes HV-VES config back to normal mode.
115 ${rc} = Run and Return RC kubectl -n onap replace --force -f ${PREV_CM_FILE}
116 Should Be Equal As Integers ${rc} 0
118 ${rc} ${old_trust_pass_path} = Run and Return RC and Output echo "%{OLD_CONFIG_YAML}" | grep security.keys.trustStorePasswordFile
119 Should Be Equal As Integers ${rc} 0
121 Remove File ${PREV_CM_FILE}
122 Remove File ${CURRENT_CONFIG_FILE}
124 Wait Until Keyword Succeeds 2 min 5 sec Check If Config Is Applied ${old_trust_pass_path}