Skip to content

Commit 8f52f49

Browse files
committed
Push for coverage
1 parent f2694f9 commit 8f52f49

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

tests/test_redfish.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,113 @@ def test_get_rack_bad(self, mock_connector):
228228
msg="Chassis type Sled does not match that of a Rack"):
229229
rf.get_rack("/redfish/v1/Chassis/Sled-1-2-1")
230230

231+
def test_server_stats_inventory(self, mock_connector):
232+
rf = self.mock_redfish_system(mock_connector, data={
233+
"/redfish/v1/Systems/System-1-2-1-1": {
234+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1",
235+
"Description": "A server",
236+
"Id": "System-1-2-1-1",
237+
"Manufacturer": "Dell Inc.",
238+
"MemorySummary": {
239+
"TotalSystemMemoryGiB": 32,
240+
},
241+
"Name": "System",
242+
"PowerState": "On",
243+
"Processors": {
244+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1/Processors"
245+
},
246+
"SerialNumber": "945hjf0927mf",
247+
},
248+
"/redfish/v1/Systems/System-1-2-1-1/Processors": {
249+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1/Processors",
250+
"Members": [{
251+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1/Processors/CPU.Socket.1"
252+
}],
253+
},
254+
"/redfish/v1/Systems/System-1-2-1-1/Processors/CPU.Socket.1": {
255+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1/Processors/CPU.Socket.1",
256+
"InstructionSet": [{
257+
"Member": "x86-64"
258+
}],
259+
"TotalCores": 20,
260+
}
261+
})
262+
physical_server = mock.Mock()
263+
physical_server.ems_ref = "/redfish/v1/Systems/System-1-2-1-1"
264+
requested_stats = ["cores_capacity", "memory_capacity",
265+
# "num_network_devices", "num_storage_devices"
266+
]
267+
requested_inventory = ["power_state"]
268+
self.assertEqual(rf.server_stats(physical_server, requested_stats),
269+
{"cores_capacity": 20, "memory_capacity": 32768})
270+
self.assertEqual(rf.server_inventory(physical_server, requested_inventory),
271+
{"power_state": "on"})
272+
273+
def test_rack_stats_inventory(self, mock_connector):
274+
rf = self.mock_redfish_system(mock_connector, data={
275+
"/redfish/v1/Chassis/Rack-1": {
276+
"@odata.id": "/redfish/v1/Chassis/Rack-1",
277+
"ChassisType": "Rack",
278+
"Description": "Redfish Rack",
279+
"Id": "Rack-1",
280+
"IndicatorLED": "Blinking",
281+
"Links": {
282+
"ComputerSystems": [
283+
{
284+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1"
285+
}
286+
]
287+
},
288+
"Manufacturer": "Dell",
289+
"Name": "G5_Rack",
290+
"SerialNumber": "1ABC",
291+
}
292+
})
293+
physical_rack = mock.Mock()
294+
physical_rack.ems_ref = "/redfish/v1/Chassis/Rack-1"
295+
# TODO: check integration_tests/cfme/physical/phsyical_rack.py
296+
requested_stats = []
297+
requested_inventory = ["rack_name"]
298+
self.assertEqual(rf.rack_stats(physical_rack, requested_stats),
299+
{})
300+
self.assertEqual(rf.rack_inventory(physical_rack, requested_inventory),
301+
{"rack_name": "Rack-1"})
302+
303+
def test_chassis_stats_inventory(self, mock_connector):
304+
rf = self.mock_redfish_system(mock_connector, data={
305+
"/redfish/v1/Chassis/Sled-1-2-1": {
306+
"@odata.id": "/redfish/v1/Chassis/Sled-1-2-1",
307+
"ChassisType": "Sled",
308+
"Description": "G5 Sled-Level Enclosure",
309+
"Id": "Sled-1-2-1",
310+
"IndicatorLED": "Blinking",
311+
"Links": {
312+
"ComputerSystems": [
313+
{
314+
"@odata.id": "/redfish/v1/Systems/System-1-2-1-1"
315+
},
316+
{
317+
"@odata.id": "/redfish/v1/Systems/System-1-1-2-2"
318+
}
319+
]
320+
},
321+
"Manufacturer": "Dell",
322+
"Name": "G5_Sled",
323+
"SerialNumber": "5555A",
324+
}
325+
})
326+
phsyical_chassis = mock.Mock()
327+
phsyical_chassis.ems_ref = "/redfish/v1/Chassis/Sled-1-2-1"
328+
# TODO: check integration_tests/cfme/physical/phsyical_chassis.py
329+
requested_stats = ["num_physical_servers"]
330+
requested_inventory = ["chassis_name", "description", "identify_led_state"]
331+
self.assertEqual(rf.chassis_stats(phsyical_chassis, requested_stats),
332+
{"num_physical_servers": 2})
333+
self.assertEqual(rf.chassis_inventory(phsyical_chassis, requested_inventory),
334+
{"chassis_name": "Dell G5_Sled (5555A)",
335+
"description": "G5 Sled-Level Enclosure",
336+
"identify_led_state": "Blinking"})
337+
231338

232339
@mock.patch("redfish_client.Connector")
233340
class TestRedfishServer(RedfishTestCase):

0 commit comments

Comments
 (0)