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_SIM_IP_ADDRESS}:1080
19 ${CBS_BASE_URL} http://${CBS_SIM_IP_ADDRESS}:1080
20 ${HEALTHCHECK_ENDPOINT} /healthcheck
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_NEW} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-new.json
25 ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/mr-expectation-policy-subscription-created-pnf-existing.json
26 ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED} %{WORKSPACE}/tests/dcaegen2-services-pmsh/testcases/assets/cbs-expectation-unlocked-config.json
28 ${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
29 ${ADMIN_STATE_UNLOCKED_PATTERN} 'administrativeState': 'UNLOCKED'
30 ${CLI_EXEC_GET_CBS_CONFIG_FIRST} docker exec pmsh /bin/sh -c "grep -m 1 'PMSH Configuration from Configbinding Service' /var/log/ONAP/dcaegen2/services/pmsh/debug.log"
31 ${CLI_EXEC_GET_CBS_CONFIG_LAST} docker exec pmsh /bin/sh -c "grep 'PMSH Configuration from Configbinding Service' /var/log/ONAP/dcaegen2/services/pmsh/debug.log | tail -1"
33 ${DB_CMD_NETWORK_FUNCTIONS_COUNT} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select count(*) from network_functions;'"
34 ${DB_CMD_NF_TO_SUB_REL_COUNT} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select count(*) from nf_to_sub_rel;'"
35 ${DB_CMD_SUBSCRIPTIONS_COUNT} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select count(*) from subscriptions;'"
37 ${CLI_GET_NETWORK_FUNCTIONS_DB_TABLE} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select nf_name, orchestration_status from network_functions;'"
38 ${CLI_GET_NF_TO_SUB_REL_DB_TABLE} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select subscription_name, nf_name, nf_sub_status from nf_to_sub_rel;'"
39 ${CLI_GET_SUBSCRIPTIONS_DB_TABLE} docker exec db bash -c "psql -U pmsh -d pmsh -A -t -c 'select subscription_name, status from subscriptions;'"
44 Verify PMSH health check returns 200 and has a status of healthy
46 [Documentation] Verify the PMSH health check api call functions correctly
48 ${resp}= Get Request pmsh_session ${HEALTHCHECK_ENDPOINT}
49 Should Be True ${resp.status_code} == 200
50 Should Match Regexp ${resp.text} healthy
52 Verify Administrative State in PMSH log file is LOCKED
54 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
56 Sleep 3 Allow time for PMSH to flush to logs
57 ${cli_cmd_output}= Run Process ${CLI_EXEC_GET_CBS_CONFIG_FIRST} shell=yes
58 Should Be True ${cli_cmd_output.rc} == 0
59 Should Contain ${cli_cmd_output.stdout} ${ADMIN_STATE_LOCKED_PATTERN}
61 Verify database tables exist and are empty
63 [Documentation] Verify database has been created and is empty
67 Verify PNF detected in AAI when administrative state unlocked
69 [Documentation] Verify PNF detected when administrative state unlocked
71 SetAdministrativeStateToUnlocked
72 Sleep 31 Allow PMSH time to pick up changes in CBS config
73 VerifyCommandOutputContains ${CLI_EXEC_GET_CBS_CONFIG_LAST} ${ADMIN_STATE_UNLOCKED_PATTERN}
74 VerifyCommandOutputIs ${cli_get_subscriptions_db_table} ExtraPM-All-gNB-R2B|UNLOCKED
75 VerifyCommandOutputIs ${cli_get_network_functions_db_table} pnf-existing|Active
76 VerifyCommandOutputIs ${cli_get_nf_to_sub_rel_db_table} ExtraPM-All-gNB-R2B|pnf-existing|PENDING_CREATE
78 Verify Policy response on MR is handled
80 [Documentation] Verify policy response on MR is handled
82 SimulatePolicyResponse ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING}
83 Sleep 7 seconds Ensure Policy response on MR is picked up
84 VerifyCommandOutputIs ${cli_get_nf_to_sub_rel_db_table} ExtraPM-All-gNB-R2B|pnf-existing|CREATED
86 Verify AAI event on MR detailing new PNF being detected is handled
88 [Documentation] Verify PNF created AAI event on MR is handled
91 Sleep 12 seconds Ensure AAI event on MR is picked up
92 VerifyCommandOutputIs ${CLI_GET_SUBSCRIPTIONS_DB_TABLE} ExtraPM-All-gNB-R2B|UNLOCKED
93 VerifyCommandOutputIs ${CLI_GET_NETWORK_FUNCTIONS_DB_TABLE} pnf-existing|Active\npnf_newly_discovered|Active
94 VerifyCommandOutputIs ${CLI_GET_NF_TO_SUB_REL_DB_TABLE} ExtraPM-All-gNB-R2B|pnf-existing|CREATED\nExtraPM-All-gNB-R2B|pnf_newly_discovered|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
101 Sleep 12 seconds Ensure AAI event on MR is picked up
102 VerifyNumberOfRecordsInDbTable ${DB_CMD_NETWORK_FUNCTIONS_COUNT} 1
103 VerifyNumberOfRecordsInDbTable ${DB_CMD_NF_TO_SUB_REL_COUNT} 1
108 Create Session pmsh_session ${PMSH_BASE_URL}
109 Create Session mr_sim_session ${MR_BASE_URL}
110 Create Session cbs_sim_session ${CBS_BASE_URL}
112 SetAdministrativeStateToUnlocked
113 ${data}= Get Data From File ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED}
114 ${resp} = Put Request cbs_sim_session /clear data={"path": "/service_component_all/.*"}
115 Should Be True ${resp.status_code} == 200
116 Sleep 2 Allow CBS time to set expectation
117 ${resp} = Put Request cbs_sim_session /expectation data=${data}
118 Should Be True ${resp.status_code} == 201
120 VerifyCommandOutputContains
121 [Arguments] ${cli_command} ${string_to_check_for}
122 ${cli_cmd_output}= Run Process ${cli_command} shell=yes
123 Should Be True ${cli_cmd_output.rc} == 0
124 Should Contain ${cli_cmd_output.stdout} ${string_to_check_for}
126 VerifyCommandOutputIs
127 [Arguments] ${cli_cmd} ${expected_contents}
128 ${cli_cmd_output}= Run Process ${cli_cmd} shell=yes
129 Log ${cli_cmd_output.stdout}
130 Should Be True ${cli_cmd_output.rc} == 0
131 Should Be Equal As Strings ${cli_cmd_output.stdout} ${expected_contents}
134 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_CREATED}
135 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/AAI-EVENT"}
136 Should Be True ${resp.status_code} == 200
137 ${resp} = Put Request mr_sim_session /expectation data=${data}
138 Should Be True ${resp.status_code} == 201
140 SimulatePolicyResponse
141 [Arguments] ${expected_contents}
142 ${data}= Get Data From File ${expected_contents}
143 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS/dcae_pmsh_cg/policy_response_consumer"}
144 Should Be True ${resp.status_code} == 200
145 ${resp} = Put Request mr_sim_session /expectation data=${data}
146 Should Be True ${resp.status_code} == 201
149 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_REMOVED}
150 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/AAI-EVENT"}
151 Should Be True ${resp.status_code} == 200
152 ${resp} = Put Request mr_sim_session /expectation data=${data}
153 Should Be True ${resp.status_code} == 201
155 VerifyNumberOfRecordsInDbTable
156 [Arguments] ${db_query} ${expected_count}
157 ${db_count} Run Process ${db_query} shell=yes
158 Should Be True ${db_count.stdout} == ${expected_count}
161 VerifyNumberOfRecordsInDbTable ${DB_CMD_NETWORK_FUNCTIONS_COUNT} 0
162 VerifyNumberOfRecordsInDbTable ${DB_CMD_NF_TO_SUB_REL_COUNT} 0
163 VerifyNumberOfRecordsInDbTable ${DB_CMD_SUBSCRIPTIONS_COUNT} 0