2 Documentation Testing PMSH functionality
4 Library OperatingSystem
5 Library RequestsLibrary
9 Resource ../../common.robot
10 Test Teardown Delete All Sessions
15 ${PMSH_BASE_URL} https://${PMSH_IP}:8443
16 ${MR_BASE_URL} http://${MR_IP_ADDRESS}:3904
17 ${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443
18 ${SUBSCRIPTION_ENDPOINT} /subscription
19 ${POLICY_PUBLISH_MR_TOPIC} /events/unauthenticated.PMSH_CL_INPUT
20 ${AAI_MR_TOPIC} /events/AAI_EVENT
22 ${MR_AAI_PNF_CREATED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/aai-pnf-create.json
23 ${MR_AAI_PNF_REMOVED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/aai-pnf-delete.json
24 ${MR_POLICY_RESPONSE_PNF_EXISTING} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/policy-sub-created-pnf-existing.json
25 ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json
26 ${CREATE_SUBSCRIPTION_DATA} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/create_subscription_request.json
27 ${CREATE_SECOND_SUBSCRIPTION_DATA} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/create_second_subscription_request.json
28 ${CREATE_SUBSCRIPTION_BAD_DATA} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/create_subscription_bad_request.json
29 ${CREATE_SUBSCRIPTION_SCHEMA_ERROR_DATA} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/create_subscription_schema_error_request.json
30 ${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
31 ${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 Get subscriptions with Network Functions None
36 [Documentation] Verify Get all subscriptions when there are no defined subscriptions
38 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT} ""
39 Should Be True ${resp.status_code} == 200
40 Should Contain ${resp.text} []
42 Verify Create Subscriptions API
44 [Documentation] Verify Create Subscription API
46 ${json_value}= json_from_file ${CREATE_SUBSCRIPTION_DATA}
47 ${resp}= PostSubscriptionCall ${SUBSCRIPTION_ENDPOINT} ${json_value}
48 Should Be True ${resp.status_code} == 201
49 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT} "/subs_01"
50 Should Be Equal As Strings ${resp.json()[0]['subscription']['subscriptionName']} subs_01
52 Verify database tables exist and are empty
54 [Documentation] Verify database has been created and is empty
56 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT} ""
57 Should Be True ${resp.status_code} == 200
58 Should Contain ${resp.text} []
60 Verify PNF detected in AAI when administrative state unlocked
62 [Documentation] Verify PNF detected when administrative state unlocked
64 SetAdministrativeStateToUnlocked
65 Sleep 31 Allow PMSH time to pick up changes in CBS config
66 ${resp}= GetMeasGrpCall /subscription/subs_01/measurementGroups/msg_grp_01
67 Should Be Equal As Strings ${resp.json()['subscriptionName']} subs_01
68 Should Be Equal As Strings ${resp.json()['administrativeState']} UNLOCKED
69 Should Be Equal As Strings ${resp.json()['networkFunctions'][0]['nfName']} pnf-existing
70 Should Be Equal As Strings ${resp.json()['networkFunctions'][0]['nfMgStatus']} PENDING_CREATE
72 Verify Policy response on MR is handled
74 [Documentation] Verify policy response on MR is handled
76 SimulatePolicyResponse ${MR_POLICY_RESPONSE_PNF_EXISTING}
77 Sleep 31 seconds Ensure Policy response on MR is picked up
78 ${resp}= GetMeasGrpCall /subscription/subs_01/measurementGroups/msg_grp_01
79 Should Be Equal As Strings ${resp.json()['subscriptionName']} subs_01
80 Should Be Equal As Strings ${resp.json()['administrativeState']} UNLOCKED
81 Should Be Equal As Strings ${resp.json()['networkFunctions'][0]['nfName']} pnf-existing
82 Should Be Equal As Strings ${resp.json()['networkFunctions'][0]['nfMgStatus']} CREATED
84 Verify AAI event on MR detailing new PNF being detected is handled
86 [Documentation] Verify PNF created AAI event on MR is handled
88 SimulateNewPNF ${MR_AAI_PNF_CREATED}
89 Sleep 31 seconds Ensure AAI event on MR is picked up
90 ${resp}= GetMeasGrpCall /subscription/subs_01/measurementGroups/msg_grp_01
91 Should Be Equal As Strings ${resp.json()['subscriptionName']} subs_01
92 Should Be Equal As Strings ${resp.json()['administrativeState']} UNLOCKED
93 Should Be Equal As Strings ${resp.json()['networkFunctions'][1]['nfName']} pnf_newly_discovered
94 Should Be Equal As Strings ${resp.json()['networkFunctions'][1]['nfMgStatus']} PENDING_CREATE
96 Verify AAI event on MR detailing PNF being deleted is handled
98 [Documentation] Verify PNF deleted AAI event on MR is handled
100 SimulateDeletedPNF ${MR_AAI_PNF_REMOVED}
101 Sleep 31 seconds Ensure AAI event on MR is picked up
102 ${resp}= GetMeasGrpCall /subscription/subs_01/measurementGroups/msg_grp_01
103 Should Not Contain ${resp.text} pnf_newly_discovered
105 Verify Create Subscription API for duplicate subscription Id
107 [Documentation] Verify Create Subscription API
109 ${json_value}= json_from_file ${CREATE_SUBSCRIPTION_DATA}
110 ${resp}= PostSubscriptionCall ${SUBSCRIPTION_ENDPOINT} ${json_value}
111 Should Be True ${resp.status_code} == 409
112 Should Contain ${resp.json()} subscription Name: subs_01 already exists.
114 Verify Create Subscription API for schema error
116 [Documentation] Verify Create Subscription API
118 ${json_value}= json_from_file ${CREATE_SUBSCRIPTION_SCHEMA_ERROR_DATA}
119 ${resp}= PostSubscriptionCall ${SUBSCRIPTION_ENDPOINT} ${json_value}
120 Should Be True ${resp.status_code} == 400
121 Should Contain ${resp.json()['detail']} 'administrativeState' is a required property - 'subscription.measurementGroups.0.measurementGroup'
123 Verify Create Subscription API for filter values missing
125 [Documentation] Verify Create Subscription API
127 ${json_value}= json_from_file ${CREATE_SUBSCRIPTION_BAD_DATA}
128 ${resp}= PostSubscriptionCall ${SUBSCRIPTION_ENDPOINT} ${json_value}
129 Should Be True ${resp.status_code} == 400
130 Should Contain ${resp.json()} At least one filter within nfFilter must not be empty
132 Verify Get Measurement Group with Network Functions
134 [Documentation] Verify Get Measurement Group with Network Functions by using MGName and SubName
136 ${resp}= GetMeasGrpWithNFSCall /subscription/subs_01/measurementGroups/msg_grp_01
137 ${nf_length}= Get length ${resp.json()['networkFunctions']}
138 Should Be True ${resp.status_code} == 200
139 Should Be Equal As Strings ${resp.json()['subscriptionName']} subs_01
140 Should Be Equal As Strings ${resp.json()['measurementGroupName']} msg_grp_01
141 Should Be Equal As Strings ${resp.json()['networkFunctions'][0]['nfName']} pnf-existing
142 Should be equal as numbers ${nf_length} 1
144 Verify Get single subscription with Network Functions
146 [Documentation] Verify Get single subscription with Network Functions by using subscription name
148 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT}/subs_01 ""
149 ${nf_length}= Get length ${resp.json()['subscription']['nfs']}
150 Should Be True ${resp.status_code} == 200
151 Should Be Equal As Strings ${resp.json()['subscription']['subscriptionName']} subs_01
152 Should Be Equal As Strings ${resp.json()['subscription']['nfs'][0]} pnf-existing
153 Should Be Equal As Strings ${resp.json()['subscription']['measurementGroups'][0]['measurementGroup']['measurementGroupName']} msg_grp_02
154 Should be equal as numbers ${nf_length} 1
156 Verify Get single subscription with Network Functions None
158 [Documentation] Verify Get single subscription with Network Functions when there is no defined subscription
160 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT}/sub_none ""
161 Should Be True ${resp.status_code} == 404
162 Should Be Equal As Strings ${resp.json()['error']} Subscription was not defined with the name : sub_none
164 Verify Get subscriptions with Network Functions
166 [Documentation] Verify Get all defined subscriptions with associated Network Functions
168 ${json_value}= json_from_file ${CREATE_SECOND_SUBSCRIPTION_DATA}
169 ${resp_post}= PostSubscriptionCall ${SUBSCRIPTION_ENDPOINT} ${json_value}
170 ${resp}= GetSubsCall ${SUBSCRIPTION_ENDPOINT} ""
171 ${nf_length_first}= Get length ${resp.json()[0]['subscription']['nfs']}
172 ${nf_length_second}= Get length ${resp.json()[1]['subscription']['nfs']}
173 Should Be True ${resp.status_code} == 200
174 Should Be Equal As Strings ${resp.json()[0]['subscription']['subscriptionName']} subs_01
175 Should Be Equal As Strings ${resp.json()[0]['subscription']['nfs'][0]} pnf-existing
176 Should Be Equal As Strings ${resp.json()[0]['subscription']['measurementGroups'][0]['measurementGroup']['measurementGroupName']} msg_grp_02
177 Should be equal as numbers ${nf_length_first} 1
178 Should Be Equal As Strings ${resp.json()[1]['subscription']['subscriptionName']} subs_02
179 Should Be Equal As Strings ${resp.json()[1]['subscription']['nfs'][0]} pnf-existing
180 Should Be Equal As Strings ${resp.json()[1]['subscription']['measurementGroups'][0]['measurementGroup']['measurementGroupName']} msg_grp_04
181 Should be equal as numbers ${nf_length_second} 1
186 SetAdministrativeStateToUnlocked
187 ${data}= Get Data From File ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED}
188 Create Session cbs_sim_session ${CBS_BASE_URL} verify=false
189 ${resp}= PUT On Session cbs_sim_session url=/clear data={"path": "/service_component_all/.*"}
190 Should Be True ${resp.status_code} == 200
191 Sleep 2 Allow CBS time to set expectation
192 ${resp} = PUT On Session cbs_sim_session url=/expectation data=${data}
193 Should Be True ${resp.status_code} == 201
196 SimulatePolicyResponse
197 [Arguments] ${expected_contents}
198 ${json_value}= json_from_file ${expected_contents}
199 ${resp}= PostMrCall ${POLICY_PUBLISH_MR_TOPIC} ${json_value}
201 Should Be Equal As Strings ${resp.status_code} 200
202 ${count}= Evaluate $resp.json().get('count')
203 log 'JSON Response Code:'${resp}
206 [Arguments] ${expected_contents}
207 ${json_value}= json_from_file ${expected_contents}
208 ${resp}= PostMrCall ${AAI_MR_TOPIC} ${json_value}
210 Should Be Equal As Strings ${resp.status_code} 200
211 ${count}= Evaluate $resp.json().get('count')
212 log 'JSON Response Code:'${resp}
215 [Arguments] ${expected_contents}
216 ${json_value}= json_from_file ${expected_contents}
217 ${resp}= PostMrCall ${AAI_MR_TOPIC} ${json_value}
219 Should Be Equal As Strings ${resp.status_code} 200
220 ${count}= Evaluate $resp.json().get('count')
221 log 'JSON Response Code:'${resp}
224 [Arguments] ${url} ${data}
225 Create Session mr_sim_session ${MR_BASE_URL} verify=false
226 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
227 ${resp}= POST On Session mr_sim_session url=${url} json=${data} headers=${headers}
231 [Arguments] ${url} ${url_path_param}
232 Create Session pmsh_session ${PMSH_BASE_URL} verify=false
233 ${resp}= GET On Session pmsh_session url=${url} data={"path": {url_path_param}} expected_status=any
238 Create Session pmsh_session ${PMSH_BASE_URL} verify=false
239 ${resp}= GET On Session pmsh_session url=${url}
242 GetMeasGrpWithNFSCall
244 Create Session pmsh_session ${PMSH_BASE_URL} verify=false
245 ${resp}= GET On Session pmsh_session url=${url}
249 [Arguments] ${url} ${data}
250 Create Session pmsh_sub_session ${PMSH_BASE_URL} verify=false
251 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json
252 ${resp}= POST On Session pmsh_sub_session url=${url} json=${data} headers=${headers} expected_status=anything