From e2c1cb7a6fae9bd738ca79f4a6c9585a8fbb88f5 Mon Sep 17 00:00:00 2001 From: Manny Date: Fri, 4 Mar 2022 15:50:08 -0500 Subject: [PATCH] Added code to get parameterized maximum and minimum temperatures (#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 --- tests/platform_tests/api/test_thermal.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/platform_tests/api/test_thermal.py b/tests/platform_tests/api/test_thermal.py index 10090c161f30..488bd0f6a71e 100644 --- a/tests/platform_tests/api/test_thermal.py +++ b/tests/platform_tests/api/test_thermal.py @@ -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 # @@ -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: @@ -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: