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 | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 30 | ${timeout} 60s |
| 31 | ${use_mock_redfish} False |
| 32 | ${use_containerized_dm} False |
| 33 | ${voltha_suite_setup} False |
| 34 | ${IMPORTER_POD_NAME} redfish-importer |
| 35 | ${DEMOTEST_POD_NAME} redfish-demotest |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 36 | |
| 37 | *** Test Cases *** |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 38 | Add Device to Monitor |
| 39 | [Documentation] This test case excercises the API, SendDeviceList, which registers Redfish devices to monitor. |
| 40 | ${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' tests/add_device_to_monitor.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 41 | ${OUTPUT}= Run Test tests/add_device_to_monitor.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
| 42 | Should Be Equal ${EXPECTED} ${OUTPUT} |
mc | cd7e950 | 2019-12-16 22:04:13 +0000 | [diff] [blame] | 43 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 44 | Clear Subscribed Events |
| 45 | [Documentation] This test case excercises the API, ClearCurrentEventList, which clears all Redfish evets currently subscribed to. |
| 46 | ${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] | 47 | ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1} |
| 48 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 49 | |
| 50 | Configure Data Polling Interval |
| 51 | [Documentation] This test case excercises the API, SetFrequency, which configures the interval of data polling. |
| 52 | ${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] | 53 | ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1} |
| 54 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 55 | |
| 56 | Delete Monitored Device |
| 57 | [Documentation] This test case excercises the API, DeleteDeviceList, which deletes Redfish devices being monitored. |
| 58 | ${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' tests/delete_monitored_device.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 59 | ${OUTPUT}= Run Test tests/delete_monitored_device.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
| 60 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 61 | |
| 62 | List Devices monitored |
| 63 | [Documentation] This test case excercises the API, GetCurrentDevices, which lists all Redfish devices being monitored. |
| 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' tests/list_device_monitored.expected |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 65 | ${OUTPUT}= Run Test tests/list_device_monitored.tc ${IP1} ${PORT1} ${IP2} ${PORT2} |
| 66 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 67 | |
| 68 | List Subscribed Events |
| 69 | [Documentation] This test case excercises the API, GetCurrentEventList, which lists all Redfish evets currently subscribed to. |
| 70 | ${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] | 71 | ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1} |
| 72 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 73 | |
| 74 | List Supported Events |
| 75 | [Documentation] This test case excercises the API, GetEventList, which lists all supported Redfish events. |
| 76 | ${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] | 77 | ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1} |
| 78 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 79 | |
| 80 | Subscribe Events |
| 81 | [Documentation] This test case excercises the API, SubscribeGivenEvents, which subscribes to the specified events. |
| 82 | ${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] | 83 | ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1} |
| 84 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 85 | |
| 86 | Unsubscribe Events |
| 87 | [Documentation] This test case excercises the API, UnsubscribeGivenEvents, which unsubscribes to the specified events. |
| 88 | ${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] | 89 | ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1} |
| 90 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 91 | |
| 92 | Validate IP |
| 93 | [Documentation] This test case validates the format of IP, whcih is expected to be in the form of <ip>:<port>. |
| 94 | ${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] | 95 | ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1} |
| 96 | Should Be Equal ${EXPECTED} ${OUTPUT} |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 97 | |
| 98 | *** Keywords *** |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 99 | Setup Suite |
| 100 | [Documentation] Set up the test suite |
| 101 | # Common voltha-system-test related setup. Only do this with a physical OLT, when called from ONF Jenkins |
| 102 | Run Keyword If ${voltha_suite_setup} Common Test Suite Setup |
| 103 | # Ensure the redfish import and demotest containers are deployed and running. |
| 104 | Run Keyword If ${use_mock_redfish} Install Mock Redfish Server |
| 105 | Get IP AND PORT |
| 106 | |
| 107 | Teardown Suite |
| 108 | [Documentation] Clean up devices if desired |
| 109 | ... kills processes and cleans up interfaces on src+dst servers |
| 110 | Run Keyword If ${use_mock_redfish} Clean Up Mock Redfish Server |
| 111 | |
| 112 | Install Mock Redfish Server |
| 113 | Apply Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
| 114 | Wait Until Keyword Succeeds ${timeout} 5s |
| 115 | ... Validate Pod Status ${IMPORTER_POD_NAME} default Running |
| 116 | Wait Until Keyword Succeeds ${timeout} 5s |
| 117 | ... Validate Pod Status ${DEMOTEST_POD_NAME} default Running |
| 118 | |
| 119 | Clean Up Mock Redfish Server |
| 120 | Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default |
| 121 | |
Ubuntu | f45d1aa | 2020-02-06 07:01:44 +0000 | [diff] [blame] | 122 | Get IP AND PORT |
| 123 | Sort List ${ADDR_LIST} |
| 124 | ${I1}= Fetch From LEFT ${ADDR_LIST}[0] : |
| 125 | Set Suite Variable ${IP1} ${I1} |
| 126 | ${P1}= Fetch From Right ${ADDR_LIST}[0] : |
| 127 | Set Suite Variable ${PORT1} ${P1} |
| 128 | ${I2}= Fetch From LEFT ${ADDR_LIST}[1] : |
| 129 | Set Suite Variable ${IP2} ${I2} |
| 130 | ${P2}= Fetch From Right ${ADDR_LIST}[1] : |
| 131 | Set Suite Variable ${PORT2} ${P2} |
Scott Baker | 5d03e17 | 2020-04-10 14:56:20 -0700 | [diff] [blame] | 132 | |
| 133 | Run Test |
| 134 | [Arguments] @{args} |
| 135 | ${output}= Run Keyword if ${use_containerized_dm} |
| 136 | ... Run Test In Container @{args} |
| 137 | ... ELSE |
| 138 | ... Run Test On Host @{args} |
| 139 | [Return] ${output} |
| 140 | |
| 141 | Run Test On Host |
| 142 | [Arguments] ${testname} @{args} |
| 143 | ${output}= Run Process ${testname} @{args} |
| 144 | [Return] ${output.stdout} |
| 145 | |
| 146 | Run Test In Container |
| 147 | [Arguments] ${testname} @{args} |
| 148 | Copy File To Pod default ${DEMOTEST_POD_NAME} ${testname} "/test.tc" |
| 149 | ${argList}= Evaluate " ".join($args) |
| 150 | ${output}= Exec Pod default ${DEMOTEST_POD_NAME} sh /test.tc ${argList} |
| 151 | [Return] ${output} |