blob: 516a51ee5c207a3bcfd3e02b65b301272874c1d9 [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 Baker5d03e172020-04-10 14:56:20 -070030${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
mccd7e9502019-12-16 22:04:13 +000036
37*** Test Cases ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000038Add 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 Baker5d03e172020-04-10 14:56:20 -070041 ${OUTPUT}= Run Test tests/add_device_to_monitor.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
42 Should Be Equal ${EXPECTED} ${OUTPUT}
mccd7e9502019-12-16 22:04:13 +000043
Ubuntuf45d1aa2020-02-06 07:01:44 +000044Clear 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 Baker5d03e172020-04-10 14:56:20 -070047 ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1}
48 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000049
50Configure 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 Baker5d03e172020-04-10 14:56:20 -070053 ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1}
54 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000055
56Delete 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 Baker5d03e172020-04-10 14:56:20 -070059 ${OUTPUT}= Run Test tests/delete_monitored_device.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
60 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000061
62List 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 Baker5d03e172020-04-10 14:56:20 -070065 ${OUTPUT}= Run Test tests/list_device_monitored.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
66 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000067
68List 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 Baker5d03e172020-04-10 14:56:20 -070071 ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1}
72 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000073
74List 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 Baker5d03e172020-04-10 14:56:20 -070077 ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1}
78 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000079
80Subscribe 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 Baker5d03e172020-04-10 14:56:20 -070083 ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1}
84 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000085
86Unsubscribe 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 Baker5d03e172020-04-10 14:56:20 -070089 ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1}
90 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000091
92Validate 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 Baker5d03e172020-04-10 14:56:20 -070095 ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1}
96 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000097
98*** Keywords ***
Scott Baker5d03e172020-04-10 14:56:20 -070099Setup 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
107Teardown 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
112Install 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
119Clean Up Mock Redfish Server
120 Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default
121
Ubuntuf45d1aa2020-02-06 07:01:44 +0000122Get 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 Baker5d03e172020-04-10 14:56:20 -0700132
133Run 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
141Run Test On Host
142 [Arguments] ${testname} @{args}
143 ${output}= Run Process ${testname} @{args}
144 [Return] ${output.stdout}
145
146Run 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}