def test_temperature(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): ''' PSU temperature test ''' for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) if name in self.psu_skip_list: logger.info("skipping check for {}".format(name)) else: temperature = psu.get_temperature(platform_api_conn, psu_id) if self.expect( temperature is not None, "Failed to retrieve temperature of PSU {}".format( psu_id)): self.expect( isinstance(temperature, float), "PSU {} temperature appears incorrect".format(psu_id)) temp_threshold = psu.get_temperature_high_threshold( platform_api_conn, psu_id) if self.expect( temp_threshold is not None, "Failed to retrieve temperature threshold of PSU {}". format(psu_id)): if self.expect( isinstance(temp_threshold, float), "PSU {} temperature high threshold appears incorrect" .format(psu_id)): self.expect( temperature < temp_threshold, "Temperature {} of PSU {} is over the threshold {}" .format(temperature, psu_id, temp_threshold)) self.assert_expectations()
def test_get_name(self, duthost, localhost, platform_api_conn): for i in range(self.num_psus): name = psu.get_name(platform_api_conn, i) if self.expect(name is not None, "Unable to retrieve PSU {} name".format(i)): self.expect(isinstance(name, STRING_TYPE), "PSU {} name appears incorrect".format(i)) self.compare_value_with_platform_facts('name', name, i) self.assert_expectations()
def test_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): ''' PSU status led test ''' duthost = duthosts[enum_rand_one_per_hwsku_hostname] FAULT_LED_COLOR_LIST = [STATUS_LED_COLOR_AMBER, STATUS_LED_COLOR_RED] NORMAL_LED_COLOR_LIST = [STATUS_LED_COLOR_GREEN] OFF_LED_COLOR_LIST = [STATUS_LED_COLOR_OFF] LED_COLOR_TYPES = [] LED_COLOR_TYPES.append(FAULT_LED_COLOR_LIST) LED_COLOR_TYPES.append(NORMAL_LED_COLOR_LIST) # Mellanox is not supporting set leds to 'off' if duthost.facts.get("asic_type") != "mellanox": LED_COLOR_TYPES.append(OFF_LED_COLOR_LIST) LED_COLOR_TYPES_DICT = {0: "fault", 1: "normal", 2: "off"} for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) if name in self.psu_skip_list: logger.info("skipping check for {}".format(name)) else: for index, led_type in enumerate(LED_COLOR_TYPES): led_type_result = False for color in led_type: result = psu.set_status_led(platform_api_conn, psu_id, color) if self.expect( result is not None, "Failed to perform set_status_led of PSU {}". format(psu_id)): led_type_result = result or led_type_result if ((result is None) or (not result)): continue color_actual = psu.get_status_led( platform_api_conn, psu_id) if self.expect( color_actual is not None, "Failed to retrieve status_led of PSU {}". format(psu_id)): if self.expect( isinstance(color_actual, STRING_TYPE), "PSU {} status LED color appears incorrect" .format(psu_id)): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {}) from PSU {}" .format(color, color_actual, psu_id)) self.expect( led_type_result is True, "Failed to set status_led of PSU {} to {}".format( psu_id, LED_COLOR_TYPES_DICT[index])) self.assert_expectations()
def test_master_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): duthost = duthosts[enum_rand_one_per_hwsku_hostname] FAULT_LED_COLOR_LIST = [STATUS_LED_COLOR_AMBER, STATUS_LED_COLOR_RED] NORMAL_LED_COLOR_LIST = [STATUS_LED_COLOR_GREEN] OFF_LED_COLOR_LIST = [STATUS_LED_COLOR_OFF] LED_COLOR_TYPES = [] LED_COLOR_TYPES.append(FAULT_LED_COLOR_LIST) LED_COLOR_TYPES.append(NORMAL_LED_COLOR_LIST) LED_COLOR_TYPES.append(OFF_LED_COLOR_LIST) LED_COLOR_TYPES_DICT = {0: "fault", 1: "normal", 2: "off"} if self.num_psus == 0: pytest.skip( "No psus found on device skipping for device {}".format( duthost)) for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) if name in self.psu_skip_list: continue for index, led_type in enumerate(LED_COLOR_TYPES): led_type_result = False for color in led_type: result = psu.set_status_master_led(platform_api_conn, psu_id, color) if self.expect(result is not None, "Failed to perform set master LED"): led_type_result = result or led_type_result if ((result is None) or (not result)): continue color_actual = psu.get_status_master_led( platform_api_conn, psu_id) if self.expect(color_actual is not None, "Failed to retrieve status_led master led"): if self.expect( isinstance(color_actual, STRING_TYPE), "Status of master LED color appears incorrect" ): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {}) for master led" .format(color, color_actual)) self.expect( led_type_result is True, "Failed to set status_led of master LED to {}".format( LED_COLOR_TYPES_DICT[index])) self.assert_expectations()
def test_get_presence(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): for i in range(self.num_psus): presence = psu.get_presence(platform_api_conn, i) name = psu.get_name(platform_api_conn, i) if self.expect(presence is not None, "Unable to retrieve PSU {} presence".format(i)): if self.expect(isinstance(presence, bool), "PSU {} presence appears incorrect".format(i)): if name in self.psu_skip_list: self.expect(presence is False, "PSU {} in skip_modules inventory got presence True expected False".format(i)) else: self.expect(presence is True, "PSU {} is not present".format(i)) self.assert_expectations()
def test_temperature(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): ''' PSU temperature test ''' duthost = duthosts[enum_rand_one_per_hwsku_hostname] skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["arista"]) psus_skipped = 0 for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) if name in self.psu_skip_list: logger.info("skipping check for {}".format(name)) else: temperature_supported = self.get_psu_facts( duthost, psu_id, True, "temperature") if not temperature_supported: logger.info( "test_set_fans_speed: Skipping chassis fan {} (speed not controllable)" .format(psu_id)) psus_skipped += 1 continue temperature = psu.get_temperature(platform_api_conn, psu_id) if self.expect( temperature is not None, "Failed to retrieve temperature of PSU {}".format( psu_id)): self.expect( isinstance(temperature, float), "PSU {} temperature appears incorrect".format(psu_id)) temp_threshold = psu.get_temperature_high_threshold( platform_api_conn, psu_id) if self.expect( temp_threshold is not None, "Failed to retrieve temperature threshold of PSU {}". format(psu_id)): if self.expect( isinstance(temp_threshold, float), "PSU {} temperature high threshold appears incorrect" .format(psu_id)): self.expect( temperature < temp_threshold, "Temperature {} of PSU {} is over the threshold {}" .format(temperature, psu_id, temp_threshold)) if psus_skipped == self.num_psus: pytest.skip( "skipped as all chassis psus' temperature sensor is not supported" ) self.assert_expectations()
def test_power(self, duthost, localhost, platform_api_conn): ''' PSU power test ''' duthost = duthosts[enum_rand_one_per_hwsku_hostname] skip_release_for_platform(duthost, ["202012", "201911", "201811"], ["arista"]) for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) if name in self.psu_skip_list: logger.info("skipping check for {}".format(name)) else: voltage = psu.get_voltage(platform_api_conn, psu_id) if self.expect(voltage is not None, "Failed to retrieve voltage of PSU {}".format(psu_id)): self.expect(isinstance(voltage, float), "PSU {} voltage appears incorrect".format(psu_id)) current = psu.get_current(platform_api_conn, psu_id) if self.expect(current is not None, "Failed to retrieve current of PSU {}".format(psu_id)): self.expect(isinstance(current, float), "PSU {} current appears incorrect".format(psu_id)) power = psu.get_power(platform_api_conn, psu_id) if self.expect(power is not None, "Failed to retrieve power of PSU {}".format(psu_id)): self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id)) max_supp_power = psu.get_maximum_supplied_power(platform_api_conn, psu_id) if self.expect(max_supp_power is not None, "Failed to retrieve maximum supplied power power of PSU {}".format(psu_id)): self.expect(isinstance(power, float), "PSU {} power appears incorrect".format(psu_id)) if current is not None and voltage is not None and power is not None: self.expect(abs(power - (voltage*current)) < power*0.1, "PSU {} reading does not make sense \ (power:{}, voltage:{}, current:{})".format(psu_id, power, voltage, current)) powergood_status = psu.get_powergood_status(platform_api_conn, psu_id) if self.expect(powergood_status is not None, "Failed to retrieve operational status of PSU {}".format(psu_id)): self.expect(powergood_status is True, "PSU {} is not operational".format(psu_id)) high_threshold = psu.get_voltage_high_threshold(platform_api_conn, psu_id) if self.expect(high_threshold is not None, "Failed to retrieve the high voltage threshold of PSU {}".format(psu_id)): self.expect(isinstance(high_threshold, float), "PSU {} voltage high threshold appears incorrect".format(psu_id)) low_threshold = psu.get_voltage_low_threshold(platform_api_conn, psu_id) if self.expect(low_threshold is not None, "Failed to retrieve the low voltage threshold of PSU {}".format(psu_id)): self.expect(isinstance(low_threshold, float), "PSU {} voltage low threshold appears incorrect".format(psu_id)) if high_threshold is not None and low_threshold is not None: self.expect(voltage < high_threshold and voltage > low_threshold, "Voltage {} of PSU {} is not in between {} and {}".format(voltage, psu_id, low_threshold, high_threshold)) self.assert_expectations()
def test_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): ''' PSU status led test ''' duthost = duthosts[enum_rand_one_per_hwsku_hostname] FAULT_LED_COLOR_LIST = [STATUS_LED_COLOR_AMBER, STATUS_LED_COLOR_RED] NORMAL_LED_COLOR_LIST = [STATUS_LED_COLOR_GREEN] OFF_LED_COLOR_LIST = [STATUS_LED_COLOR_OFF] LED_COLOR_TYPES = [] LED_COLOR_TYPES.append(FAULT_LED_COLOR_LIST) LED_COLOR_TYPES.append(NORMAL_LED_COLOR_LIST) # Mellanox is not supporting set leds to 'off' if duthost.facts.get("asic_type") != "mellanox": LED_COLOR_TYPES.append(OFF_LED_COLOR_LIST) LED_COLOR_TYPES_DICT = {0: "fault", 1: "normal", 2: "off"} psus_skipped = 0 for psu_id in range(self.num_psus): name = psu.get_name(platform_api_conn, psu_id) led_support = duthost.facts.get("chassis").get("psus")[psu_id].get( "led") if led_support == "N/A": logger.info("led not supported for this psu {}".format(name)) elif name in self.psu_skip_list: logger.info("skipping check for {}".format(name)) psus_skipped += 1 else: led_controllable = self.get_psu_facts(duthost, psu_id, True, "status_led", "controllable") led_supported_colors = self.get_psu_facts( duthost, psu_id, None, "status_led", "colors") if led_controllable: led_type_skipped = 0 for index, led_type in enumerate(LED_COLOR_TYPES): if led_supported_colors: led_type = set(led_type) & set( led_supported_colors) if not led_type: logger.warning( "test_status_led: Skipping PSU {} set status_led to {} (No supported colors)" .format(psu_id, LED_COLOR_TYPES_DICT[index])) led_type_skipped += 1 continue led_type_result = False for color in led_type: result = psu.set_status_led( platform_api_conn, psu_id, color) if self.expect( result is not None, "Failed to perform set_status_led of PSU {}" .format(psu_id)): led_type_result = result or led_type_result if ((result is None) or (not result)): continue color_actual = psu.get_status_led( platform_api_conn, psu_id) if self.expect( color_actual is not None, "Failed to retrieve status_led of PSU {}". format(psu_id)): if self.expect( isinstance(color_actual, STRING_TYPE), "PSU {} status LED color appears incorrect" .format(psu_id)): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {}) from PSU {}" .format(color, color_actual, psu_id)) self.expect( led_type_result is True, "Failed to set status_led of PSU {} to {}".format( psu_id, LED_COLOR_TYPES_DICT[index])) if led_type_skipped == len(LED_COLOR_TYPES): logger.info( "test_status_led: Skipping PSU {} (no supported colors for all types)" .format(psu_id)) psus_skipped += 1 else: logger.info( "test_status_led: Skipping PSU {} (LED is not controllable)" .format(psu_id)) psus_skipped += 1 if psus_skipped == self.num_psus: pytest.skip( "skipped as all PSUs' LED is not controllable/no supported colors/in skip list" ) self.assert_expectations()
def test_get_name(self, duthost, localhost, platform_api_conn): for i in range(self.num_psus): name = psu.get_name(platform_api_conn, i) if self.expect(name is not None, "Unable to retrieve PSU {} name".format(i)): self.expect(isinstance(name, str), "PSU {} name appears incorrect".format(i)) self.assert_expectations()