blob: 95b78c257b499e20c129d98d53e1ba905a08144e [file] [log] [blame]
AndyWalsheb412c7b2020-02-13 15:05:21 +00001*** Settings ***
2Documentation Testing PMSH functionality
AndyWalshe48496a52020-03-12 12:52:19 +00003
AndyWalsheb412c7b2020-02-13 15:05:21 +00004Library OperatingSystem
5Library RequestsLibrary
6Library String
AndyWalshe48496a52020-03-12 12:52:19 +00007Library Process
AndyWalsheb412c7b2020-02-13 15:05:21 +00008
AndyWalshe48496a52020-03-12 12:52:19 +00009Resource ../../common.robot
10
11Test Setup CreateSessions
AndyWalsheb412c7b2020-02-13 15:05:21 +000012Test Teardown Delete All Sessions
13
14
15*** Variables ***
AndyWalshe48496a52020-03-12 12:52:19 +000016
AndyWalsheb412c7b2020-02-13 15:05:21 +000017${PMSH_BASE_URL} https://${PMSH_IP}:8443
AndyWalshe48496a52020-03-12 12:52:19 +000018${MR_BASE_URL} http://${MR_SIM_IP_ADDRESS}:1080
19${CBS_BASE_URL} http://${CBS_SIM_IP_ADDRESS}:1080
AndyWalsheb412c7b2020-02-13 15:05:21 +000020${HEALTHCHECK_ENDPOINT} /healthcheck
21
AndyWalshe48496a52020-03-12 12:52:19 +000022${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
27
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"
32
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;'"
36
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;'"
40
AndyWalsheb412c7b2020-02-13 15:05:21 +000041
42*** Test Cases ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000043
AndyWalshe48496a52020-03-12 12:52:19 +000044Verify PMSH health check returns 200 and has a status of healthy
45 [Tags] PMSH_01
46 [Documentation] Verify the PMSH health check api call functions correctly
47 [Timeout] 10 seconds
AndyWalsheb412c7b2020-02-13 15:05:21 +000048 ${resp}= Get Request pmsh_session ${HEALTHCHECK_ENDPOINT}
AndyWalshe48496a52020-03-12 12:52:19 +000049 Should Be True ${resp.status_code} == 200
50 Should Match Regexp ${resp.text} healthy
51
52Verify Administrative State in PMSH log file is LOCKED
53 [Tags] PMSH_02
54 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
55 [Timeout] 10 seconds
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}
60
61Verify database tables exist and are empty
62 [Tags] PMSH_03
63 [Documentation] Verify database has been created and is empty
64 [Timeout] 10 seconds
65 VerifyDatabaseEmpty
66
67Verify PNF detected in AAI when administrative state unlocked
68 [Tags] PMSH_04
69 [Documentation] Verify PNF detected when administrative state unlocked
70 [Timeout] 40 seconds
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
77
78Verify Policy response on MR is handled
79 [Tags] PMSH_05
80 [Documentation] Verify policy response on MR is handled
81 [Timeout] 40 seconds
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
85
86Verify AAI event on MR detailing new PNF being detected is handled
87 [Tags] PMSH_06
88 [Documentation] Verify PNF created AAI event on MR is handled
89 [Timeout] 30 seconds
90 SimulateNewPNF
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
95
96Verify AAI event on MR detailing PNF being deleted is handled
97 [Tags] PMSH_07
98 [Documentation] Verify PNF deleted AAI event on MR is handled
99 [Timeout] 30 seconds
100 SimulateDeletedPNF
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
AndyWalsheb412c7b2020-02-13 15:05:21 +0000104
105*** Keywords ***
AndyWalsheb412c7b2020-02-13 15:05:21 +0000106
AndyWalshe48496a52020-03-12 12:52:19 +0000107CreateSessions
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}
111
112SetAdministrativeStateToUnlocked
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
119
120VerifyCommandOutputContains
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}
125
126VerifyCommandOutputIs
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}
132
133SimulateNewPNF
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
139
140SimulatePolicyResponse
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
147
148SimulateDeletedPNF
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
154
155VerifyNumberOfRecordsInDbTable
156 [Arguments] ${db_query} ${expected_count}
157 ${db_count} Run Process ${db_query} shell=yes
158 Should Be True ${db_count.stdout} == ${expected_count}
159
160VerifyDatabaseEmpty
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