blob: 5116539bab40c915ec9f0dafb384e8269feeb155 [file] [log] [blame]
Dinesh Belwalkar6c0bc752020-04-24 23:47:53 +00001# Copyright 2018-present Open Networking Foundation
2# Copyright 2018-present Edgecore Networks Corporation
mccd7e9502019-12-16 22:04:13 +00003#
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 ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000017Documentation Provide the function to perform funtional tests for the Redfish device-management project
Scott Baker5d03e172020-04-10 14:56:20 -070018Suite Setup Setup Suite
19Suite Teardown Teardown Suite
mccd7e9502019-12-16 22:04:13 +000020Library Process
21Library OperatingSystem
Ubuntuf45d1aa2020-02-06 07:01:44 +000022Library BuiltIn
23Library String
24Library Collections
Scott Baker5d03e172020-04-10 14:56:20 -070025Library ../../voltha-system-tests/libraries/DependencyLibrary.py
26Resource ../../voltha-system-tests/libraries/k8s.robot
Ubuntuf45d1aa2020-02-06 07:01:44 +000027
28*** Variables ***
29@{ADDR_LIST} 192.168.4.26:8888 192.168.4.27:8888
Scott Baker105df152020-04-13 15:55:14 -070030
31# timeout: timeout for most operations.
Scott Baker5d03e172020-04-10 14:56:20 -070032${timeout} 60s
Scott Baker105df152020-04-13 15:55:14 -070033
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 Bakere0382b82020-05-01 14:53:45 -070039# use_mock_redfish: If true, mock redfish OLTs will be used instead of a
Scott Baker105df152020-04-13 15:55:14 -070040# physical device. Default: False.
Scott Baker5d03e172020-04-10 14:56:20 -070041${use_mock_redfish} False
Scott Baker105df152020-04-13 15:55:14 -070042
Scott Bakere0382b82020-05-01 14:53:45 -070043# 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 Baker105df152020-04-13 15:55:14 -070047# use_Containerized_dm: If true, then dm will be run from inside the
48# demo-test container. Default: False.
Scott Baker5d03e172020-04-10 14:56:20 -070049${use_containerized_dm} False
Scott Baker105df152020-04-13 15:55:14 -070050
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 Baker5d03e172020-04-10 14:56:20 -070054${voltha_suite_setup} False
Scott Baker105df152020-04-13 15:55:14 -070055
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 Baker5d03e172020-04-10 14:56:20 -070059${IMPORTER_POD_NAME} redfish-importer
60${DEMOTEST_POD_NAME} redfish-demotest
Scott Baker105df152020-04-13 15:55:14 -070061${MOCK1_POD_NAME} mock-olt-1
62${MOCK2_POD_NAME} mock-olt-2
mccd7e9502019-12-16 22:04:13 +000063
64*** Test Cases ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000065Add Device to Monitor
66 [Documentation] This test case excercises the API, SendDeviceList, which registers Redfish devices to monitor.
Scott Baker105df152020-04-13 15:55:14 -070067 ${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 Baker5d03e172020-04-10 14:56:20 -070070 Should Be Equal ${EXPECTED} ${OUTPUT}
mccd7e9502019-12-16 22:04:13 +000071
Ubuntuf45d1aa2020-02-06 07:01:44 +000072Clear 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 Baker5d03e172020-04-10 14:56:20 -070075 ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1}
76 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000077
78Configure 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 Baker5d03e172020-04-10 14:56:20 -070081 ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1}
82 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000083
84Delete Monitored Device
85 [Documentation] This test case excercises the API, DeleteDeviceList, which deletes Redfish devices being monitored.
Scott Baker105df152020-04-13 15:55:14 -070086 ${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 Baker5d03e172020-04-10 14:56:20 -070089 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000090
91List Devices monitored
92 [Documentation] This test case excercises the API, GetCurrentDevices, which lists all Redfish devices being monitored.
Scott Baker105df152020-04-13 15:55:14 -070093 ${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 Baker5d03e172020-04-10 14:56:20 -070096 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000097
98List 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 Baker5d03e172020-04-10 14:56:20 -0700101 ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1}
102 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000103
104List 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 Baker5d03e172020-04-10 14:56:20 -0700107 ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1}
108 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000109
110Subscribe 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 Baker5d03e172020-04-10 14:56:20 -0700113 ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1}
114 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000115
116Unsubscribe 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 Baker5d03e172020-04-10 14:56:20 -0700119 ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1}
120 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000121
122Validate 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 Baker5d03e172020-04-10 14:56:20 -0700125 ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1}
126 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000127
128*** Keywords ***
Scott Baker5d03e172020-04-10 14:56:20 -0700129Setup 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 Bakere0382b82020-05-01 14:53:45 -0700135 Run Keyword If ${use_kubernetes_install} Install Importer Using Kubernetes
Scott Baker5d03e172020-04-10 14:56:20 -0700136 Get IP AND PORT
137
138Teardown Suite
139 [Documentation] Clean up devices if desired
140 ... kills processes and cleans up interfaces on src+dst servers
Scott Bakere0382b82020-05-01 14:53:45 -0700141 Run Keyword If ${use_kubernetes_install} Clean Up Importer Using Kubernetes
Scott Baker5d03e172020-04-10 14:56:20 -0700142 Run Keyword If ${use_mock_redfish} Clean Up Mock Redfish Server
143
144Install Mock Redfish Server
Scott Bakere0382b82020-05-01 14:53:45 -0700145 [Documentation] Installs Redfish Importer and Demotest
146 Apply Kubernetes Resources ../../kubernetes/deploy-mock-olts.yaml default
Scott Baker105df152020-04-13 15:55:14 -0700147 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 Baker105df152020-04-13 15:55:14 -0700151 # 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 Baker5d03e172020-04-10 14:56:20 -0700154
Scott Bakere0382b82020-05-01 14:53:45 -0700155Install 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 Baker5d03e172020-04-10 14:56:20 -0700163Clean Up Mock Redfish Server
Scott Bakere0382b82020-05-01 14:53:45 -0700164 Delete Kubernetes Resources ../../kubernetes/deploy-mock-olts.yaml default
165
166Clean Up Importer Using Kubernetes
Scott Baker5d03e172020-04-10 14:56:20 -0700167 Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default
168
Ubuntuf45d1aa2020-02-06 07:01:44 +0000169Get IP AND PORT
Scott Baker105df152020-04-13 15:55:14 -0700170 ${num_addr}= Get Length ${ADDR_LIST}
171 ${multiple_olt}= Set Variable If ${num_addr}>1 True False
172 Set Suite Variable ${multiple_olt}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000173 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 Baker105df152020-04-13 15:55:14 -0700178 Run Keyword If ${multiple_olt} Get IP AND PORT Second OLT
179 ... ELSE Set No Second OLT
180
181Get IP AND PORT Second OLT
Ubuntuf45d1aa2020-02-06 07:01:44 +0000182 ${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 Baker5d03e172020-04-10 14:56:20 -0700186
Scott Baker105df152020-04-13 15:55:14 -0700187Set No Second OLT
188 Set Suite Variable ${IP2} None
189 Set Suite Variable ${PORT2} None
190
Scott Baker5d03e172020-04-10 14:56:20 -0700191Run 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
199Run Test On Host
200 [Arguments] ${testname} @{args}
201 ${output}= Run Process ${testname} @{args}
202 [Return] ${output.stdout}
203
204Run 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}