From 9db8319bb5ada08d2986feb7c665e79e4a8a6018 Mon Sep 17 00:00:00 2001 From: msftsettiy <63882775+msftsettiy@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:39:09 -0800 Subject: [PATCH 1/2] Enable redirection when starting a network (#6732) Co-authored-by: Yagnesh Setti Subramanian (cherry picked from commit d6ca4ed3f8e4ed6ab10948cedd391bb3a1eba073) --- tests/start_network.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/start_network.py b/tests/start_network.py index 80287d8a6334..a41b4ca02e69 100644 --- a/tests/start_network.py +++ b/tests/start_network.py @@ -30,6 +30,24 @@ def run(args): for host_desc in host_descs: interface = infra.interfaces.RPCInterface.from_args(args) interface.parse_from_str(host_desc) + + if args.redirection_kind == "node-by-role": + LOG.warning("Redirection with node-by-role is enabled") + interface.redirections = infra.interfaces.RedirectionConfig( + to_primary=infra.interfaces.NodeByRoleResolver(), + to_backup=infra.interfaces.NodeByRoleResolver(), + ) + elif args.redirection_kind == "static-address": + LOG.warning("Redirection with static-address is enabled") + interface.redirections = infra.interfaces.RedirectionConfig( + to_primary=infra.interfaces.StaticAddressResolver( + args.primary_hostname + ), + to_backup=infra.interfaces.StaticAddressResolver( + args.backup_hostname + ), + ) + hosts.append( infra.interfaces.HostSpec( rpc_interfaces={infra.interfaces.PRIMARY_RPC_INTERFACE: interface} @@ -209,12 +227,34 @@ def add(parser): type=int, default=0, ) + parser.add_argument( + "--redirection-kind", + default="node-by-role", + choices=["node-by-role", "static-address"], + help="The redirection kind to use in lieu of forwarding. Either node-by-role or static-address", + ) + parser.add_argument( + "--primary-hostname", + help="The primary hostname to set when --redirection-kind is set to static-address", + ) + parser.add_argument( + "--backup-hostname", + help="The backup hostname to set when --redirection-kind is set to static-address", + ) args = infra.e2e_args.cli_args(add) if args.recover and not all([args.ledger_dir, args.common_dir]): print("Error: --recover requires --ledger-dir and --common-dir arguments.") sys.exit(1) + if args.redirection_kind == "static-address" and not all( + [args.primary_hostname, args.backup_hostname] + ): + print( + "Error: --redirection-kind static-address requires --primary-hostname and --backup-hostname arguments." + ) + sys.exit(1) + if args.common_dir is not None: args.common_dir = os.path.abspath(args.common_dir) From ca9be7a641bff557f1d433148c449f9f350faa65 Mon Sep 17 00:00:00 2001 From: msftsettiy <63882775+msftsettiy@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:50:56 -0800 Subject: [PATCH 2/2] Fixed the backup redirection config in the start_network.py (#6755) Co-authored-by: msftsettiy (cherry picked from commit 80b1a2124073db01387be397ed1c9225e1be8111) --- tests/start_network.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/start_network.py b/tests/start_network.py index a41b4ca02e69..0021ffc1c439 100644 --- a/tests/start_network.py +++ b/tests/start_network.py @@ -35,7 +35,11 @@ def run(args): LOG.warning("Redirection with node-by-role is enabled") interface.redirections = infra.interfaces.RedirectionConfig( to_primary=infra.interfaces.NodeByRoleResolver(), - to_backup=infra.interfaces.NodeByRoleResolver(), + to_backup=infra.interfaces.NodeByRoleResolver( + target=infra.interfaces.TargetRole( + infra.interfaces.NodeRole.backup + ) + ), ) elif args.redirection_kind == "static-address": LOG.warning("Redirection with static-address is enabled")