2 Documentation Testing PMSH functionality
4 Library OperatingSystem
5 Library RequestsLibrary
9 Resource ../../common.robot
11 Test Setup CreateSessions
12 Test Teardown Delete All Sessions
17 ${PMSH_BASE_URL} https://${PMSH_IP}:8443
18 ${MR_BASE_URL} http://${MR_IP_ADDRESS}:3904
19 ${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443
20 ${SUBSCRIPTIONS_ENDPOINT} /subscriptions
21 ${POLICY_PUBLISH_MR_TOPIC} /events/unauthenticated.PMSH_CL_INPUT
22 ${AAI_MR_TOPIC} /events/AAI_EVENT
24 ${MR_AAI_PNF_CREATED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/aai-pnf-create.json
25 ${MR_AAI_PNF_REMOVED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/aai-pnf-delete.json
26 ${MR_POLICY_RESPONSE_PNF_EXISTING} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/policy-sub-created-pnf-existing.json
27 ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json
29 ${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
30 ${CLI_EXEC_GET_CBS_CONFIG_FIRST} docker exec pmsh /bin/sh -c "grep -m 1 'PMSH config from CBS' /var/log/ONAP/dcaegen2/services/pmsh/application.log"
34 Verify Administrative State in PMSH log file is LOCKED
36 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
38 Sleep 3 Allow time for PMSH to flush to logs
39 ${cli_cmd_output}= Run Process ${CLI_EXEC_GET_CBS_CONFIG_FIRST} shell=yes
40 Should Be True ${cli_cmd_output.rc} == 0
41 Should Contain ${cli_cmd_output.stdout} ${ADMIN_STATE_LOCKED_PATTERN}
43 Verify database tables exist and are empty
45 [Documentation] Verify database has been created and is empty
47 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
48 Should Be True ${resp.status_code} == 200
49 Should Contain ${resp.text} []
51 Verify PNF detected in AAI when administrative state unlocked
53 [Documentation] Verify PNF detected when administrative state unlocked
55 SetAdministrativeStateToUnlocked
56 Sleep 31 Allow PMSH time to pick up changes in CBS config
57 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
58 Should Be Equal As Strings ${resp.json()[0]['subscription_status']} UNLOCKED
59 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_name']} pnf-existing
60 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} PENDING_CREATE
62 Verify Policy response on MR is handled
64 [Documentation] Verify policy response on MR is handled
66 SimulatePolicyResponse ${MR_POLICY_RESPONSE_PNF_EXISTING}
67 Sleep 31 seconds Ensure Policy response on MR is picked up
68 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
69 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED
71 Verify AAI event on MR detailing new PNF being detected is handled
73 [Documentation] Verify PNF created AAI event on MR is handled
75 SimulateNewPNF ${MR_AAI_PNF_CREATED}
76 Sleep 31 seconds Ensure AAI event on MR is picked up
77 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
78 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered
79 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE
81 Verify AAI event on MR detailing PNF being deleted is handled
83 [Documentation] Verify PNF deleted AAI event on MR is handled
85 SimulateDeletedPNF ${MR_AAI_PNF_REMOVED}
86 Sleep 31 seconds Ensure AAI event on MR is picked up
87 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
88 Should Not Contain ${resp.text} pnf_newly_discovered
93 Create Session pmsh_session ${PMSH_BASE_URL}
94 Create Session mr_sim_session ${MR_BASE_URL}
95 Create Session cbs_sim_session ${CBS_BASE_URL}
97 SetAdministrativeStateToUnlocked
98 ${data}= Get Data From File ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED}
99 ${resp} = Put Request cbs_sim_session /clear data={"path": "/service_component_all/.*"}
100 Should Be True ${resp.status_code} == 200
101 Sleep 2 Allow CBS time to set expectation
102 ${resp} = Put Request cbs_sim_session /expectation data=${data}
103 Should Be True ${resp.status_code} == 201
106 SimulatePolicyResponse
107 [Arguments] ${expected_contents}
108 ${json_value}= json_from_file ${expected_contents}
109 ${resp}= PostCall ${POLICY_PUBLISH_MR_TOPIC} ${json_value}
111 Should Be Equal As Strings ${resp.status_code} 200
112 ${count}= Evaluate $resp.json().get('count')
113 log 'JSON Response Code:'${resp}
116 [Arguments] ${expected_contents}
117 ${json_value}= json_from_file ${expected_contents}
118 ${resp}= PostCall ${AAI_MR_TOPIC} ${json_value}
120 Should Be Equal As Strings ${resp.status_code} 200
121 ${count}= Evaluate $resp.json().get('count')
122 log 'JSON Response Code:'${resp}
125 [Arguments] ${expected_contents}
126 ${json_value}= json_from_file ${expected_contents}
127 ${resp}= PostCall ${AAI_MR_TOPIC} ${json_value}
129 Should Be Equal As Strings ${resp.status_code} 200
130 ${count}= Evaluate $resp.json().get('count')
131 log 'JSON Response Code:'${resp}
134 [Arguments] ${url} ${data}
135 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
136 ${resp}= Post Request mr_sim_session ${url} json=${data} headers=${headers}