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