blob: 749aa9882643596471abac4500579f7a884a6921 [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
39# use_mock_redfish: If true, mock redfish OLTs will be used instead of a
40# physical device. Default: False.
Scott Baker5d03e172020-04-10 14:56:20 -070041${use_mock_redfish} False
Scott Baker105df152020-04-13 15:55:14 -070042
43# use_Containerized_dm: If true, then dm will be run from inside the
44# demo-test container. Default: False.
Scott Baker5d03e172020-04-10 14:56:20 -070045${use_containerized_dm} False
Scott Baker105df152020-04-13 15:55:14 -070046
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 Baker5d03e172020-04-10 14:56:20 -070050${voltha_suite_setup} False
Scott Baker105df152020-04-13 15:55:14 -070051
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 Baker5d03e172020-04-10 14:56:20 -070055${IMPORTER_POD_NAME} redfish-importer
56${DEMOTEST_POD_NAME} redfish-demotest
Scott Baker105df152020-04-13 15:55:14 -070057${MOCK1_POD_NAME} mock-olt-1
58${MOCK2_POD_NAME} mock-olt-2
mccd7e9502019-12-16 22:04:13 +000059
60*** Test Cases ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000061Add Device to Monitor
62 [Documentation] This test case excercises the API, SendDeviceList, which registers Redfish devices to monitor.
Scott Baker105df152020-04-13 15:55:14 -070063 ${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 Baker5d03e172020-04-10 14:56:20 -070066 Should Be Equal ${EXPECTED} ${OUTPUT}
mccd7e9502019-12-16 22:04:13 +000067
Ubuntuf45d1aa2020-02-06 07:01:44 +000068Clear 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 Baker5d03e172020-04-10 14:56:20 -070071 ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1}
72 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000073
74Configure 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 Baker5d03e172020-04-10 14:56:20 -070077 ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1}
78 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000079
80Delete Monitored Device
81 [Documentation] This test case excercises the API, DeleteDeviceList, which deletes Redfish devices being monitored.
Scott Baker105df152020-04-13 15:55:14 -070082 ${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 Baker5d03e172020-04-10 14:56:20 -070085 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000086
87List Devices monitored
88 [Documentation] This test case excercises the API, GetCurrentDevices, which lists all Redfish devices being monitored.
Scott Baker105df152020-04-13 15:55:14 -070089 ${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 Baker5d03e172020-04-10 14:56:20 -070092 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000093
94List 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 Baker5d03e172020-04-10 14:56:20 -070097 ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1}
98 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000099
100List 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 Baker5d03e172020-04-10 14:56:20 -0700103 ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1}
104 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000105
106Subscribe 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 Baker5d03e172020-04-10 14:56:20 -0700109 ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1}
110 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000111
112Unsubscribe 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 Baker5d03e172020-04-10 14:56:20 -0700115 ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1}
116 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000117
118Validate 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 Baker5d03e172020-04-10 14:56:20 -0700121 ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1}
122 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000123
124*** Keywords ***
Scott Baker5d03e172020-04-10 14:56:20 -0700125Setup 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
133Teardown 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
138Install Mock Redfish Server
Scott Baker105df152020-04-13 15:55:14 -0700139 [Documentation] Installs mock OLTS, redfish importer, demo-test
Scott Baker5d03e172020-04-10 14:56:20 -0700140 Apply Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default
Scott Baker105df152020-04-13 15:55:14 -0700141 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 Baker5d03e172020-04-10 14:56:20 -0700146 ... Validate Pod Status ${IMPORTER_POD_NAME} default Running
Scott Baker105df152020-04-13 15:55:14 -0700147 Wait Until Keyword Succeeds ${pod_timeout} 5s
Scott Baker5d03e172020-04-10 14:56:20 -0700148 ... Validate Pod Status ${DEMOTEST_POD_NAME} default Running
Scott Baker105df152020-04-13 15:55:14 -0700149 # 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 Baker5d03e172020-04-10 14:56:20 -0700152
153Clean Up Mock Redfish Server
154 Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default
155
Ubuntuf45d1aa2020-02-06 07:01:44 +0000156Get IP AND PORT
Scott Baker105df152020-04-13 15:55:14 -0700157 ${num_addr}= Get Length ${ADDR_LIST}
158 ${multiple_olt}= Set Variable If ${num_addr}>1 True False
159 Set Suite Variable ${multiple_olt}
Ubuntuf45d1aa2020-02-06 07:01:44 +0000160 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 Baker105df152020-04-13 15:55:14 -0700165 Run Keyword If ${multiple_olt} Get IP AND PORT Second OLT
166 ... ELSE Set No Second OLT
167
168Get IP AND PORT Second OLT
Ubuntuf45d1aa2020-02-06 07:01:44 +0000169 ${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 Baker5d03e172020-04-10 14:56:20 -0700173
Scott Baker105df152020-04-13 15:55:14 -0700174Set No Second OLT
175 Set Suite Variable ${IP2} None
176 Set Suite Variable ${PORT2} None
177
Scott Baker5d03e172020-04-10 14:56:20 -0700178Run 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
186Run Test On Host
187 [Arguments] ${testname} @{args}
188 ${output}= Run Process ${testname} @{args}
189 [Return] ${output.stdout}
190
191Run 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}