blob: 4b0dc6e4a3ca9a3a51c94c77ef00dfc7191bc225 [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
efiacor830e11d2021-01-29 14:28:34 +000018${MR_BASE_URL} http://${MR_IP_ADDRESS}:3904
efiacore207b422020-04-23 10:36:54 +010019${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443
efiacorb67a0932020-05-22 13:48:52 +010020${SUBSCRIPTIONS_ENDPOINT} /subscriptions
efiacor830e11d2021-01-29 14:28:34 +000021${POLICY_PUBLISH_MR_TOPIC} /events/unauthenticated.PMSH_CL_INPUT
22${AAI_MR_TOPIC} /events/AAI_EVENT
AndyWalsheb412c7b2020-02-13 15:05:21 +000023
efiacor830e11d2021-01-29 14:28:34 +000024${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
AndyWalshe48496a52020-03-12 12:52:19 +000028
29${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
efiacorb67a0932020-05-22 13:48:52 +010030${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"
AndyWalsheb412c7b2020-02-13 15:05:21 +000031
32*** Test Cases ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000033
AndyWalshe48496a52020-03-12 12:52:19 +000034Verify Administrative State in PMSH log file is LOCKED
efiacorb67a0932020-05-22 13:48:52 +010035 [Tags] PMSH_01
AndyWalshe48496a52020-03-12 12:52:19 +000036 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
37 [Timeout] 10 seconds
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}
42
43Verify database tables exist and are empty
efiacorb67a0932020-05-22 13:48:52 +010044 [Tags] PMSH_02
AndyWalshe48496a52020-03-12 12:52:19 +000045 [Documentation] Verify database has been created and is empty
46 [Timeout] 10 seconds
efiacor830e11d2021-01-29 14:28:34 +000047 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
efiacorb67a0932020-05-22 13:48:52 +010048 Should Be True ${resp.status_code} == 200
49 Should Contain ${resp.text} []
AndyWalshe48496a52020-03-12 12:52:19 +000050
51Verify PNF detected in AAI when administrative state unlocked
efiacorb67a0932020-05-22 13:48:52 +010052 [Tags] PMSH_03
AndyWalshe48496a52020-03-12 12:52:19 +000053 [Documentation] Verify PNF detected when administrative state unlocked
efiacor830e11d2021-01-29 14:28:34 +000054 [Timeout] 60 seconds
AndyWalshe48496a52020-03-12 12:52:19 +000055 SetAdministrativeStateToUnlocked
56 Sleep 31 Allow PMSH time to pick up changes in CBS config
efiacor830e11d2021-01-29 14:28:34 +000057 ${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
AndyWalshe48496a52020-03-12 12:52:19 +000061
62Verify Policy response on MR is handled
efiacorb67a0932020-05-22 13:48:52 +010063 [Tags] PMSH_04
AndyWalshe48496a52020-03-12 12:52:19 +000064 [Documentation] Verify policy response on MR is handled
efiacor455efa42020-08-12 14:50:54 +010065 [Timeout] 60 seconds
efiacor830e11d2021-01-29 14:28:34 +000066 SimulatePolicyResponse ${MR_POLICY_RESPONSE_PNF_EXISTING}
efiacor455efa42020-08-12 14:50:54 +010067 Sleep 31 seconds Ensure Policy response on MR is picked up
efiacor830e11d2021-01-29 14:28:34 +000068 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
69 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED
AndyWalshe48496a52020-03-12 12:52:19 +000070
71Verify AAI event on MR detailing new PNF being detected is handled
efiacorb67a0932020-05-22 13:48:52 +010072 [Tags] PMSH_05
AndyWalshe48496a52020-03-12 12:52:19 +000073 [Documentation] Verify PNF created AAI event on MR is handled
efiacor455efa42020-08-12 14:50:54 +010074 [Timeout] 60 seconds
efiacor830e11d2021-01-29 14:28:34 +000075 SimulateNewPNF ${MR_AAI_PNF_CREATED}
efiacor455efa42020-08-12 14:50:54 +010076 Sleep 31 seconds Ensure AAI event on MR is picked up
efiacor830e11d2021-01-29 14:28:34 +000077 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
efiacorb67a0932020-05-22 13:48:52 +010078 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered
efiacor830e11d2021-01-29 14:28:34 +000079 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE
AndyWalshe48496a52020-03-12 12:52:19 +000080
81Verify AAI event on MR detailing PNF being deleted is handled
efiacorb67a0932020-05-22 13:48:52 +010082 [Tags] PMSH_06
AndyWalshe48496a52020-03-12 12:52:19 +000083 [Documentation] Verify PNF deleted AAI event on MR is handled
efiacor455efa42020-08-12 14:50:54 +010084 [Timeout] 60 seconds
efiacor830e11d2021-01-29 14:28:34 +000085 SimulateDeletedPNF ${MR_AAI_PNF_REMOVED}
efiacor455efa42020-08-12 14:50:54 +010086 Sleep 31 seconds Ensure AAI event on MR is picked up
efiacor830e11d2021-01-29 14:28:34 +000087 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
88 Should Not Contain ${resp.text} pnf_newly_discovered
AndyWalsheb412c7b2020-02-13 15:05:21 +000089
90*** Keywords ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000091
AndyWalshe48496a52020-03-12 12:52:19 +000092CreateSessions
efiacor830e11d2021-01-29 14:28:34 +000093 Create Session pmsh_session ${PMSH_BASE_URL}
94 Create Session mr_sim_session ${MR_BASE_URL}
AndyWalshe48496a52020-03-12 12:52:19 +000095 Create Session cbs_sim_session ${CBS_BASE_URL}
96
97SetAdministrativeStateToUnlocked
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
104
AndyWalshe48496a52020-03-12 12:52:19 +0000105
106SimulatePolicyResponse
107 [Arguments] ${expected_contents}
efiacor830e11d2021-01-29 14:28:34 +0000108 ${json_value}= json_from_file ${expected_contents}
109 ${resp}= PostCall ${POLICY_PUBLISH_MR_TOPIC} ${json_value}
110 log ${resp.text}
111 Should Be Equal As Strings ${resp.status_code} 200
112 ${count}= Evaluate $resp.json().get('count')
113 log 'JSON Response Code:'${resp}
114
115SimulateNewPNF
116 [Arguments] ${expected_contents}
117 ${json_value}= json_from_file ${expected_contents}
118 ${resp}= PostCall ${AAI_MR_TOPIC} ${json_value}
119 log ${resp.text}
120 Should Be Equal As Strings ${resp.status_code} 200
121 ${count}= Evaluate $resp.json().get('count')
122 log 'JSON Response Code:'${resp}
AndyWalshe48496a52020-03-12 12:52:19 +0000123
124SimulateDeletedPNF
efiacor830e11d2021-01-29 14:28:34 +0000125 [Arguments] ${expected_contents}
126 ${json_value}= json_from_file ${expected_contents}
127 ${resp}= PostCall ${AAI_MR_TOPIC} ${json_value}
128 log ${resp.text}
129 Should Be Equal As Strings ${resp.status_code} 200
130 ${count}= Evaluate $resp.json().get('count')
131 log 'JSON Response Code:'${resp}
132
133PostCall
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}
137 [Return] ${resp}