diff --git a/test/case/containers/internal_link/test.py b/test/case/containers/internal_link/test.py index 24ea7e1f1..21a119995 100755 --- a/test/case/containers/internal_link/test.py +++ b/test/case/containers/internal_link/test.py @@ -19,7 +19,7 @@ """ import infamy -from infamy.util import until +from infamy.util import parallel, until # Regression test for #941: previously, when both ends of a pair were # assigned to a container, neither side created the pair. @@ -30,8 +30,8 @@ with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) if not target.has_model("infix-containers"): test.skip() diff --git a/test/case/containers/upgrade/test.py b/test/case/containers/upgrade/test.py index 5e13ba982..a5b72354a 100755 --- a/test/case/containers/upgrade/test.py +++ b/test/case/containers/upgrade/test.py @@ -14,7 +14,7 @@ import time import infamy import infamy.file_server as srv -from infamy.util import until +from infamy.util import parallel, until SRVPORT = 8008 SRVDIR = "/srv" @@ -24,8 +24,8 @@ with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) if not target.has_model("infix-containers"): test.skip() diff --git a/test/case/containers/volume/test.py b/test/case/containers/volume/test.py index b4c752f2e..599713177 100755 --- a/test/case/containers/volume/test.py +++ b/test/case/containers/volume/test.py @@ -7,7 +7,7 @@ """ import infamy -from infamy.util import until, curl +from infamy.util import curl, parallel, until with infamy.Test() as test: NAME = "web-volume" @@ -16,8 +16,8 @@ with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) addr = target.get_mgmt_ip() URL = f"http://[{addr}]:{PORT}/index.html" diff --git a/test/case/dhcp/client6_basic/test.py b/test/case/dhcp/client6_basic/test.py index e06b011f1..45818bf0a 100755 --- a/test/case/dhcp/client6_basic/test.py +++ b/test/case/dhcp/client6_basic/test.py @@ -7,6 +7,7 @@ """ import infamy +from infamy.util import parallel import infamy.dhcp import infamy.iface as iface import infamy.route as route @@ -33,8 +34,8 @@ def check_dns_resolution(): with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - client = env.attach("client", "mgmt") - tgtssh = env.attach("client", "mgmt", "ssh") + client, tgtssh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh")) _, host = env.ltop.xlate("host", "data") _, port = env.ltop.xlate("client", "data") diff --git a/test/case/dhcp/client6_prefix_delegation/test.py b/test/case/dhcp/client6_prefix_delegation/test.py index 3eb1d23d9..c89cb287e 100755 --- a/test/case/dhcp/client6_prefix_delegation/test.py +++ b/test/case/dhcp/client6_prefix_delegation/test.py @@ -9,7 +9,7 @@ import infamy, infamy.dhcp import infamy.iface as iface -from infamy.util import until +from infamy.util import parallel, until import time @@ -38,8 +38,8 @@ def checklog(dut): with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - client = env.attach("client", "mgmt") - tgtssh = env.attach("client", "mgmt", "ssh") + client, tgtssh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh")) _, host = env.ltop.xlate("host", "data") _, port = env.ltop.xlate("client", "data") diff --git a/test/case/dhcp/client6_slaac_ra/test.py b/test/case/dhcp/client6_slaac_ra/test.py index 09385d8a1..c90ffddcf 100755 --- a/test/case/dhcp/client6_slaac_ra/test.py +++ b/test/case/dhcp/client6_slaac_ra/test.py @@ -17,7 +17,7 @@ import infamy import infamy.dhcp import infamy.iface as iface -from infamy.util import until +from infamy.util import parallel, until def checkrun(dut): @@ -47,8 +47,8 @@ def check_slaac_address(): with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - client = env.attach("client", "mgmt") - tgtssh = env.attach("client", "mgmt", "ssh") + client, tgtssh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh")) _, host = env.ltop.xlate("host", "data") _, port = env.ltop.xlate("client", "data") diff --git a/test/case/dhcp/client_hostname_resend/test.py b/test/case/dhcp/client_hostname_resend/test.py index dceb89cc2..bd346d83b 100755 --- a/test/case/dhcp/client_hostname_resend/test.py +++ b/test/case/dhcp/client_hostname_resend/test.py @@ -13,7 +13,7 @@ """ import infamy -from infamy.util import until +from infamy.util import parallel, until def udhcpc_cmdline(ssh, ifname): @@ -40,8 +40,8 @@ def running_hostname(ssh, ifname): with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - client = env.attach("client", "mgmt") - clissh = env.attach("client", "mgmt", "ssh") + client, clissh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh")) _, port = env.ltop.xlate("client", "mgmt") with test.step(f"Configure initial hostname '{HOSTNM_A}'"): diff --git a/test/case/dhcp/server_basic/test.py b/test/case/dhcp/server_basic/test.py index 094f9c86d..24e528d1a 100755 --- a/test/case/dhcp/server_basic/test.py +++ b/test/case/dhcp/server_basic/test.py @@ -11,7 +11,7 @@ import infamy import infamy.iface as iface import infamy.route as route -from infamy.util import until +from infamy.util import parallel, until def verify_hostname(dut, hostname): @@ -30,8 +30,8 @@ def verify_hostname(dut, hostname): HOSTNM2 = 'client' with test.step("Set up topology and attach to client and server DUTs"): env = infamy.Env() - client = env.attach("client", "mgmt") - server = env.attach("server", "mgmt") + client, server = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("server", "mgmt")) with test.step("Configure DHCP server and client's hostname"): server.put_config_dicts({ diff --git a/test/case/dhcp/server_host/test.py b/test/case/dhcp/server_host/test.py index 03187716a..7c370e2a5 100755 --- a/test/case/dhcp/server_host/test.py +++ b/test/case/dhcp/server_host/test.py @@ -9,7 +9,7 @@ import infamy import infamy.iface as iface import infamy.route as route -from infamy.util import until +from infamy.util import parallel, until with infamy.Test() as test: @@ -28,9 +28,9 @@ with test.step("Set up topology and attach to client and server DUTs"): env = infamy.Env() - server = env.attach("server", "mgmt") - client1 = env.attach("client1", "mgmt") - client2 = env.attach("client2", "mgmt") + server, client1, client2 = parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("client1", "mgmt"), + lambda: env.attach("client2", "mgmt")) with test.step("Configure DHCP client and server DUTs"): server.put_config_dicts({ diff --git a/test/case/dhcp/server_subnets/test.py b/test/case/dhcp/server_subnets/test.py index ce0647636..3016fbd2f 100755 --- a/test/case/dhcp/server_subnets/test.py +++ b/test/case/dhcp/server_subnets/test.py @@ -24,7 +24,7 @@ import infamy import infamy.iface as iface import infamy.route as route -from infamy.util import until +from infamy.util import parallel, until def has_dns_server(data, dns_servers): @@ -83,10 +83,10 @@ def has_system_servers(dut, dns, ntp=None): with test.step("Set up topology and attach to client and server DUTs"): env = infamy.Env() - server = env.attach("server", "mgmt") - client1 = env.attach("client1", "mgmt") - client2 = env.attach("client2", "mgmt") - client3 = env.attach("client3", "mgmt") + server, client1, client2, client3 = parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("client1", "mgmt"), + lambda: env.attach("client2", "mgmt"), + lambda: env.attach("client3", "mgmt")) with test.step("Configure DHCP server"): server.put_config_dicts({ diff --git a/test/case/hardware/watchdog/test.py b/test/case/hardware/watchdog/test.py index b88545362..3c4d66dff 100755 --- a/test/case/hardware/watchdog/test.py +++ b/test/case/hardware/watchdog/test.py @@ -12,6 +12,7 @@ """ import base64 import infamy +from infamy.util import parallel import json import subprocess import time @@ -19,8 +20,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Verify the presence of a watchdog device"): wctl = tgtssh.run(["watchdogctl"], stdout=subprocess.PIPE) diff --git a/test/case/interfaces/bridge_fwd_dual_dut/test.py b/test/case/interfaces/bridge_fwd_dual_dut/test.py index 2f0f82142..8c0151818 100755 --- a/test/case/interfaces/bridge_fwd_dual_dut/test.py +++ b/test/case/interfaces/bridge_fwd_dual_dut/test.py @@ -27,12 +27,13 @@ """ import infamy +from infamy.util import parallel with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - dut1 = env.attach("dut1", "mgmt") - dut2 = env.attach("dut2", "mgmt") + dut1, dut2 = parallel(lambda: env.attach("dut1", "mgmt"), + lambda: env.attach("dut2", "mgmt")) with test.step("Configure a bridge with triple physical port"): _, tport11 = env.ltop.xlate("dut1", "data1") diff --git a/test/case/interfaces/bridge_vlan/test.py b/test/case/interfaces/bridge_vlan/test.py index 2b325f5b4..198a2ca29 100755 --- a/test/case/interfaces/bridge_vlan/test.py +++ b/test/case/interfaces/bridge_vlan/test.py @@ -10,12 +10,13 @@ """ import infamy +from infamy.util import parallel with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - dut1 = env.attach("dut1", "mgmt") - dut2 = env.attach("dut2", "mgmt") + dut1, dut2 = parallel(lambda: env.attach("dut1", "mgmt"), + lambda: env.attach("dut2", "mgmt")) with test.step("Configure DUTs"): dut1.put_config_dicts({"ietf-interfaces": { diff --git a/test/case/interfaces/bridge_vlan_separation/test.py b/test/case/interfaces/bridge_vlan_separation/test.py index fd7272c1e..7ebadc11b 100755 --- a/test/case/interfaces/bridge_vlan_separation/test.py +++ b/test/case/interfaces/bridge_vlan_separation/test.py @@ -24,13 +24,14 @@ .... """ import infamy +from infamy.util import parallel import subprocess with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - dut1 = env.attach("dut1", "mgmt") - dut2 = env.attach("dut2", "mgmt") + dut1, dut2 = parallel(lambda: env.attach("dut1", "mgmt"), + lambda: env.attach("dut2", "mgmt")) with test.step("Configure DUTs"): _, tport10 = env.ltop.xlate("dut1", "data1") diff --git a/test/case/interfaces/iface_enable_disable/test.py b/test/case/interfaces/iface_enable_disable/test.py index a1ea3d18d..def6c8728 100755 --- a/test/case/interfaces/iface_enable_disable/test.py +++ b/test/case/interfaces/iface_enable_disable/test.py @@ -9,9 +9,9 @@ """ import infamy +from infamy.util import parallel, until import infamy.iface as iface -from infamy import until def print_error_message(iface, param, exp_val, act_val): return f"'{param}' failure for interface '{iface}'. Expected '{exp_val}', Actual: '{act_val}'" @@ -65,8 +65,8 @@ def configure_interface(target, iface_name, iface_type=None, enabled=True, ip_ad with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - target1 = env.attach("target1", "mgmt") - target2 = env.attach("target2", "mgmt") + target1, target2 = parallel(lambda: env.attach("target1", "mgmt"), + lambda: env.attach("target2", "mgmt")) _, data1 = env.ltop.xlate("target1", "data") _, link1 = env.ltop.xlate("target1", "link") diff --git a/test/case/interfaces/igmp_vlan/test.py b/test/case/interfaces/igmp_vlan/test.py index 46c27b7d9..a62e71dbf 100755 --- a/test/case/interfaces/igmp_vlan/test.py +++ b/test/case/interfaces/igmp_vlan/test.py @@ -24,11 +24,11 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - dut1 = env.attach("dut1", "mgmt") + dut1, dut2 = parallel(lambda: env.attach("dut1", "mgmt"), + lambda: env.attach("dut2", "mgmt")) _, d1send = env.ltop.xlate("dut1", "data1") _, d1receiver = env.ltop.xlate("dut1", "data2") _, d1trunk = env.ltop.xlate("dut1", "link") - dut2 = env.attach("dut2", "mgmt") _, d2receive = env.ltop.xlate("dut2", "data1") _, d2sender = env.ltop.xlate("dut2", "data2") _, d2trunk = env.ltop.xlate("dut2", "link") diff --git a/test/case/interfaces/ipv6_address/test.py b/test/case/interfaces/ipv6_address/test.py index f3372e847..2c4d42f49 100755 --- a/test/case/interfaces/ipv6_address/test.py +++ b/test/case/interfaces/ipv6_address/test.py @@ -6,13 +6,13 @@ See issue #473 for details. """ import infamy -from infamy.util import until +from infamy.util import parallel, until with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Setting up bridge with IPv6 SLAAC for global prefix on target:data"): _, tport = env.ltop.xlate("target", "data") diff --git a/test/case/interfaces/lag_basic/test.py b/test/case/interfaces/lag_basic/test.py index e4f8ddba9..3610e7bd7 100755 --- a/test/case/interfaces/lag_basic/test.py +++ b/test/case/interfaces/lag_basic/test.py @@ -24,9 +24,9 @@ def __init__(self, sys, dut, netns): self.env = sys self.dut = dut self.net = netns - self.tgt = {} - for i, (name, _) in dut.items(): - self.tgt[i] = env.attach(name, "mgmt", "ssh") + self.tgt = dict(zip(dut.keys(), + parallel(*(lambda n=name: env.attach(n, "mgmt", "ssh") + for name, _ in dut.values())))) def set_link(self, link, updown): """Set link up or down, verify before returning.""" @@ -136,8 +136,8 @@ def dut_init(dut, mode, addr): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env(edge_mappings=infamy.lag.edge_mappings) - dut1 = env.attach("dut1", "mgmt") - dut2 = env.attach("dut2", "mgmt") + dut1, dut2 = parallel(lambda: env.attach("dut1", "mgmt"), + lambda: env.attach("dut2", "mgmt")) _, mon = env.ltop.xlate("host", "mon") with infamy.IsolatedMacVlan(mon) as ns: diff --git a/test/case/interfaces/lag_failure/test.py b/test/case/interfaces/lag_failure/test.py index 124ffebfe..c397d138a 100755 --- a/test/case/interfaces/lag_failure/test.py +++ b/test/case/interfaces/lag_failure/test.py @@ -122,8 +122,8 @@ def dut_init(dut, addr, peer): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env(edge_mappings=infamy.lag.edge_mappings) - dut1 = env.attach("dut1") - dut2 = env.attach("dut2") + dut1, dut2 = parallel(lambda: env.attach("dut1"), + lambda: env.attach("dut2")) _, mon = env.ltop.xlate("host", "mon") with infamy.IsolatedMacVlan(mon) as ns: diff --git a/test/case/interfaces/tunnel_basic/test.py b/test/case/interfaces/tunnel_basic/test.py index 576ffcd2d..8e9c5248e 100755 --- a/test/case/interfaces/tunnel_basic/test.py +++ b/test/case/interfaces/tunnel_basic/test.py @@ -12,6 +12,7 @@ """ import infamy +from infamy.util import parallel class ArgumentParser(infamy.ArgumentParser): @@ -25,8 +26,8 @@ def __init__(self): arg = ArgumentParser() env = infamy.Env(args=arg) tunnel = env.args.tunnel - left = env.attach("left", "mgmt") - right = env.attach("right", "mgmt") + left, right = parallel(lambda: env.attach("left", "mgmt"), + lambda: env.attach("right", "mgmt")) with test.step(f"Configure DUTs with tunnel {tunnel}"): container_left4 = { diff --git a/test/case/interfaces/tunnel_bridged/test.py b/test/case/interfaces/tunnel_bridged/test.py index 15b283222..36ad36979 100755 --- a/test/case/interfaces/tunnel_bridged/test.py +++ b/test/case/interfaces/tunnel_bridged/test.py @@ -11,6 +11,7 @@ """ import infamy +from infamy.util import parallel class ArgumentParser(infamy.ArgumentParser): @@ -23,8 +24,8 @@ def __init__(self): with test.step("Set up topology and attach to target DUTs"): arg = ArgumentParser() env = infamy.Env(args=arg) - left = env.attach("left", "mgmt") - right = env.attach("right", "mgmt") + left, right = parallel(lambda: env.attach("left", "mgmt"), + lambda: env.attach("right", "mgmt")) tunnel = env.args.tunnel with test.step("Configure DUTs with tunnel {tunnel}"): diff --git a/test/case/interfaces/tunnel_ttl/test.py b/test/case/interfaces/tunnel_ttl/test.py index 7cab666d5..965603a14 100755 --- a/test/case/interfaces/tunnel_ttl/test.py +++ b/test/case/interfaces/tunnel_ttl/test.py @@ -16,6 +16,7 @@ """ import infamy +from infamy.util import parallel class ArgumentParser(infamy.ArgumentParser): @@ -65,9 +66,9 @@ def __init__(self): arg = ArgumentParser() env = infamy.Env(args=arg) tunnel = env.args.tunnel - r1 = env.attach("R1", "mgmt") - r2 = env.attach("R2", "mgmt") - r3 = env.attach("R3", "mgmt") + r1, r2, r3 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt")) with test.step(f"Configure R1 with {tunnel} tunnel to R3"): # R1: Entry point, west facing PC, east facing R2, tunnel to R3 diff --git a/test/case/interfaces/wireguard_multipoint/test.py b/test/case/interfaces/wireguard_multipoint/test.py index c790ae520..9084aefdf 100755 --- a/test/case/interfaces/wireguard_multipoint/test.py +++ b/test/case/interfaces/wireguard_multipoint/test.py @@ -464,9 +464,9 @@ def configure_client2(dut): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - server = env.attach("server", "mgmt") - client1 = env.attach("client1", "mgmt") - client2 = env.attach("client2", "mgmt") + server, client1, client2 = util.parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("client1", "mgmt"), + lambda: env.attach("client2", "mgmt")) _, hclient1 = env.ltop.xlate("host", "data1") _, hserver = env.ltop.xlate("host", "data2") diff --git a/test/case/interfaces/wireguard_p2p/test.py b/test/case/interfaces/wireguard_p2p/test.py index 33081e288..aaf609d12 100755 --- a/test/case/interfaces/wireguard_p2p/test.py +++ b/test/case/interfaces/wireguard_p2p/test.py @@ -43,8 +43,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - left = env.attach("left", "mgmt") - right = env.attach("right", "mgmt") + left, right = util.parallel(lambda: env.attach("left", "mgmt"), + lambda: env.attach("right", "mgmt")) with test.step("Configure WireGuard tunnel on DUTs"): util.parallel(left.put_config_dicts({ diff --git a/test/case/interfaces/wireguard_roadwarrior/test.py b/test/case/interfaces/wireguard_roadwarrior/test.py index 4ed4b7e0d..232cfdcf1 100755 --- a/test/case/interfaces/wireguard_roadwarrior/test.py +++ b/test/case/interfaces/wireguard_roadwarrior/test.py @@ -317,10 +317,10 @@ def configure_client(client, client_num, private_key, public_key, server_pubkey) with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - server = env.attach("server", "mgmt") - router = env.attach("router", "mgmt") - client1 = env.attach("client1", "mgmt") - client2 = env.attach("client2", "mgmt") + server, router, client1, client2 = util.parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("router", "mgmt"), + lambda: env.attach("client1", "mgmt"), + lambda: env.attach("client2", "mgmt")) _, hport_server = env.ltop.xlate("host", "data") _, hport_client1 = env.ltop.xlate("host", "data1") diff --git a/test/case/misc/start_from_startup/test.py b/test/case/misc/start_from_startup/test.py index 386886789..fb95924f2 100755 --- a/test/case/misc/start_from_startup/test.py +++ b/test/case/misc/start_from_startup/test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import infamy -from infamy.util import wait_boot +from infamy.util import parallel, wait_boot with infamy.Test() as test: with test.step("Initialize"): @@ -17,8 +17,8 @@ target.reboot() if not wait_boot(target, env): test.fail() - target = env.attach("target", "mgmt", test_reset=False) - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt", test_reset=False), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Verify user admin is now in wheel group"): if not tgtssh.runsh("grep wheel /etc/group | grep 'admin'"): diff --git a/test/case/misc/support_collect/test.py b/test/case/misc/support_collect/test.py index e1399288a..abb799314 100755 --- a/test/case/misc/support_collect/test.py +++ b/test/case/misc/support_collect/test.py @@ -12,13 +12,14 @@ import tarfile import tempfile import infamy +from infamy.util import parallel import infamy.ssh as ssh with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Check for GPG availability on target"): result = tgtssh.run("command -v gpg >/dev/null 2>&1", check=False) diff --git a/test/case/ntp/client_stratum_selection/test.py b/test/case/ntp/client_stratum_selection/test.py index f52be5461..42424d2f1 100755 --- a/test/case/ntp/client_stratum_selection/test.py +++ b/test/case/ntp/client_stratum_selection/test.py @@ -18,7 +18,7 @@ """ import infamy -from infamy import until +from infamy.util import parallel, until import infamy.ntp as ntp import infamy.ntp_server as ntp_server @@ -32,8 +32,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to devices"): env = infamy.Env() - srv2 = env.attach("srv2", "mgmt") - client = env.attach("client", "mgmt") + srv2, client = parallel(lambda: env.attach("srv2", "mgmt"), + lambda: env.attach("client", "mgmt")) _, swp1 = env.ltop.xlate("srv2", "swp1") _, swp2 = env.ltop.xlate("srv2", "swp2") diff --git a/test/case/ntp/server_client/test.py b/test/case/ntp/server_client/test.py index fd3de100b..e1d71e264 100755 --- a/test/case/ntp/server_client/test.py +++ b/test/case/ntp/server_client/test.py @@ -11,15 +11,15 @@ """ import infamy -from infamy import until +from infamy.util import parallel, until import infamy.ntp as ntp with infamy.Test() as test: with test.step("Set up topology and attach to devices"): env = infamy.Env() - server = env.attach("server", "mgmt") - client = env.attach("client", "mgmt") + server, client = parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("client", "mgmt")) _, server_data = env.ltop.xlate("server", "data") _, client_data = env.ltop.xlate("client", "data") diff --git a/test/case/ntp/server_mode_peer/test.py b/test/case/ntp/server_mode_peer/test.py index 68f024487..4a6f789a7 100755 --- a/test/case/ntp/server_mode_peer/test.py +++ b/test/case/ntp/server_mode_peer/test.py @@ -20,7 +20,7 @@ """ import infamy -from infamy import until +from infamy.util import parallel, until import infamy.ntp as ntp @@ -79,8 +79,8 @@ def has_selected_peer(peers): with infamy.Test() as test: with test.step("Set up topology and attach to devices"): env = infamy.Env() - peer1 = env.attach("peer1", "mgmt") - peer2 = env.attach("peer2", "mgmt") + peer1, peer2 = parallel(lambda: env.attach("peer1", "mgmt"), + lambda: env.attach("peer2", "mgmt")) _, if1 = env.ltop.xlate("peer1", "data") _, if2 = env.ltop.xlate("peer2", "data") diff --git a/test/case/ntp/server_mode_server/test.py b/test/case/ntp/server_mode_server/test.py index 46ccbe2c6..5ff6bac4d 100755 --- a/test/case/ntp/server_mode_server/test.py +++ b/test/case/ntp/server_mode_server/test.py @@ -16,15 +16,15 @@ """ import infamy -from infamy import until +from infamy.util import parallel, until import infamy.ntp as ntp with infamy.Test() as test: with test.step("Set up topology and attach to devices"): env = infamy.Env() - upstream = env.attach("upstream", "mgmt") - downstream = env.attach("downstream", "mgmt") + upstream, downstream = parallel(lambda: env.attach("upstream", "mgmt"), + lambda: env.attach("downstream", "mgmt")) # Get interface names for each device _, upstream_data1 = env.ltop.xlate("upstream", "data1") diff --git a/test/case/ptp/basic/test.py b/test/case/ptp/basic/test.py index 6d8b50b41..86f2b169c 100755 --- a/test/case/ptp/basic/test.py +++ b/test/case/ptp/basic/test.py @@ -14,8 +14,7 @@ import infamy import infamy.ptp as ptp -from infamy import until -from infamy.util import parallel +from infamy.util import parallel, until class ArgumentParser(infamy.ArgumentParser): @@ -82,8 +81,8 @@ def configure_oc(iface, priority1, client_only, profile, ip=None): arg = ArgumentParser() env = infamy.Env(args=arg) profile = env.args.profile - gm = env.attach("gm", "mgmt") - receiver = env.attach("receiver", "mgmt") + gm, receiver = parallel(lambda: env.attach("gm", "mgmt"), + lambda: env.attach("receiver", "mgmt")) _, gm_iface = env.ltop.xlate("gm", "data") _, receiver_iface = env.ltop.xlate("receiver", "data") diff --git a/test/case/ptp/bmca/test.py b/test/case/ptp/bmca/test.py index 615ee60f4..8bd96799e 100755 --- a/test/case/ptp/bmca/test.py +++ b/test/case/ptp/bmca/test.py @@ -23,8 +23,7 @@ import infamy import infamy.ptp as ptp -from infamy import until -from infamy.util import parallel +from infamy.util import parallel, until class ArgumentParser(infamy.ArgumentParser): @@ -83,8 +82,8 @@ def configure_oc(iface, priority1, profile, ip=None): arg = ArgumentParser() env = infamy.Env(args=arg) profile = env.args.profile - alpha = env.attach("alpha", "mgmt") - beta = env.attach("beta", "mgmt") + alpha, beta = parallel(lambda: env.attach("alpha", "mgmt"), + lambda: env.attach("beta", "mgmt")) _, if_alpha = env.ltop.xlate("alpha", "data") _, if_beta = env.ltop.xlate("beta", "data") diff --git a/test/case/ptp/boundary_clock/test.py b/test/case/ptp/boundary_clock/test.py index 552051a3e..47946be7f 100755 --- a/test/case/ptp/boundary_clock/test.py +++ b/test/case/ptp/boundary_clock/test.py @@ -21,8 +21,8 @@ """ import infamy +from infamy.util import parallel, until import infamy.ptp as ptp -from infamy import until class ArgumentParser(infamy.ArgumentParser): @@ -135,9 +135,9 @@ def configure_bc(uplink_iface, dnlink_iface, profile, arg = ArgumentParser() env = infamy.Env(args=arg) profile = env.args.profile - gm = env.attach("gm", "mgmt") - bc = env.attach("bc", "mgmt") - receiver = env.attach("receiver", "mgmt") + gm, bc, receiver = parallel(lambda: env.attach("gm", "mgmt"), + lambda: env.attach("bc", "mgmt"), + lambda: env.attach("receiver", "mgmt")) _, gm_iface = env.ltop.xlate("gm", "data") _, bc_uplink = env.ltop.xlate("bc", "uplink") diff --git a/test/case/ptp/port_recovery/test.py b/test/case/ptp/port_recovery/test.py index 49f820ad6..e5f796df3 100755 --- a/test/case/ptp/port_recovery/test.py +++ b/test/case/ptp/port_recovery/test.py @@ -13,8 +13,8 @@ """ import infamy +from infamy.util import parallel, until import infamy.ptp as ptp -from infamy import until def configure_oc(iface, ip, priority1, client_only, dm="e2e"): @@ -85,8 +85,8 @@ def __init__(self): with test.step("Set up topology and attach to DUTs"): arg = ArgumentParser() env = infamy.Env(args=arg) - gm = env.attach("gm", "mgmt") - receiver = env.attach("receiver", "mgmt") + gm, receiver = parallel(lambda: env.attach("gm", "mgmt"), + lambda: env.attach("receiver", "mgmt")) _, gm_iface = env.ltop.xlate("gm", "data") _, receiver_iface = env.ltop.xlate("receiver", "data") diff --git a/test/case/ptp/servo/test.py b/test/case/ptp/servo/test.py index 27576fb2d..176e83dde 100755 --- a/test/case/ptp/servo/test.py +++ b/test/case/ptp/servo/test.py @@ -27,8 +27,7 @@ import infamy import infamy.ptp as ptp -from infamy import until -from infamy.util import parallel +from infamy.util import parallel, until STEP_SEC = 10 @@ -104,8 +103,8 @@ def step_clock(ssh, iface, seconds): with test.step("Set up topology and attach to DUTs"): arg = ArgumentParser() env = infamy.Env(args=arg) - gm = env.attach("gm", "mgmt") - receiver = env.attach("receiver", "mgmt") + gm, receiver = parallel(lambda: env.attach("gm", "mgmt"), + lambda: env.attach("receiver", "mgmt")) _, gm_iface = env.ltop.xlate("gm", "data") _, receiver_iface = env.ltop.xlate("receiver", "data") diff --git a/test/case/ptp/transparent_clock/test.py b/test/case/ptp/transparent_clock/test.py index f309e89db..254618fa5 100755 --- a/test/case/ptp/transparent_clock/test.py +++ b/test/case/ptp/transparent_clock/test.py @@ -24,8 +24,8 @@ """ import infamy +from infamy.util import parallel, until import infamy.ptp as ptp -from infamy import until class ArgumentParser(infamy.ArgumentParser): @@ -136,9 +136,9 @@ def configure_tc(uplink_iface, dnlink_iface, profile, dm="e2e", env = infamy.Env(args=arg) profile = env.args.profile dm = "p2p" if profile == "ieee802-dot1as" else env.args.delay_mechanism - gm = env.attach("gm", "mgmt") - tc = env.attach("tc", "mgmt") - receiver = env.attach("receiver", "mgmt") + gm, tc, receiver = parallel(lambda: env.attach("gm", "mgmt"), + lambda: env.attach("tc", "mgmt"), + lambda: env.attach("receiver", "mgmt")) gm_iface = gm["data"] tc_uplink = tc["uplink"] diff --git a/test/case/routing/ospf_basic/test.py b/test/case/routing/ospf_basic/test.py index 405abd531..7ab9f1aaf 100755 --- a/test/case/routing/ospf_basic/test.py +++ b/test/case/routing/ospf_basic/test.py @@ -198,9 +198,9 @@ def config_host(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - HOST = env.attach("HOST", "mgmt") + R1, R2, HOST = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("HOST", "mgmt")) with test.step("Configure targets"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/ospf_bfd/test.py b/test/case/routing/ospf_bfd/test.py index fc743a9a9..62dc655d3 100755 --- a/test/case/routing/ospf_bfd/test.py +++ b/test/case/routing/ospf_bfd/test.py @@ -105,8 +105,8 @@ def ifconfig(name, addr, plen): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Setup TPMR between R1fast and R2fast"): breaker = TPMR(env.ltop.xlate("PC", "R1fast")[1], diff --git a/test/case/routing/ospf_debug/test.py b/test/case/routing/ospf_debug/test.py index d61dbc7f6..8bceb5585 100755 --- a/test/case/routing/ospf_debug/test.py +++ b/test/case/routing/ospf_debug/test.py @@ -220,9 +220,9 @@ def config_target2(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R1ssh = env.attach("R1", "mgmt", "ssh") - R2 = env.attach("R2", "mgmt") + R1, R1ssh, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R1", "mgmt", "ssh"), + lambda: env.attach("R2", "mgmt")) with test.step("Clean up old log files from previous test runs"): R1ssh.runsh("sudo rm -f /var/log/ospf-debug") diff --git a/test/case/routing/ospf_default_route_advertise/test.py b/test/case/routing/ospf_default_route_advertise/test.py index 8cb055f9f..fffa024d4 100755 --- a/test/case/routing/ospf_default_route_advertise/test.py +++ b/test/case/routing/ospf_default_route_advertise/test.py @@ -260,8 +260,8 @@ def set_redistribute_default_always(target): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Configure targets"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/ospf_multiarea/test.py b/test/case/routing/ospf_multiarea/test.py index df0f3cf4e..ce056919f 100755 --- a/test/case/routing/ospf_multiarea/test.py +++ b/test/case/routing/ospf_multiarea/test.py @@ -573,10 +573,10 @@ def disable_link(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") - R4 = env.attach("R4", "mgmt") + R1, R2, R3, R4 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt"), + lambda: env.attach("R4", "mgmt")) _, R1ring1 = env.ltop.xlate("R1", "ring1") _, R1ring2 = env.ltop.xlate("R1", "ring2") diff --git a/test/case/routing/ospf_point_to_multipoint/test.py b/test/case/routing/ospf_point_to_multipoint/test.py index 48c2ab630..1ce52fb57 100755 --- a/test/case/routing/ospf_point_to_multipoint/test.py +++ b/test/case/routing/ospf_point_to_multipoint/test.py @@ -293,9 +293,9 @@ def config_target3(target, link, data): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") + R1, R2, R3 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt")) with test.step("Configure targets"): diff --git a/test/case/routing/ospf_point_to_multipoint_hybrid/test.py b/test/case/routing/ospf_point_to_multipoint_hybrid/test.py index f067ad832..19efff29e 100755 --- a/test/case/routing/ospf_point_to_multipoint_hybrid/test.py +++ b/test/case/routing/ospf_point_to_multipoint_hybrid/test.py @@ -287,9 +287,9 @@ def config_target3(target, link, data): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") + R1, R2, R3 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt")) with test.step("Configure targets"): _, R1link = env.ltop.xlate("R1", "link") diff --git a/test/case/routing/ospf_unnumbered_interface/test.py b/test/case/routing/ospf_unnumbered_interface/test.py index 895801a02..aa86ca290 100755 --- a/test/case/routing/ospf_unnumbered_interface/test.py +++ b/test/case/routing/ospf_unnumbered_interface/test.py @@ -157,8 +157,8 @@ def config_target2(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) _, R1data = env.ltop.xlate("R1", "data") _, R2link = env.ltop.xlate("R2", "link") diff --git a/test/case/routing/rip_basic/test.py b/test/case/routing/rip_basic/test.py index e6976c196..5137d81de 100755 --- a/test/case/routing/rip_basic/test.py +++ b/test/case/routing/rip_basic/test.py @@ -177,8 +177,8 @@ def config_target2(target, link, data): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Configure targets"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/rip_multihop/test.py b/test/case/routing/rip_multihop/test.py index 44ff528a2..39ac5520f 100755 --- a/test/case/routing/rip_multihop/test.py +++ b/test/case/routing/rip_multihop/test.py @@ -234,9 +234,9 @@ def config_r3(target, link, data): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") + R1, R2, R3 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt")) with test.step("Configure routers"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/rip_passive_interface/test.py b/test/case/routing/rip_passive_interface/test.py index 4761578b4..5b540df4d 100755 --- a/test/case/routing/rip_passive_interface/test.py +++ b/test/case/routing/rip_passive_interface/test.py @@ -128,8 +128,8 @@ def config_target2(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Configure targets"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/rip_redistribute/test.py b/test/case/routing/rip_redistribute/test.py index ad66c594b..3da9bbf70 100755 --- a/test/case/routing/rip_redistribute/test.py +++ b/test/case/routing/rip_redistribute/test.py @@ -245,9 +245,9 @@ def config_r3_ospf(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") + R1, R2, R3 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt")) with test.step("Configure routers"): _, R1rip = env.ltop.xlate("R1", "rip") diff --git a/test/case/routing/route_pref_255/test.py b/test/case/routing/route_pref_255/test.py index df949358d..460093023 100755 --- a/test/case/routing/route_pref_255/test.py +++ b/test/case/routing/route_pref_255/test.py @@ -95,8 +95,8 @@ def config_target2(target, data, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Configure targets with active static route"): _, R1data = env.ltop.xlate("R1", "data") diff --git a/test/case/routing/route_pref_dhcp/test.py b/test/case/routing/route_pref_dhcp/test.py index 70a53ec2c..b276f6abf 100755 --- a/test/case/routing/route_pref_dhcp/test.py +++ b/test/case/routing/route_pref_dhcp/test.py @@ -113,8 +113,8 @@ def config_target2(target, data, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Configure targets. Assign higher priority to the dhcp route"): _, R1data1 = env.ltop.xlate("R1", "data1") diff --git a/test/case/routing/route_pref_ospf/test.py b/test/case/routing/route_pref_ospf/test.py index b27b979f5..f35e95800 100755 --- a/test/case/routing/route_pref_ospf/test.py +++ b/test/case/routing/route_pref_ospf/test.py @@ -139,8 +139,8 @@ def config_target2(target, data, link, ospf): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) with test.step("Set up TPMR between R1ospf and R2ospf"): ospf_breaker = TPMR(env.ltop.xlate("PC", "R1_ospf")[1], env.ltop.xlate("PC", "R2_ospf")[1]).start() diff --git a/test/case/routing/static_routing/test.py b/test/case/routing/static_routing/test.py index bcf14f3d8..687d8cc41 100755 --- a/test/case/routing/static_routing/test.py +++ b/test/case/routing/static_routing/test.py @@ -195,8 +195,8 @@ def config_target2(target, link): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") + R1, R2 = parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt")) _, R1data = env.ltop.xlate("R1", "data") _, R2link = env.ltop.xlate("R2", "link") diff --git a/test/case/syslog/advanced_compare/test.py b/test/case/syslog/advanced_compare/test.py index fe049cf95..41ee70fd9 100755 --- a/test/case/syslog/advanced_compare/test.py +++ b/test/case/syslog/advanced_compare/test.py @@ -8,7 +8,7 @@ """ import infamy -from infamy.util import until +from infamy.util import parallel, until TEST_MESSAGES = [ ("daemon.emerg", "Emergency: system is unusable"), @@ -24,8 +24,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Clean up old log files from previous test runs"): tgtssh.runsh("sudo rm -f /var/log/{exact-errors,no-debug,baseline}") diff --git a/test/case/syslog/basic/test.py b/test/case/syslog/basic/test.py index 785d06849..972804696 100755 --- a/test/case/syslog/basic/test.py +++ b/test/case/syslog/basic/test.py @@ -9,13 +9,14 @@ """ import infamy +from infamy.util import parallel import infamy.ssh as ssh with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) factory = env.get_password("target") address = target.get_mgmt_ip() diff --git a/test/case/syslog/hostname_filter/test.py b/test/case/syslog/hostname_filter/test.py index 78ebf480a..6bbbb684c 100755 --- a/test/case/syslog/hostname_filter/test.py +++ b/test/case/syslog/hostname_filter/test.py @@ -7,8 +7,8 @@ """ import infamy +from infamy.util import parallel, until import infamy.iface as iface -from infamy import until TEST_MESSAGES = [ ("router1", "Message from router1"), @@ -41,10 +41,10 @@ def check_log(): with infamy.Test() as test: with test.step("Set up topology and attach to DUTs"): env = infamy.Env() - client = env.attach("client", "mgmt") - server = env.attach("server", "mgmt") - clientssh = env.attach("client", "mgmt", "ssh") - serverssh = env.attach("server", "mgmt", "ssh") + client, server, clientssh, serverssh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("server", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh"), + lambda: env.attach("server", "mgmt", "ssh")) with test.step("Clean up old log files on server"): serverssh.runsh("sudo rm -f /var/log/{router1,router2,all-hosts}") diff --git a/test/case/syslog/pattern_match/test.py b/test/case/syslog/pattern_match/test.py index 4291951e8..2171bc288 100755 --- a/test/case/syslog/pattern_match/test.py +++ b/test/case/syslog/pattern_match/test.py @@ -8,6 +8,7 @@ """ import infamy +from infamy.util import parallel import time TEST_MESSAGES = [ @@ -22,8 +23,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Clean up old log files from previous test runs"): tgtssh.runsh("sudo rm -f /var/log/{errors,routers,all-messages}") diff --git a/test/case/syslog/property_filter/test.py b/test/case/syslog/property_filter/test.py index 9ba0b0e8b..9ca9d81b8 100755 --- a/test/case/syslog/property_filter/test.py +++ b/test/case/syslog/property_filter/test.py @@ -7,7 +7,7 @@ """ import infamy -from infamy.util import until +from infamy.util import parallel, until TEST_MESSAGES = [ ("myapp", "Application startup"), @@ -22,8 +22,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Clean up old log files"): tgtssh.runsh("sudo rm -f /var/log/{myapp,not-error,case-test,baseline}") diff --git a/test/case/syslog/remote/test.py b/test/case/syslog/remote/test.py index b9c1794b9..468bcc93f 100755 --- a/test/case/syslog/remote/test.py +++ b/test/case/syslog/remote/test.py @@ -5,6 +5,7 @@ Verify logging to remote, acting as a remote, and RFC5424 log format. """ import infamy +from infamy.util import parallel def syslog_check(clientssh, serverssh): clientssh.runsh("logger -t test -m client -p security.notice TestMessage") @@ -14,10 +15,10 @@ def syslog_check(clientssh, serverssh): with infamy.Test() as test: with test.step("Set up topology and attach to client and server DUTs"): env = infamy.Env() - client = env.attach("client", "mgmt") - server = env.attach("server", "mgmt") - clientssh = env.attach("client", "mgmt", "ssh") - serverssh = env.attach("server", "mgmt", "ssh") + client, server, clientssh, serverssh = parallel(lambda: env.attach("client", "mgmt"), + lambda: env.attach("server", "mgmt"), + lambda: env.attach("client", "mgmt", "ssh"), + lambda: env.attach("server", "mgmt", "ssh")) with test.step("Configure client DUT as syslog client with server DUT as remote, and configure server DUT as syslog server"): _, client_link = env.ltop.xlate("client", "link") diff --git a/test/case/system/add_delete_user/test.py b/test/case/system/add_delete_user/test.py index 448df181c..a5be02605 100755 --- a/test/case/system/add_delete_user/test.py +++ b/test/case/system/add_delete_user/test.py @@ -19,8 +19,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = util.parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Add new user 'newuser01' with password 'newuser01password'"): target.put_config_dicts({ diff --git a/test/case/system/factory_config/test.py b/test/case/system/factory_config/test.py index 8d5a7ac3f..ecbfb7593 100755 --- a/test/case/system/factory_config/test.py +++ b/test/case/system/factory_config/test.py @@ -10,7 +10,7 @@ import json import infamy -from infamy.util import wait_boot +from infamy.util import parallel, wait_boot STARTUP = "/cfg/startup-config.cfg" FACTORY = "/etc/factory-config.cfg" @@ -32,8 +32,8 @@ def cleanup(env): with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) with test.step("Determine factory-config hostname"): expected = factory_hostname(tgtssh) diff --git a/test/case/system/hostname/test.py b/test/case/system/hostname/test.py index 9c57f2653..6da450bf6 100755 --- a/test/case/system/hostname/test.py +++ b/test/case/system/hostname/test.py @@ -9,12 +9,13 @@ """ import re import infamy +from infamy.util import parallel with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) FMT = "%h-%m" NEW = "h0stn4m3" diff --git a/test/case/system/user_admin/test.py b/test/case/system/user_admin/test.py index d6b39ffb6..41dbb595a 100755 --- a/test/case/system/user_admin/test.py +++ b/test/case/system/user_admin/test.py @@ -14,8 +14,8 @@ with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() - target = env.attach("target", "mgmt") - tgtssh = env.attach("target", "mgmt", "ssh") + target, tgtssh = util.parallel(lambda: env.attach("target", "mgmt"), + lambda: env.attach("target", "mgmt", "ssh")) factory = env.get_password("target") address = target.get_mgmt_ip() diff --git a/test/case/use_case/dhcp_ntp_dns_combination/test.py b/test/case/use_case/dhcp_ntp_dns_combination/test.py index 8c841dbbc..ea14df2df 100755 --- a/test/case/use_case/dhcp_ntp_dns_combination/test.py +++ b/test/case/use_case/dhcp_ntp_dns_combination/test.py @@ -7,7 +7,7 @@ """ import infamy import infamy.iface as iface -from infamy.util import until +from infamy.util import parallel, until def any_dhcp_address(target, iface_name): try: @@ -61,8 +61,8 @@ def has_system_servers(target, dns, ntp_list): with test.step("Set up topology and configure static IP on client"): env = infamy.Env() - server = env.attach("server", "mgmt") - client = env.attach("client", "mgmt") + server, client = parallel(lambda: env.attach("server", "mgmt"), + lambda: env.attach("client", "mgmt")) client_data = client["server"] server_data = server["client"] diff --git a/test/case/use_case/ospf_container/test.py b/test/case/use_case/ospf_container/test.py index 968f37e28..3815b6840 100755 --- a/test/case/use_case/ospf_container/test.py +++ b/test/case/use_case/ospf_container/test.py @@ -574,10 +574,10 @@ def config_abr(target, data, link1, link2, link3): with infamy.Test() as test: with test.step("Set up topology and attach to target DUTs"): env = infamy.Env() - R1 = env.attach("R1", "mgmt") - R2 = env.attach("R2", "mgmt") - R3 = env.attach("R3", "mgmt") - ABR = env.attach("ABR", "mgmt") + R1, R2, R3, ABR = util.parallel(lambda: env.attach("R1", "mgmt"), + lambda: env.attach("R2", "mgmt"), + lambda: env.attach("R3", "mgmt"), + lambda: env.attach("ABR", "mgmt")) if not R1.has_model("infix-containers"): test.skip() if not R2.has_model("infix-containers"):