Skip to content

Commit

Permalink
Added code to get parameterized maximum and minimum temperatures (son…
Browse files Browse the repository at this point in the history
…ic-net#5305 mannytaheri:test_thermal)

changed *key to key in get_thermal_temperature

Modified get_thermal_temperature to except on valuse as a key instead of a list
  • Loading branch information
mannytaheri authored and sanmalho-git committed Jul 22, 2022
1 parent b009417 commit e2c1cb7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/platform_tests/api/test_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def get_thermal_facts(self, duthost, thermal_idx, def_value, *keys):

return def_value

def get_thermal_temperature(self, duthost, def_value, key):
if duthost.facts.get("chassis"):
thermals_temperature = duthost.facts.get("chassis").get("thermal_temperature")
if thermals_temperature:
value = thermals_temperature.get(key)
if value is None:
return def_value
return value
return def_value

#
# Functions to test methods inherited from DeviceBase class
#
Expand Down Expand Up @@ -172,11 +182,14 @@ def test_get_minimum_recorded(self, duthosts, enum_rand_one_per_hwsku_hostname,
thermals_skipped += 1
continue

min_temperature = self.get_thermal_temperature(duthost, 0, "minimum")
max_temperature = self.get_thermal_temperature(duthost, 100, "maximum")

temperature = thermal.get_minimum_recorded(platform_api_conn, i)

if self.expect(temperature is not None, "Unable to retrieve Thermal {} temperature".format(i)):
if self.expect(isinstance(temperature, float), "Thermal {} temperature appears incorrect".format(i)):
self.expect(temperature > 0 and temperature <= 100,
self.expect(temperature > min_temperature and temperature <= max_temperature,
"Thermal {} temperature {} reading is not within range".format(i, temperature))

if thermals_skipped == self.num_thermals:
Expand All @@ -195,11 +208,14 @@ def test_get_maximum_recorded(self, duthosts, enum_rand_one_per_hwsku_hostname,
thermals_skipped += 1
continue

min_temperature = self.get_thermal_temperature(duthost, 0, "minimum")
max_temperature = self.get_thermal_temperature(duthost, 100, "maximum")

temperature = thermal.get_maximum_recorded(platform_api_conn, i)

if self.expect(temperature is not None, "Unable to retrieve Thermal {} temperature".format(i)):
if self.expect(isinstance(temperature, float), "Thermal {} temperature appears incorrect".format(i)):
self.expect(temperature > 0 and temperature <= 100,
self.expect(temperature > min_temperature and temperature <= max_temperature,
"Thermal {} temperature {} reading is not within range".format(i, temperature))

if thermals_skipped == self.num_thermals:
Expand Down

0 comments on commit e2c1cb7

Please sign in to comment.