|
14 | 14 |
|
15 | 15 | from tests.common.fixtures.ptfhost_utils import ptf_portmap_file # noqa F401 |
16 | 16 | from tests.common.helpers.assertions import pytest_assert, pytest_require |
| 17 | +from tests.common.helpers.multi_thread_utils import SafeThreadPoolExecutor |
17 | 18 | from tests.common.mellanox_data import is_mellanox_device as isMellanoxDevice |
18 | 19 | from tests.common.cisco_data import is_cisco_device |
19 | 20 | from tests.common.dualtor.dual_tor_utils import upper_tor_host, lower_tor_host, dualtor_ports, is_tunnel_qos_remap_enabled # noqa F401 |
@@ -590,13 +591,18 @@ def swapSyncd_on_selected_duts(self, request, duthosts, creds, tbinfo, lower_tor |
590 | 591 | new_creds['docker_registry_password'] = '' |
591 | 592 | else: |
592 | 593 | new_creds = creds |
593 | | - for duthost in dut_list: |
594 | | - docker.swap_syncd(duthost, new_creds) |
| 594 | + |
| 595 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 596 | + for duthost in dut_list: |
| 597 | + executor.submit(docker.swap_syncd, duthost, new_creds) |
| 598 | + |
595 | 599 | yield |
| 600 | + |
596 | 601 | finally: |
597 | 602 | if swapSyncd: |
598 | | - for duthost in dut_list: |
599 | | - docker.restore_default_syncd(duthost, new_creds) |
| 603 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 604 | + for duthost in dut_list: |
| 605 | + executor.submit(docker.restore_default_syncd, duthost, new_creds) |
600 | 606 |
|
601 | 607 | @pytest.fixture(scope='class', name="select_src_dst_dut_and_asic", |
602 | 608 | params=["single_asic", "single_dut_multi_asic", |
@@ -1414,23 +1420,31 @@ def updateDockerService(host, docker="", action="", service=""): # noqa: F811 |
1414 | 1420 | upper_tor_host, testcase="test_qos_sai", feature_list=feature_list) |
1415 | 1421 |
|
1416 | 1422 | disable_container_autorestart(src_dut, testcase="test_qos_sai", feature_list=feature_list) |
1417 | | - for service in src_services: |
1418 | | - updateDockerService(src_dut, action="stop", **service) |
| 1423 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 1424 | + for service in src_services: |
| 1425 | + executor.submit(updateDockerService, src_dut, action="stop", **service) |
| 1426 | + |
1419 | 1427 | src_dut.shell("sudo config bgp shutdown all") |
1420 | 1428 | if src_asic != dst_asic: |
1421 | 1429 | disable_container_autorestart(dst_dut, testcase="test_qos_sai", feature_list=feature_list) |
1422 | | - for service in dst_services: |
1423 | | - updateDockerService(dst_dut, action="stop", **service) |
| 1430 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 1431 | + for service in dst_services: |
| 1432 | + executor.submit(updateDockerService, dst_dut, action="stop", **service) |
| 1433 | + |
1424 | 1434 | dst_dut.shell("sudo config bgp shutdown all") |
1425 | 1435 |
|
1426 | 1436 | yield |
1427 | 1437 |
|
1428 | | - for service in src_services: |
1429 | | - updateDockerService(src_dut, action="start", **service) |
| 1438 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 1439 | + for service in src_services: |
| 1440 | + executor.submit(updateDockerService, src_dut, action="start", **service) |
| 1441 | + |
1430 | 1442 | src_dut.shell("sudo config bgp start all") |
1431 | 1443 | if src_asic != dst_asic: |
1432 | | - for service in dst_services: |
1433 | | - updateDockerService(dst_dut, action="start", **service) |
| 1444 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 1445 | + for service in dst_services: |
| 1446 | + executor.submit(updateDockerService, dst_dut, action="start", **service) |
| 1447 | + |
1434 | 1448 | dst_dut.shell("sudo config bgp start all") |
1435 | 1449 |
|
1436 | 1450 | """ Start mux conatiner for dual ToR """ |
@@ -1909,9 +1923,13 @@ def dut_disable_ipv6(self, duthosts, tbinfo, lower_tor_host, swapSyncd_on_select |
1909 | 1923 | logger.info("Adding docker0's IPv6 address since it was removed when disabing IPv6") |
1910 | 1924 | duthost.shell("ip -6 addr add {} dev docker0".format(all_docker0_ipv6_addrs[duthost.hostname])) |
1911 | 1925 |
|
1912 | | - # TODO: parallelize this step.. Do we really need this ? |
1913 | | - for duthost in dut_list: |
1914 | | - config_reload(duthost, config_source='config_db', safe_reload=True, check_intf_up_ports=True) |
| 1926 | + # TODO: Do we really need this ? |
| 1927 | + with SafeThreadPoolExecutor(max_workers=8) as executor: |
| 1928 | + for duthost in dut_list: |
| 1929 | + executor.submit( |
| 1930 | + config_reload, |
| 1931 | + duthost, config_source='config_db', safe_reload=True, check_intf_up_ports=True, |
| 1932 | + ) |
1915 | 1933 |
|
1916 | 1934 | @pytest.fixture(scope='class', autouse=True) |
1917 | 1935 | def sharedHeadroomPoolSize( |
|
0 commit comments