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} https://${MR_SIM_IP_ADDRESS}:3095
19 ${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443
20 ${SUBSCRIPTIONS_ENDPOINT} /subscriptions
22 ${MR_EXPECTATION_AAI_PNF_CREATED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-created.json
23 ${MR_EXPECTATION_AAI_PNF_REMOVED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-aai-pnf-deleted.json
24 ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json
25 ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json
27 ${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
28 ${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"
32 Verify Administrative State in PMSH log file is LOCKED
34 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
36 Sleep 3 Allow time for PMSH to flush to logs
37 ${cli_cmd_output}= Run Process ${CLI_EXEC_GET_CBS_CONFIG_FIRST} shell=yes
38 Should Be True ${cli_cmd_output.rc} == 0
39 Should Contain ${cli_cmd_output.stdout} ${ADMIN_STATE_LOCKED_PATTERN}
41 Verify database tables exist and are empty
43 [Documentation] Verify database has been created and is empty
45 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
46 Should Be True ${resp.status_code} == 200
47 Should Contain ${resp.text} []
49 Verify PNF detected in AAI when administrative state unlocked
51 [Documentation] Verify PNF detected when administrative state unlocked
53 SetAdministrativeStateToUnlocked
54 Sleep 31 Allow PMSH time to pick up changes in CBS config
55 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
56 Should Be Equal As Strings ${resp.json()[0]['subscription_status']} UNLOCKED
57 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_name']} pnf-existing
58 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} PENDING_CREATE
60 Verify Policy response on MR is handled
62 [Documentation] Verify policy response on MR is handled
64 SimulatePolicyResponse ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING}
65 Sleep 31 seconds Ensure Policy response on MR is picked up
66 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
67 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED
69 Verify AAI event on MR detailing new PNF being detected is handled
71 [Documentation] Verify PNF created AAI event on MR is handled
74 Sleep 31 seconds Ensure AAI event on MR is picked up
75 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
76 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered
77 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE
79 Verify AAI event on MR detailing PNF being deleted is handled
81 [Documentation] Verify PNF deleted AAI event on MR is handled
84 Sleep 31 seconds Ensure AAI event on MR is picked up
85 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
86 Should Not Contain ${resp.text} pnf_newly_discovered
91 Create Session pmsh_session ${PMSH_BASE_URL}
92 Create Session mr_sim_session ${MR_BASE_URL}
93 Create Session cbs_sim_session ${CBS_BASE_URL}
95 SetAdministrativeStateToUnlocked
96 ${data}= Get Data From File ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED}
97 ${resp} = Put Request cbs_sim_session /clear data={"path": "/service_component_all/.*"}
98 Should Be True ${resp.status_code} == 200
99 Sleep 2 Allow CBS time to set expectation
100 ${resp} = Put Request cbs_sim_session /expectation data=${data}
101 Should Be True ${resp.status_code} == 201
104 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_CREATED}
105 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event"}
106 Should Be True ${resp.status_code} == 200
107 ${resp} = Put Request mr_sim_session /expectation data=${data}
108 Should Be True ${resp.status_code} == 201
110 SimulatePolicyResponse
111 [Arguments] ${expected_contents}
112 ${data}= Get Data From File ${expected_contents}
113 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input"}
114 Should Be True ${resp.status_code} == 200
115 ${resp} = Put Request mr_sim_session /expectation data=${data}
116 Should Be True ${resp.status_code} == 201
119 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_REMOVED}
120 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event"}
121 Should Be True ${resp.status_code} == 200
122 ${resp} = Put Request mr_sim_session /expectation data=${data}
123 Should Be True ${resp.status_code} == 201