blob: 389028b7d6c60c18bd0cfd60e10c9461e0c23542 [file] [log] [blame]
Ubuntuf45d1aa2020-02-06 07:01:44 +00001# Copyright 2018 Open Networking Foundation
mccd7e9502019-12-16 22:04:13 +00002#
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 ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000016Documentation Provide the function to perform funtional tests for the Redfish device-management project
Scott Baker5d03e172020-04-10 14:56:20 -070017Suite Setup Setup Suite
18Suite Teardown Teardown Suite
mccd7e9502019-12-16 22:04:13 +000019Library Process
20Library OperatingSystem
Ubuntuf45d1aa2020-02-06 07:01:44 +000021Library BuiltIn
22Library String
23Library Collections
Scott Baker5d03e172020-04-10 14:56:20 -070024Library ../../voltha-system-tests/libraries/DependencyLibrary.py
25Resource ../../voltha-system-tests/libraries/k8s.robot
Ubuntuf45d1aa2020-02-06 07:01:44 +000026
27*** Variables ***
28@{ADDR_LIST} 192.168.4.26:8888 192.168.4.27:8888
Scott Baker5d03e172020-04-10 14:56:20 -070029${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
mccd7e9502019-12-16 22:04:13 +000035
36*** Test Cases ***
Ubuntuf45d1aa2020-02-06 07:01:44 +000037Add 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 Baker5d03e172020-04-10 14:56:20 -070040 ${OUTPUT}= Run Test tests/add_device_to_monitor.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
41 Should Be Equal ${EXPECTED} ${OUTPUT}
mccd7e9502019-12-16 22:04:13 +000042
Ubuntuf45d1aa2020-02-06 07:01:44 +000043Clear 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 Baker5d03e172020-04-10 14:56:20 -070046 ${OUTPUT}= Run Test tests/clear_all_subscribed_events.tc ${IP1} ${PORT1}
47 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000048
49Configure 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 Baker5d03e172020-04-10 14:56:20 -070052 ${OUTPUT}= Run Test tests/configure_data_polling_interval.tc ${IP1} ${PORT1}
53 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000054
55Delete 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 Baker5d03e172020-04-10 14:56:20 -070058 ${OUTPUT}= Run Test tests/delete_monitored_device.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
59 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000060
61List 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 Baker5d03e172020-04-10 14:56:20 -070064 ${OUTPUT}= Run Test tests/list_device_monitored.tc ${IP1} ${PORT1} ${IP2} ${PORT2}
65 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000066
67List 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 Baker5d03e172020-04-10 14:56:20 -070070 ${OUTPUT}= Run Test tests/list_subscribed_events.tc ${IP1} ${PORT1}
71 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000072
73List 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 Baker5d03e172020-04-10 14:56:20 -070076 ${OUTPUT}= Run Test tests/list_supported_events.tc ${IP1} ${PORT1}
77 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000078
79Subscribe 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 Baker5d03e172020-04-10 14:56:20 -070082 ${OUTPUT}= Run Test tests/subscribe_events.tc ${IP1} ${PORT1}
83 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000084
85Unsubscribe 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 Baker5d03e172020-04-10 14:56:20 -070088 ${OUTPUT}= Run Test tests/unsubscribe_events.tc ${IP1} ${PORT1}
89 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000090
91Validate 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 Baker5d03e172020-04-10 14:56:20 -070094 ${OUTPUT}= Run Test tests/validate_ip.tc ${IP1} ${PORT1}
95 Should Be Equal ${EXPECTED} ${OUTPUT}
Ubuntuf45d1aa2020-02-06 07:01:44 +000096
97*** Keywords ***
Scott Baker5d03e172020-04-10 14:56:20 -070098Setup 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
106Teardown 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
111Install 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
118Clean Up Mock Redfish Server
119 Delete Kubernetes Resources ../../kubernetes/deploy-redfish-importer.yaml default
120
Ubuntuf45d1aa2020-02-06 07:01:44 +0000121Get 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 Baker5d03e172020-04-10 14:56:20 -0700131
132Run 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
140Run Test On Host
141 [Arguments] ${testname} @{args}
142 ${output}= Run Process ${testname} @{args}
143 [Return] ${output.stdout}
144
145Run 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}