Dinesh Belwalkar | 6c0bc75 | 2020-04-24 23:47:53 +0000 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
| 2 | # Copyright 2018-present Edgecore Networks Corporation |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | *** Settings *** |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 17 | Documentation Provide the function to perform funtional tests for the Redfish device-management project |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 18 | Suite Setup Setup Suite |
| 19 | Suite Teardown Teardown Suite |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 20 | Library Process |
| 21 | Library OperatingSystem |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 22 | Library BuiltIn |
| 23 | Library String |
| 24 | Library Collections |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 25 | Library ../../voltha-system-tests/libraries/DependencyLibrary.py |
| 26 | Resource ../../voltha-system-tests/libraries/k8s.robot |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 27 | |
| 28 | *** Variables *** |
| 29 | @{ADDR_LIST} 192.168.4.26:8888 192.168.4.27:8888 |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 30 | |
| 31 | # timeout: timeout for most operations. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 32 | ${timeout} 60s |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 33 | |
| 34 | # pod_timeout: timeout to bring up a new pod. It has been observed to take up to |
| 35 | # 120 seconds for images to pull. Set 300 seconds to alloww room for temporary |
| 36 | # network fluctuation. |
| 37 | ${pod_timeout} 300s |
| 38 | |
| 39 | # use_mock_redfish: If true, mock redfish OLTs will be used instead of a |
| 40 | # physical device. Default: False. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 41 | ${use_mock_redfish} False |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 42 | |
| 43 | # use_Containerized_dm: If true, then dm will be run from inside the |
| 44 | # demo-test container. Default: False. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 45 | ${use_containerized_dm} False |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 46 | |
| 47 | # voltha_suite_setup. If true, then voltha common test suite setup will |
| 48 | # be run. Among other things, this will also check to ensure that |
| 49 | # Kubernetes is configured. Default: False. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 50 | ${voltha_suite_setup} False |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 51 | |
| 52 | # Pod names when using the Kubernetes-based deploy-redfish-importer.yaml. See |
| 53 | # the keyword "Install Mock Redfish Server" for the step that brings up these |
| 54 | # pods and checks their existence. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 55 | ${IMPORTER_POD_NAME} redfish-importer |
| 56 | ${DEMOTEST_POD_NAME} redfish-demotest |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 57 | ${MOCK1_POD_NAME} mock-olt-1 |
| 58 | ${MOCK2_POD_NAME} mock-olt-2 |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 59 | |
| 60 | *** Test Cases *** |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 61 | Add Device to Monitor |
| 62 | [Documentation] This test case excercises the API, SendDeviceList, which registers Redfish devices to monitor. |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 63 | ${TESTNAME}= Set Variable If ${multiple_olt} tests/add_device_to_monitor tests/add_single_device_to_monitor |
| 64 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected |
| 65 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 66 | Should Be Equal ${EXPECTED} ${OUTPUT} |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 67 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 68 | Clear Subscribed Events |
| 69 | [Documentation] This test case excercises the API, ClearCurrentEventList, which clears all Redfish evets currently subscribed to. |
| 70 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/clear_all_subscribed_events.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 71 | ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1} |
| 72 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 73 | |
| 74 | Configure Data Polling Interval |
| 75 | [Documentation] This test case excercises the API, SetFrequency, which configures the interval of data polling. |
| 76 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/configure_data_polling_interval.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 77 | ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1} |
| 78 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 79 | |
| 80 | Delete Monitored Device |
| 81 | [Documentation] This test case excercises the API, DeleteDeviceList, which deletes Redfish devices being monitored. |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 82 | ${TESTNAME}= SEt Variable If ${multiple_olt} tests/delete_monitored_device tests/delete_single_monitored_device |
| 83 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected |
| 84 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 85 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 86 | |
| 87 | List Devices monitored |
| 88 | [Documentation] This test case excercises the API, GetCurrentDevices, which lists all Redfish devices being monitored. |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 89 | ${TESTNAME}= SEt Variable If ${multiple_olt} tests/list_device_monitored tests/list_single_device_monitored |
| 90 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected |
| 91 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 92 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 93 | |
| 94 | List Subscribed Events |
| 95 | [Documentation] This test case excercises the API, GetCurrentEventList, which lists all Redfish evets currently subscribed to. |
| 96 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/list_subscribed_events.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 97 | ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1} |
| 98 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 99 | |
| 100 | List Supported Events |
| 101 | [Documentation] This test case excercises the API, GetEventList, which lists all supported Redfish events. |
| 102 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/list_supported_events.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 103 | ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1} |
| 104 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 105 | |
| 106 | Subscribe Events |
| 107 | [Documentation] This test case excercises the API, SubscribeGivenEvents, which subscribes to the specified events. |
| 108 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/subscribe_events.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 109 | ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1} |
| 110 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 111 | |
| 112 | Unsubscribe Events |
| 113 | [Documentation] This test case excercises the API, UnsubscribeGivenEvents, which unsubscribes to the specified events. |
| 114 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/unsubscribe_events.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 115 | ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1} |
| 116 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 117 | |
| 118 | Validate IP |
| 119 | [Documentation] This test case validates the format of IP, whcih is expected to be in the form of <ip>:<port>. |
| 120 | ${EXPECTED}= RUN sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' tests/validate_ip.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 121 | ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1} |
| 122 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 123 | |
| 124 | *** Keywords *** |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 125 | Setup Suite |
| 126 | [Documentation] Set up the test suite |
| 127 | # Common voltha-system-test related setup. Only do this with a physical OLT, when called from ONF Jenkins |
| 128 | Run Keyword If ${voltha_suite_setup} Common Test Suite Setup |
| 129 | # Ensure the redfish import and demotest containers are deployed and running. |
| 130 | Run Keyword If ${use_mock_redfish} Install Mock Redfish Server |
| 131 | Get IP AND PORT |
| 132 | |
| 133 | Teardown Suite |
| 134 | [Documentation] Clean up devices if desired |
| 135 | ... kills processes and cleans up interfaces on src+dst servers |
| 136 | Run Keyword If ${use_mock_redfish} Clean Up Mock Redfish Server |
| 137 | |
| 138 | Install Mock Redfish Server |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 139 | [Documentation] Installs mock OLTS, redfish importer, demo-test |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 140 | Apply Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 141 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 142 | ... Validate Pod Status ${MOCK1_POD_NAME} default Running |
| 143 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 144 | ... Validate Pod Status ${MOCK2_POD_NAME} default Running |
| 145 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 146 | ... Validate Pod Status ${IMPORTER_POD_NAME} default Running |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 147 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 148 | ... Validate Pod Status ${DEMOTEST_POD_NAME} default Running |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 149 | # After the pods have come online, it may still take a few seconds |
| 150 | # before they start responding to requests. |
| 151 | Sleep 10 Seconds |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 152 | |
| 153 | Clean Up Mock Redfish Server |
| 154 | Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
| 155 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 156 | Get IP AND PORT |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 157 | ${num_addr}= Get Length ${ADDR_LIST} |
| 158 | ${multiple_olt}= Set Variable If ${num_addr}>1 True False |
| 159 | Set Suite Variable ${multiple_olt} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 160 | Sort List ${ADDR_LIST} |
| 161 | ${I1}= Fetch From LEFT ${ADDR_LIST}[0] : |
| 162 | Set Suite Variable ${IP1} ${I1} |
| 163 | ${P1}= Fetch From Right ${ADDR_LIST}[0] : |
| 164 | Set Suite Variable ${PORT1} ${P1} |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 165 | Run Keyword If ${multiple_olt} Get IP AND PORT Second OLT |
| 166 | ... ELSE Set No Second OLT |
| 167 | |
| 168 | Get IP AND PORT Second OLT |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 169 | ${I2}= Fetch From LEFT ${ADDR_LIST}[1] : |
| 170 | Set Suite Variable ${IP2} ${I2} |
| 171 | ${P2}= Fetch From Right ${ADDR_LIST}[1] : |
| 172 | Set Suite Variable ${PORT2} ${P2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 173 | |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 174 | Set No Second OLT |
| 175 | Set Suite Variable ${IP2} None |
| 176 | Set Suite Variable ${PORT2} None |
| 177 | |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 178 | Run Test |
| 179 | [Arguments] @{args} |
| 180 | ${output}= Run Keyword if ${use_containerized_dm} |
| 181 | ... Run Test In Container @{args} |
| 182 | ... ELSE |
| 183 | ... Run Test On Host @{args} |
| 184 | [Return] ${output} |
| 185 | |
| 186 | Run Test On Host |
| 187 | [Arguments] ${testname} @{args} |
| 188 | ${output}= Run Process ${testname} @{args} |
| 189 | [Return] ${output.stdout} |
| 190 | |
| 191 | Run Test In Container |
| 192 | [Arguments] ${testname} @{args} |
| 193 | Copy File To Pod default ${DEMOTEST_POD_NAME} ${testname} "/test.tc" |
| 194 | ${argList}= Evaluate " ".join($args) |
| 195 | ${output}= Exec Pod default ${DEMOTEST_POD_NAME} sh /test.tc ${argList} |
| 196 | [Return] ${output} |