blob: 2f0e5bf6f9ef1c4178acb78178348e937e827981 [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
efiacore207b422020-04-23 10:36:54 +010018${MR_BASE_URL} https://${MR_SIM_IP_ADDRESS}:3095
19${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443
efiacorb67a0932020-05-22 13:48:52 +010020${SUBSCRIPTIONS_ENDPOINT} /subscriptions
AndyWalsheb412c7b2020-02-13 15:05:21 +000021
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
AndyWalshe48496a52020-03-12 12:52:19 +000024${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
26
27${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED'
efiacorb67a0932020-05-22 13:48:52 +010028${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 +000029
30*** Test Cases ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000031
AndyWalshe48496a52020-03-12 12:52:19 +000032Verify Administrative State in PMSH log file is LOCKED
efiacorb67a0932020-05-22 13:48:52 +010033 [Tags] PMSH_01
AndyWalshe48496a52020-03-12 12:52:19 +000034 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
35 [Timeout] 10 seconds
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}
40
41Verify database tables exist and are empty
efiacorb67a0932020-05-22 13:48:52 +010042 [Tags] PMSH_02
AndyWalshe48496a52020-03-12 12:52:19 +000043 [Documentation] Verify database has been created and is empty
44 [Timeout] 10 seconds
efiacorb67a0932020-05-22 13:48:52 +010045 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
46 Should Be True ${resp.status_code} == 200
47 Should Contain ${resp.text} []
AndyWalshe48496a52020-03-12 12:52:19 +000048
49Verify PNF detected in AAI when administrative state unlocked
efiacorb67a0932020-05-22 13:48:52 +010050 [Tags] PMSH_03
AndyWalshe48496a52020-03-12 12:52:19 +000051 [Documentation] Verify PNF detected when administrative state unlocked
52 [Timeout] 40 seconds
53 SetAdministrativeStateToUnlocked
54 Sleep 31 Allow PMSH time to pick up changes in CBS config
efiacorb67a0932020-05-22 13:48:52 +010055 ${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
efiacorb67a0932020-05-22 13:48:52 +010058 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} PENDING_CREATE
AndyWalshe48496a52020-03-12 12:52:19 +000059
60Verify Policy response on MR is handled
efiacorb67a0932020-05-22 13:48:52 +010061 [Tags] PMSH_04
AndyWalshe48496a52020-03-12 12:52:19 +000062 [Documentation] Verify policy response on MR is handled
efiacor455efa42020-08-12 14:50:54 +010063 [Timeout] 60 seconds
AndyWalshe48496a52020-03-12 12:52:19 +000064 SimulatePolicyResponse ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING}
efiacor455efa42020-08-12 14:50:54 +010065 Sleep 31 seconds Ensure Policy response on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010066 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
67 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED
AndyWalshe48496a52020-03-12 12:52:19 +000068
69Verify AAI event on MR detailing new PNF being detected is handled
efiacorb67a0932020-05-22 13:48:52 +010070 [Tags] PMSH_05
AndyWalshe48496a52020-03-12 12:52:19 +000071 [Documentation] Verify PNF created AAI event on MR is handled
efiacor455efa42020-08-12 14:50:54 +010072 [Timeout] 60 seconds
AndyWalshe48496a52020-03-12 12:52:19 +000073 SimulateNewPNF
efiacor455efa42020-08-12 14:50:54 +010074 Sleep 31 seconds Ensure AAI event on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010075 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
76 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered
efiacorb67a0932020-05-22 13:48:52 +010077 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE
AndyWalshe48496a52020-03-12 12:52:19 +000078
79Verify AAI event on MR detailing PNF being deleted is handled
efiacorb67a0932020-05-22 13:48:52 +010080 [Tags] PMSH_06
AndyWalshe48496a52020-03-12 12:52:19 +000081 [Documentation] Verify PNF deleted AAI event on MR is handled
efiacor455efa42020-08-12 14:50:54 +010082 [Timeout] 60 seconds
AndyWalshe48496a52020-03-12 12:52:19 +000083 SimulateDeletedPNF
efiacor455efa42020-08-12 14:50:54 +010084 Sleep 31 seconds Ensure AAI event on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010085 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
86 Should Not Contain ${resp.text} pnf_newly_discovered
AndyWalsheb412c7b2020-02-13 15:05:21 +000087
88*** Keywords ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000089
AndyWalshe48496a52020-03-12 12:52:19 +000090CreateSessions
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}
94
95SetAdministrativeStateToUnlocked
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
102
AndyWalshe48496a52020-03-12 12:52:19 +0000103SimulateNewPNF
104 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_CREATED}
efiacor49b46442020-07-06 11:55:44 +0100105 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event"}
AndyWalshe48496a52020-03-12 12:52:19 +0000106 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
109
110SimulatePolicyResponse
111 [Arguments] ${expected_contents}
112 ${data}= Get Data From File ${expected_contents}
efiacor49b46442020-07-06 11:55:44 +0100113 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/unauthenticated.PMSH_CL_INPUT/dcae_pmsh_cg/dcae_pmsh_policy_cl_input"}
AndyWalshe48496a52020-03-12 12:52:19 +0000114 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
117
118SimulateDeletedPNF
119 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_REMOVED}
efiacor49b46442020-07-06 11:55:44 +0100120 ${resp} = Put Request mr_sim_session /clear data={"path": "/events/AAI_EVENT/dcae_pmsh_cg/dcae_pmsh_aai_event"}
AndyWalshe48496a52020-03-12 12:52:19 +0000121 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