blob: a2b8cad65c439483b69bb3d385ce446dddda08bf [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
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'
efiacorb67a0932020-05-22 13:48:52 +010029${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 +000030
31*** Test Cases ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000032
AndyWalshe48496a52020-03-12 12:52:19 +000033Verify Administrative State in PMSH log file is LOCKED
efiacorb67a0932020-05-22 13:48:52 +010034 [Tags] PMSH_01
AndyWalshe48496a52020-03-12 12:52:19 +000035 [Documentation] Verify Administrative State as logged in PMSH log file is LOCKED
36 [Timeout] 10 seconds
37 Sleep 3 Allow time for PMSH to flush to logs
38 ${cli_cmd_output}= Run Process ${CLI_EXEC_GET_CBS_CONFIG_FIRST} shell=yes
39 Should Be True ${cli_cmd_output.rc} == 0
40 Should Contain ${cli_cmd_output.stdout} ${ADMIN_STATE_LOCKED_PATTERN}
41
42Verify database tables exist and are empty
efiacorb67a0932020-05-22 13:48:52 +010043 [Tags] PMSH_02
AndyWalshe48496a52020-03-12 12:52:19 +000044 [Documentation] Verify database has been created and is empty
45 [Timeout] 10 seconds
efiacorb67a0932020-05-22 13:48:52 +010046 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
47 Should Be True ${resp.status_code} == 200
48 Should Contain ${resp.text} []
AndyWalshe48496a52020-03-12 12:52:19 +000049
50Verify PNF detected in AAI when administrative state unlocked
efiacorb67a0932020-05-22 13:48:52 +010051 [Tags] PMSH_03
AndyWalshe48496a52020-03-12 12:52:19 +000052 [Documentation] Verify PNF detected when administrative state unlocked
53 [Timeout] 40 seconds
54 SetAdministrativeStateToUnlocked
55 Sleep 31 Allow PMSH time to pick up changes in CBS config
efiacorb67a0932020-05-22 13:48:52 +010056 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
57 Should Be Equal As Strings ${resp.json()[0]['subscription_status']} UNLOCKED
58 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_name']} pnf-existing
59 Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['orchestration_status']} Active
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
65 [Timeout] 40 seconds
66 SimulatePolicyResponse ${MR_EXPECTATION_POLICY_RESPONSE_PNF_EXISTING}
efiacor49b46442020-07-06 11:55:44 +010067 Sleep 15 seconds Ensure Policy response on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010068 ${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
74 [Timeout] 30 seconds
75 SimulateNewPNF
efiacor49b46442020-07-06 11:55:44 +010076 Sleep 15 seconds Ensure AAI event on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010077 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
78 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered
79 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['orchestration_status']} Active
80 Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE
AndyWalshe48496a52020-03-12 12:52:19 +000081
82Verify AAI event on MR detailing PNF being deleted is handled
efiacorb67a0932020-05-22 13:48:52 +010083 [Tags] PMSH_06
AndyWalshe48496a52020-03-12 12:52:19 +000084 [Documentation] Verify PNF deleted AAI event on MR is handled
85 [Timeout] 30 seconds
86 SimulateDeletedPNF
87 Sleep 12 seconds Ensure AAI event on MR is picked up
efiacorb67a0932020-05-22 13:48:52 +010088 ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT}
89 Should Not Contain ${resp.text} pnf_newly_discovered
AndyWalsheb412c7b2020-02-13 15:05:21 +000090
91*** Keywords ***
AndyWalsheb412c7b2020-02-13 15:05:21 +000092
AndyWalshe48496a52020-03-12 12:52:19 +000093CreateSessions
94 Create Session pmsh_session ${PMSH_BASE_URL}
95 Create Session mr_sim_session ${MR_BASE_URL}
96 Create Session cbs_sim_session ${CBS_BASE_URL}
97
98SetAdministrativeStateToUnlocked
99 ${data}= Get Data From File ${CBS_EXPECTATION_ADMIN_STATE_UNLOCKED}
100 ${resp} = Put Request cbs_sim_session /clear data={"path": "/service_component_all/.*"}
101 Should Be True ${resp.status_code} == 200
102 Sleep 2 Allow CBS time to set expectation
103 ${resp} = Put Request cbs_sim_session /expectation data=${data}
104 Should Be True ${resp.status_code} == 201
105
AndyWalshe48496a52020-03-12 12:52:19 +0000106SimulateNewPNF
107 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_CREATED}
efiacor49b46442020-07-06 11:55:44 +0100108 ${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 +0000109 Should Be True ${resp.status_code} == 200
110 ${resp} = Put Request mr_sim_session /expectation data=${data}
111 Should Be True ${resp.status_code} == 201
112
113SimulatePolicyResponse
114 [Arguments] ${expected_contents}
115 ${data}= Get Data From File ${expected_contents}
efiacor49b46442020-07-06 11:55:44 +0100116 ${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 +0000117 Should Be True ${resp.status_code} == 200
118 ${resp} = Put Request mr_sim_session /expectation data=${data}
119 Should Be True ${resp.status_code} == 201
120
121SimulateDeletedPNF
122 ${data}= Get Data From File ${MR_EXPECTATION_AAI_PNF_REMOVED}
efiacor49b46442020-07-06 11:55:44 +0100123 ${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 +0000124 Should Be True ${resp.status_code} == 200
125 ${resp} = Put Request mr_sim_session /expectation data=${data}
126 Should Be True ${resp.status_code} == 201