Scott Baker | 60e570d | 2020-02-02 22:10:13 -0800 | [diff] [blame] | 1 | #Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | *** Settings *** |
| 16 | Documentation This test raises alarms using bbsimctl and verifies them using voltctl |
| 17 | Suite Setup Setup Suite |
| 18 | Suite Teardown Teardown Suite |
| 19 | Library Collections |
| 20 | Library String |
| 21 | Library OperatingSystem |
| 22 | Library XML |
| 23 | Library RequestsLibrary |
| 24 | Library ../../libraries/DependencyLibrary.py |
| 25 | Resource ../../libraries/onos.robot |
| 26 | Resource ../../libraries/voltctl.robot |
| 27 | Resource ../../libraries/utils.robot |
| 28 | Resource ../../libraries/k8s.robot |
| 29 | Resource ../../variables/variables.robot |
| 30 | |
| 31 | *** Variables *** |
| 32 | ${timeout} 60s |
| 33 | ${long_timeout} 420s |
| 34 | ${of_id} 0 |
| 35 | ${logical_id} 0 |
| 36 | ${has_dataplane} True |
| 37 | ${external_libs} True |
| 38 | ${setup_device} True |
| 39 | ${teardown_device} True |
| 40 | ${VOLTCTL_NAMESPACE} default |
| 41 | ${BBSIMCTL_NAMESPACE} voltha |
| 42 | ${VOLTCTL_POD_NAME} voltctl |
| 43 | ${BBSIMCTL_POD_NAME} bbsim |
| 44 | |
| 45 | *** Test Cases *** |
| 46 | Ensure required pods Running |
| 47 | [Documentation] Ensure the bbsim and voltctl pods are in Running state |
| 48 | [Tags] active |
| 49 | Validate Pod Status ${BBSIMCTL_POD_NAME} ${BBSIMCTL_NAMESPACE} Running |
| 50 | Validate Pod Status ${VOLTCTL_POD_NAME} ${VOLTCTL_NAMESPACE} Running |
| 51 | |
| 52 | ONU Discovery |
| 53 | [Documentation] Discover lists of ONUS, their Serial Numbers and device id, and pick one for subsequent tests |
| 54 | [Tags] active |
| 55 | #build onu sn list |
| 56 | ${List_ONU_Serial} Create List |
| 57 | Set Suite Variable ${List_ONU_Serial} |
| 58 | Build ONU SN List ${List_ONU_Serial} |
| 59 | Log ${List_ONU_Serial} |
| 60 | #validate onu states |
| 61 | Wait Until Keyword Succeeds ${long_timeout} 20s |
| 62 | ... Validate ONU Devices ENABLED ACTIVE REACHABLE ${List_ONU_Serial} |
| 63 | # Pick an ONU to use for subsequent test cases |
| 64 | ${onu_sn} Set Variable ${List_ONU_Serial}[0] |
| 65 | Set Suite Variable ${onu_sn} |
| 66 | ${onu_id} Get Device ID From SN ${onu_sn} |
| 67 | Set Suite Variable ${onu_id} |
| 68 | |
| 69 | Test StartupFailureAlarm |
| 70 | [Documentation] Raise StartupFailure Alarm and verify event received |
| 71 | [Tags] not_active |
| 72 | Raise Alarm StartupFailure ${onu_sn} |
| 73 | # This one is actually broken... |
| 74 | # TODO: complete test once alarm is working... |
| 75 | |
| 76 | Test RaiseLossOfBurstAlarm |
| 77 | [Documentation] Raise Loss Of Burst Alarm and verify event received |
| 78 | [Tags] active |
| 79 | ${since} Get Current Time |
| 80 | Raise Alarm LossOfBurst ${onu_sn} |
| 81 | ${header} ${deviceEvent} Get Device Event ONU_LOSS_OF_BURST_RAISE_EVENT ${since} |
| 82 | Verify Header ${header} Voltha.openolt.ONU_LOSS_OF_BURST\.(\\d+) |
| 83 | Should Be Equal ${deviceEvent}[deviceEventName] ONU_LOSS_OF_BURST_RAISE_EVENT |
| 84 | # TODO: Why does the event have the OLT ID instead of the ONU ID ? Verify correctness. |
| 85 | ${parent_id} Get Parent ID From Device ID ${onu_id} |
| 86 | Should Be Equal ${deviceEvent}[resourceId] ${parent_id} |
| 87 | |
| 88 | Test ClearLossOfBurstAlarm |
| 89 | [Documentation] Clear Loss Of Burst Alarm and verify event received |
| 90 | [Tags] active |
| 91 | ${since} Get Current Time |
| 92 | Clear Alarm LossOfBurst ${onu_sn} |
| 93 | ${header} ${deviceEvent} Get Device Event ONU_LOSS_OF_BURST_CLEAR_EVENT ${since} |
| 94 | Verify Header ${header} Voltha.openolt.ONU_LOSS_OF_BURST\.(\\d+) |
| 95 | Should Be Equal ${deviceEvent}[deviceEventName] ONU_LOSS_OF_BURST_CLEAR_EVENT |
| 96 | # TODO: Why does the event have the OLT ID instead of the ONU ID ? Verify correctness. |
| 97 | ${parent_id} Get Parent ID From Device ID ${onu_id} |
| 98 | Should Be Equal ${deviceEvent}[resourceId] ${parent_id} |
| 99 | |
| 100 | *** Keywords *** |
| 101 | Setup Suite |
| 102 | [Documentation] Set up the test suite |
| 103 | Common Test Suite Setup |
| 104 | # Ensure the voltctl pod is deployed and running |
| 105 | Apply Kubernetes Resources ./voltctl.yaml ${VOLTCTL_NAMESPACE} |
| 106 | Wait Until Keyword Succeeds ${timeout} 5s |
| 107 | ... Validate Pod Status ${VOLTCTL_POD_NAME} ${VOLTCTL_NAMESPACE} Running |
| 108 | # Call Setup keyword in utils library to create and enable device |
| 109 | Run Keyword If ${setup_device} Setup |
| 110 | |
| 111 | Teardown Suite |
| 112 | [Documentation] Clean up devices if desired |
| 113 | ... kills processes and cleans up interfaces on src+dst servers |
| 114 | Run Keyword If ${external_libs} Get ONOS Status ${k8s_node_ip} |
| 115 | Run Keyword If ${has_dataplane} Clean Up Linux |
| 116 | Run Keyword If ${external_libs} |
| 117 | ... Log Kubernetes Containers Logs Since Time ${datetime} ${container_list} |
| 118 | Run Keyword If ${teardown_device} Delete Device and Verify |
| 119 | Run Keyword If ${teardown_device} Test Empty Device List |
| 120 | Run Keyword If ${teardown_device} Execute ONOS CLI Command ${k8s_node_ip} ${ONOS_SSH_PORT} |
| 121 | ... device-remove ${of_id} |
| 122 | |
| 123 | Raise Alarm |
| 124 | [Documentation] Raise an Alarm |
| 125 | [Arguments] ${name} ${sn} |
| 126 | ${raiseOutput} Exec Pod ${BBSIMCTL_NAMESPACE} ${BBSIMCTL_POD_NAME} bbsimctl alarm raise ${name} ${sn} |
| 127 | Should Contain ${raiseOutput} Alarm Indication Sent |
| 128 | |
| 129 | Clear Alarm |
| 130 | [Documentation] Raise an Alarm |
| 131 | [Arguments] ${name} ${sn} |
| 132 | ${raiseOutput} Exec Pod ${BBSIMCTL_NAMESPACE} ${BBSIMCTL_POD_NAME} bbsimctl alarm clear ${name} ${sn} |
| 133 | Should Contain ${raiseOutput} Alarm Indication Sent |
| 134 | |
| 135 | Get Device Event |
| 136 | [Documentation] Get the most recent alarm event from voltha.events |
| 137 | [Arguments] ${deviceEventName} ${since} |
| 138 | ${output} ${raiseErr} Exec Pod Separate Stderr ${VOLTCTL_NAMESPACE} ${VOLTCTL_POD_NAME} |
| 139 | ... voltctl event listen --show-body -t 1 -o json -f Titles=${deviceEventName} -s ${since} |
| 140 | ${json} To Json ${output} |
| 141 | ${count} Get Length ${json} |
| 142 | # If there is more than one event (which could happen if we quickly do a raise and a clear), |
| 143 | # then return the most recent one. |
| 144 | Should Be Larger Than ${count} 0 |
| 145 | ${lastIndex} Evaluate ${count}-1 |
| 146 | ${lastItem} Set Variable ${json}[${lastIndex}] |
| 147 | ${header} Set Variable ${lastItem}[header] |
| 148 | ${deviceEvent} Set Variable ${lastItem}[deviceEvent] |
| 149 | Log ${header} |
| 150 | Log ${deviceEvent} |
| 151 | [return] ${header} ${deviceEvent} |
| 152 | |
| 153 | Verify Header |
| 154 | [Documentation] Verify that a DeviceEvent's header is sane and the id matches regex |
| 155 | [Arguments] ${header} ${id} |
| 156 | Should Be Equal ${header}[subCategory] ONU |
| 157 | Should Be Equal ${header}[type] DEVICE_EVENT |
| 158 | Should Match Regexp ${header}[id] ${id} |
| 159 | # TODO Revisit when timestamp format is changed from Float to Timestamp |
| 160 | Should Be Float ${header}[raisedTs] |
| 161 | Should Be Float ${header}[reportedTs] |
| 162 | |