AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Testing PMSH functionality |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 3 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 4 | Library OperatingSystem |
| 5 | Library RequestsLibrary |
| 6 | Library String |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 7 | Library Process |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 8 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 9 | Resource ../../common.robot |
| 10 | |
| 11 | Test Setup CreateSessions |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 12 | Test Teardown Delete All Sessions |
| 13 | |
| 14 | |
| 15 | *** Variables *** |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 16 | |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 17 | ${PMSH_BASE_URL} https://${PMSH_IP}:8443 |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 18 | ${MR_BASE_URL} http://${MR_IP_ADDRESS}:3904 |
efiacor | e207b42 | 2020-04-23 10:36:54 +0100 | [diff] [blame] | 19 | ${CBS_BASE_URL} https://${CBS_SIM_IP_ADDRESS}:10443 |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 20 | ${SUBSCRIPTIONS_ENDPOINT} /subscriptions |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 21 | ${POLICY_PUBLISH_MR_TOPIC} /events/unauthenticated.PMSH_CL_INPUT |
| 22 | ${AAI_MR_TOPIC} /events/AAI_EVENT |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 23 | |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 24 | ${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 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 28 | |
| 29 | ${ADMIN_STATE_LOCKED_PATTERN} 'administrativeState': 'LOCKED' |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 30 | ${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" |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 31 | |
| 32 | *** Test Cases *** |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 33 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 34 | Verify Administrative State in PMSH log file is LOCKED |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 35 | [Tags] PMSH_01 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 36 | [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 | |
| 43 | Verify database tables exist and are empty |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 44 | [Tags] PMSH_02 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 45 | [Documentation] Verify database has been created and is empty |
| 46 | [Timeout] 10 seconds |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 47 | ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 48 | Should Be True ${resp.status_code} == 200 |
| 49 | Should Contain ${resp.text} [] |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 50 | |
| 51 | Verify PNF detected in AAI when administrative state unlocked |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 52 | [Tags] PMSH_03 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 53 | [Documentation] Verify PNF detected when administrative state unlocked |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 54 | [Timeout] 60 seconds |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 55 | SetAdministrativeStateToUnlocked |
| 56 | Sleep 31 Allow PMSH time to pick up changes in CBS config |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 57 | ${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 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 61 | |
| 62 | Verify Policy response on MR is handled |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 63 | [Tags] PMSH_04 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 64 | [Documentation] Verify policy response on MR is handled |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 65 | [Timeout] 60 seconds |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 66 | SimulatePolicyResponse ${MR_POLICY_RESPONSE_PNF_EXISTING} |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 67 | Sleep 31 seconds Ensure Policy response on MR is picked up |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 68 | ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} |
| 69 | Should Be Equal As Strings ${resp.json()[0]['network_functions'][0]['nf_sub_status']} CREATED |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 70 | |
| 71 | Verify AAI event on MR detailing new PNF being detected is handled |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 72 | [Tags] PMSH_05 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 73 | [Documentation] Verify PNF created AAI event on MR is handled |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 74 | [Timeout] 60 seconds |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 75 | SimulateNewPNF ${MR_AAI_PNF_CREATED} |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 76 | Sleep 31 seconds Ensure AAI event on MR is picked up |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 77 | ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 78 | Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_name']} pnf_newly_discovered |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 79 | Should Be Equal As Strings ${resp.json()[0]['network_functions'][1]['nf_sub_status']} PENDING_CREATE |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 80 | |
| 81 | Verify AAI event on MR detailing PNF being deleted is handled |
efiacor | b67a093 | 2020-05-22 13:48:52 +0100 | [diff] [blame] | 82 | [Tags] PMSH_06 |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 83 | [Documentation] Verify PNF deleted AAI event on MR is handled |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 84 | [Timeout] 60 seconds |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 85 | SimulateDeletedPNF ${MR_AAI_PNF_REMOVED} |
efiacor | 455efa4 | 2020-08-12 14:50:54 +0100 | [diff] [blame] | 86 | Sleep 31 seconds Ensure AAI event on MR is picked up |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 87 | ${resp}= Get Request pmsh_session ${SUBSCRIPTIONS_ENDPOINT} |
| 88 | Should Not Contain ${resp.text} pnf_newly_discovered |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 89 | |
| 90 | *** Keywords *** |
AndyWalshe | b412c7b | 2020-02-13 15:05:21 +0000 | [diff] [blame] | 91 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 92 | CreateSessions |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 93 | Create Session pmsh_session ${PMSH_BASE_URL} |
| 94 | Create Session mr_sim_session ${MR_BASE_URL} |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 95 | Create Session cbs_sim_session ${CBS_BASE_URL} |
| 96 | |
| 97 | SetAdministrativeStateToUnlocked |
| 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 | |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 105 | |
| 106 | SimulatePolicyResponse |
| 107 | [Arguments] ${expected_contents} |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 108 | ${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 | |
| 115 | SimulateNewPNF |
| 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} |
AndyWalshe | 48496a5 | 2020-03-12 12:52:19 +0000 | [diff] [blame] | 123 | |
| 124 | SimulateDeletedPNF |
efiacor | 830e11d | 2021-01-29 14:28:34 +0000 | [diff] [blame] | 125 | [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 | |
| 133 | PostCall |
| 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} |