diff --git a/ansible/roles/test/files/ptftests/hash_test.py b/ansible/roles/test/files/ptftests/hash_test.py index 76735bf2c06..78a5137004e 100644 --- a/ansible/roles/test/files/ptftests/hash_test.py +++ b/ansible/roles/test/files/ptftests/hash_test.py @@ -84,12 +84,21 @@ def check_hash(self, hash_key): in_port = random.choice([port for port in self.src_ports if port not in exp_port_list]) hit_count_map = {} - for _ in range(0, self.BALANCING_TEST_TIMES): - logging.info("in_port: {}".format(in_port)) - (matched_index, _) = self.check_ip_route(hash_key, in_port, dst_ip, exp_port_list) - hit_count_map[matched_index] = hit_count_map.get(matched_index, 0) + 1 - logging.info("hit count map: {}".format(hit_count_map)) - self.check_balancing(next_hop.get_next_hop(), hit_count_map) + if hash_key == 'ingress-port': # The sample is too little for hash_key ingress-port, check it loose(just verify if the asic actually used the hash field as a load-balancing factor) + for in_port in [port for port in self.src_ports if port not in exp_port_list]: + logging.info("in_port: {}".format(in_port)) + (matched_index, _) = self.check_ip_route(hash_key, in_port, dst_ip, exp_port_list) + hit_count_map[matched_index] = hit_count_map.get(matched_index, 0) + 1 + logging.info("hit count map: {}".format(hit_count_map)) + assert True if len(hit_count_map.keys()) > 1 else False + else: + for _ in range(0, self.BALANCING_TEST_TIMES): + logging.info("in_port: {}".format(in_port)) + (matched_index, _) = self.check_ip_route(hash_key, in_port, dst_ip, exp_port_list) + hit_count_map[matched_index] = hit_count_map.get(matched_index, 0) + 1 + logging.info("hit count map: {}".format(hit_count_map)) + + self.check_balancing(next_hop.get_next_hop(), hit_count_map) def check_ip_route(self, hash_key, in_port, dst_ip, dst_port_list): if ip_network(unicode(dst_ip)).version == 4: diff --git a/tests/fib/test_fib.py b/tests/fib/test_fib.py index 3450b8f98c3..cbf4a3de57b 100644 --- a/tests/fib/test_fib.py +++ b/tests/fib/test_fib.py @@ -127,9 +127,6 @@ def setup_hash(self, testbed, duthost, ptfhost): self.hash_keys.remove('src-port') self.hash_keys.remove('dst-port') - # TODO - self.hash_keys.remove('ingress-port') - g_vars['testbed_type'] = testbed['topo']['name'] g_vars['router_mac'] = duthost.shell('sonic-cfggen -d -v \'DEVICE_METADATA.localhost.mac\'')["stdout_lines"][0].decode("utf-8")