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 | |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 39 | # use_mock_redfish: If true, mock redfish OLTs will be used instead of a |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 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 | |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 43 | # use_kubernetes_importer: If true, then the importer and demo_test will |
| 44 | # be installed using Kubernetes. Default: False |
| 45 | ${use_kubernetes_install} False |
| 46 | |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 47 | # use_Containerized_dm: If true, then dm will be run from inside the |
| 48 | # demo-test container. Default: False. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 49 | ${use_containerized_dm} False |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 50 | |
| 51 | # voltha_suite_setup. If true, then voltha common test suite setup will |
| 52 | # be run. Among other things, this will also check to ensure that |
| 53 | # Kubernetes is configured. Default: False. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 54 | ${voltha_suite_setup} False |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 55 | |
| 56 | # Pod names when using the Kubernetes-based deploy-redfish-importer.yaml. See |
| 57 | # the keyword "Install Mock Redfish Server" for the step that brings up these |
| 58 | # pods and checks their existence. |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 59 | ${IMPORTER_POD_NAME} redfish-importer |
| 60 | ${DEMOTEST_POD_NAME} redfish-demotest |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 61 | ${MOCK1_POD_NAME} mock-olt-1 |
| 62 | ${MOCK2_POD_NAME} mock-olt-2 |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 63 | |
| 64 | *** Test Cases *** |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 65 | Add Device to Monitor |
| 66 | [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] | 67 | ${TESTNAME}= Set Variable If ${multiple_olt} tests/add_device_to_monitor tests/add_single_device_to_monitor |
| 68 | ${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 |
| 69 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 70 | Should Be Equal ${EXPECTED} ${OUTPUT} |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 71 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 72 | Clear Subscribed Events |
| 73 | [Documentation] This test case excercises the API, ClearCurrentEventList, which clears all Redfish evets currently subscribed to. |
| 74 | ${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] | 75 | ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1} |
| 76 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 77 | |
| 78 | Configure Data Polling Interval |
| 79 | [Documentation] This test case excercises the API, SetFrequency, which configures the interval of data polling. |
| 80 | ${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] | 81 | ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1} |
| 82 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 83 | |
| 84 | Delete Monitored Device |
| 85 | [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] | 86 | ${TESTNAME}= SEt Variable If ${multiple_olt} tests/delete_monitored_device tests/delete_single_monitored_device |
| 87 | ${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 |
| 88 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 89 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 90 | |
| 91 | List Devices monitored |
| 92 | [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] | 93 | ${TESTNAME}= SEt Variable If ${multiple_olt} tests/list_device_monitored tests/list_single_device_monitored |
| 94 | ${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 |
| 95 | ${OUTPUT}= Run Test ${TESTNAME}.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 96 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 97 | |
| 98 | List Subscribed Events |
| 99 | [Documentation] This test case excercises the API, GetCurrentEventList, which lists all Redfish evets currently subscribed to. |
| 100 | ${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] | 101 | ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1} |
| 102 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 103 | |
| 104 | List Supported Events |
| 105 | [Documentation] This test case excercises the API, GetEventList, which lists all supported Redfish events. |
| 106 | ${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] | 107 | ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1} |
| 108 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 109 | |
| 110 | Subscribe Events |
| 111 | [Documentation] This test case excercises the API, SubscribeGivenEvents, which subscribes to the specified events. |
| 112 | ${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] | 113 | ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1} |
| 114 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 115 | |
| 116 | Unsubscribe Events |
| 117 | [Documentation] This test case excercises the API, UnsubscribeGivenEvents, which unsubscribes to the specified events. |
| 118 | ${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] | 119 | ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1} |
| 120 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 121 | |
| 122 | Validate IP |
| 123 | [Documentation] This test case validates the format of IP, whcih is expected to be in the form of <ip>:<port>. |
| 124 | ${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] | 125 | ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1} |
| 126 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 127 | |
| 128 | *** Keywords *** |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 129 | Setup Suite |
| 130 | [Documentation] Set up the test suite |
| 131 | # Common voltha-system-test related setup. Only do this with a physical OLT, when called from ONF Jenkins |
| 132 | Run Keyword If ${voltha_suite_setup} Common Test Suite Setup |
| 133 | # Ensure the redfish import and demotest containers are deployed and running. |
| 134 | Run Keyword If ${use_mock_redfish} Install Mock Redfish Server |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 135 | Run Keyword If ${use_kubernetes_install} Install Importer Using Kubernetes |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 136 | Get IP AND PORT |
| 137 | |
| 138 | Teardown Suite |
| 139 | [Documentation] Clean up devices if desired |
| 140 | ... kills processes and cleans up interfaces on src+dst servers |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 141 | Run Keyword If ${use_kubernetes_install} Clean Up Importer Using Kubernetes |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 142 | Run Keyword If ${use_mock_redfish} Clean Up Mock Redfish Server |
| 143 | |
| 144 | Install Mock Redfish Server |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 145 | [Documentation] Installs Redfish Importer and Demotest |
| 146 | Apply Kubernetes Resources ../../kubernetes/deploy-mock-olts.yaml default |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 147 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 148 | ... Validate Pod Status ${MOCK1_POD_NAME} default Running |
| 149 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 150 | ... Validate Pod Status ${MOCK2_POD_NAME} default Running |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 151 | # After the pods have come online, it may still take a few seconds |
| 152 | # before they start responding to requests. |
| 153 | Sleep 10 Seconds |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 154 | |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 155 | Install Importer Using Kubernetes |
| 156 | [Documentation] Installs mock OLTS |
| 157 | Apply Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
| 158 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 159 | ... Validate Pod Status ${IMPORTER_POD_NAME} default Running |
| 160 | Wait Until Keyword Succeeds ${pod_timeout} 5s |
| 161 | ... Validate Pod Status ${DEMOTEST_POD_NAME} default Running |
| 162 | |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 163 | Clean Up Mock Redfish Server |
Scott Baker | e0382b8 | 2020-05-01 14:53:45 -0700 | [diff] [blame] | 164 | Delete Kubernetes Resources ../../kubernetes/deploy-mock-olts.yaml default |
| 165 | |
| 166 | Clean Up Importer Using Kubernetes |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 167 | Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
| 168 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 169 | Get IP AND PORT |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 170 | ${num_addr}= Get Length ${ADDR_LIST} |
| 171 | ${multiple_olt}= Set Variable If ${num_addr}>1 True False |
| 172 | Set Suite Variable ${multiple_olt} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 173 | Sort List ${ADDR_LIST} |
| 174 | ${I1}= Fetch From LEFT ${ADDR_LIST}[0] : |
| 175 | Set Suite Variable ${IP1} ${I1} |
| 176 | ${P1}= Fetch From Right ${ADDR_LIST}[0] : |
| 177 | Set Suite Variable ${PORT1} ${P1} |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 178 | Run Keyword If ${multiple_olt} Get IP AND PORT Second OLT |
| 179 | ... ELSE Set No Second OLT |
| 180 | |
| 181 | Get IP AND PORT Second OLT |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 182 | ${I2}= Fetch From LEFT ${ADDR_LIST}[1] : |
| 183 | Set Suite Variable ${IP2} ${I2} |
| 184 | ${P2}= Fetch From Right ${ADDR_LIST}[1] : |
| 185 | Set Suite Variable ${PORT2} ${P2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 186 | |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame] | 187 | Set No Second OLT |
| 188 | Set Suite Variable ${IP2} None |
| 189 | Set Suite Variable ${PORT2} None |
| 190 | |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 191 | Run Test |
| 192 | [Arguments] @{args} |
| 193 | ${output}= Run Keyword if ${use_containerized_dm} |
| 194 | ... Run Test In Container @{args} |
| 195 | ... ELSE |
| 196 | ... Run Test On Host @{args} |
| 197 | [Return] ${output} |
| 198 | |
| 199 | Run Test On Host |
| 200 | [Arguments] ${testname} @{args} |
| 201 | ${output}= Run Process ${testname} @{args} |
| 202 | [Return] ${output.stdout} |
| 203 | |
| 204 | Run Test In Container |
| 205 | [Arguments] ${testname} @{args} |
| 206 | Copy File To Pod default ${DEMOTEST_POD_NAME} ${testname} "/test.tc" |
| 207 | ${argList}= Evaluate " ".join($args) |
| 208 | ${output}= Exec Pod default ${DEMOTEST_POD_NAME} sh /test.tc ${argList} |
| 209 | [Return] ${output} |