diff --git a/framework/infrastructure/gcp/api.py b/framework/infrastructure/gcp/api.py index 84b8446c..e85f69b9 100644 --- a/framework/infrastructure/gcp/api.py +++ b/framework/infrastructure/gcp/api.py @@ -157,7 +157,7 @@ def compute(self, version: str): return self._build_from_discovery_v1(api_name, version) elif version == "v1alpha": return self._build_from_discovery_v1(api_name, "alpha") - elif version in ["v1beta", "v1beta1"]: + elif version == "v1beta": return self._build_from_discovery_v1(api_name, "beta") raise NotImplementedError(f"Compute {version} not supported") diff --git a/framework/infrastructure/traffic_director.py b/framework/infrastructure/traffic_director.py index 2e191eed..23f31629 100644 --- a/framework/infrastructure/traffic_director.py +++ b/framework/infrastructure/traffic_director.py @@ -109,6 +109,7 @@ def __init__( resource_suffix: str, network: str = "default", compute_api_version: str = "v1", + enable_dualstack: bool = False, ): # API self.compute = _ComputeV1( @@ -123,6 +124,7 @@ def __init__( self.network: str = network self.resource_prefix: str = resource_prefix self.resource_suffix: str = resource_suffix + self.enable_dualstack: bool = enable_dualstack # Managed resources self.health_check: Optional[GcpResource] = None @@ -138,7 +140,6 @@ def __init__( self.forwarding_rule: Optional[GcpResource] = None self.forwarding_rule_ipv6: Optional[GcpResource] = None self.alternative_forwarding_rule: Optional[GcpResource] = None - self.enable_dualstack = xds_flags.ENABLE_DUALSTACK.value # Backends. self.backends = set() @@ -189,6 +190,7 @@ def cleanup(self, *, force=False): self.delete_target_grpc_proxy(force=force) if self.enable_dualstack: self.delete_target_proxy_ipv6(force=force) + self.delete_forwarding_rule_ipv6(force=force) self.delete_alternative_target_grpc_proxy(force=force) self.delete_url_map(force=force) self.delete_alternative_url_map(force=force) @@ -740,7 +742,6 @@ def create_forwarding_rule(self, src_port: int): def create_forwarding_rule_ipv6(self, src_port: int): name = self.make_resource_name(self.FORWARDING_RULE_NAME_IPV6) - src_port = int(src_port) logging.info( 'Creating forwarding rule "%s" in network "%s": [::]:%s -> %s', name, @@ -762,17 +763,23 @@ def create_forwarding_rule_ipv6(self, src_port: int): def delete_forwarding_rule(self, force=False): if force: name = self.make_resource_name(self.FORWARDING_RULE_NAME) - name_ipv6 = self.make_resource_name(self.FORWARDING_RULE_NAME_IPV6) elif self.forwarding_rule: name = self.forwarding_rule.name - name_ipv6 = self.forwarding_rule_ipv6.name else: return logger.info('Deleting Forwarding rule "%s"', name) self.compute.delete_forwarding_rule(name) self.forwarding_rule = None - logger.info('Deleting Forwarding rule "%s"', name_ipv6) - self.compute.delete_forwarding_rule(name_ipv6) + + def delete_forwarding_rule_ipv6(self, force=False): + if force: + name = self.make_resource_name(self.FORWARDING_RULE_NAME_IPV6) + elif self.forwarding_rule_ipv6: + name = self.forwarding_rule_ipv6.name + else: + return + logger.info('Deleting Forwarding rule "%s"', name) + self.compute.delete_forwarding_rule(name) self.forwarding_rule_ipv6 = None def create_alternative_forwarding_rule( @@ -914,6 +921,7 @@ def __init__( resource_suffix: Optional[str] = None, network: str = "default", compute_api_version: str = "v1", + enable_dualstack: bool = False, ): super().__init__( gcp_api_manager, @@ -922,6 +930,7 @@ def __init__( resource_suffix=resource_suffix, network=network, compute_api_version=compute_api_version, + enable_dualstack=enable_dualstack, ) # API @@ -1038,6 +1047,7 @@ def __init__( resource_suffix: Optional[str] = None, network: str = "default", compute_api_version: str = "v1", + enable_dualstack: bool = False, ): super().__init__( gcp_api_manager, @@ -1046,6 +1056,7 @@ def __init__( resource_suffix=resource_suffix, network=network, compute_api_version=compute_api_version, + enable_dualstack=enable_dualstack, ) # API diff --git a/framework/test_app/runners/k8s/k8s_xds_client_runner.py b/framework/test_app/runners/k8s/k8s_xds_client_runner.py index 9c5110af..db98bd2f 100644 --- a/framework/test_app/runners/k8s/k8s_xds_client_runner.py +++ b/framework/test_app/runners/k8s/k8s_xds_client_runner.py @@ -31,6 +31,7 @@ class ClientDeploymentArgs: enable_csm_observability: bool = False csm_workload_name: str = "" csm_canonical_service_name: str = "" + enable_dualstack: bool = False def as_dict(self): return dataclasses.asdict(self) diff --git a/framework/test_app/runners/k8s/k8s_xds_server_runner.py b/framework/test_app/runners/k8s/k8s_xds_server_runner.py index ffe60c39..045e57d0 100644 --- a/framework/test_app/runners/k8s/k8s_xds_server_runner.py +++ b/framework/test_app/runners/k8s/k8s_xds_server_runner.py @@ -108,6 +108,7 @@ def __init__( # pylint: disable=too-many-locals debug_use_port_forwarding: bool = False, enable_workload_identity: bool = True, deployment_args: Optional[ServerDeploymentArgs] = None, + enable_dualstack: bool = False, ): super().__init__( k8s_namespace, @@ -142,6 +143,7 @@ def __init__( # pylint: disable=too-many-locals self.td_bootstrap_image = td_bootstrap_image self.network = network self.xds_server_uri = xds_server_uri + self.enable_dualstack = enable_dualstack # Workload identity settings: if self.enable_workload_identity: @@ -223,6 +225,7 @@ def run( # pylint: disable=arguments-differ,too-many-branches deployment_name=self.deployment_name, neg_name=self.gcp_neg_name, test_port=test_port, + enable_dualstack=self.enable_dualstack, ) self._wait_service_neg_status_annotation(self.service_name, test_port) diff --git a/framework/xds_flags.py b/framework/xds_flags.py index 9070326e..3960b27f 100644 --- a/framework/xds_flags.py +++ b/framework/xds_flags.py @@ -193,7 +193,7 @@ ENABLE_DUALSTACK = flags.DEFINE_bool( "enable_dualstack", default=False, - help=("Enable support for Dual Stack resources to the framework."), + help="Enable support for Dual Stack resources to the framework.", ) diff --git a/framework/xds_k8s_testcase.py b/framework/xds_k8s_testcase.py index 58e0ed10..49106b19 100644 --- a/framework/xds_k8s_testcase.py +++ b/framework/xds_k8s_testcase.py @@ -65,6 +65,7 @@ TrafficDirectorSecureManager = traffic_director.TrafficDirectorSecureManager XdsTestServer = server_app.XdsTestServer XdsTestClient = client_app.XdsTestClient +ClientDeploymentArgs = k8s_xds_client_runner.ClientDeploymentArgs KubernetesServerRunner = k8s_xds_server_runner.KubernetesServerRunner KubernetesClientRunner = k8s_xds_client_runner.KubernetesClientRunner _LoadBalancerStatsResponse = grpc_testing.LoadBalancerStatsResponse @@ -146,6 +147,7 @@ class XdsKubernetesBaseTestCase(base_testcase.BaseTestCase): _prev_sigint_handler: Optional[_SignalHandler] = None _handling_sigint: bool = False yaml_highlighter: framework.helpers.highlighter.HighlighterYaml = None + enable_dualstack: bool = False @staticmethod def is_supported(config: skips.TestConfig) -> bool: @@ -179,6 +181,7 @@ def setUpClass(cls): cls.td_bootstrap_image = xds_k8s_flags.TD_BOOTSTRAP_IMAGE.value cls.xds_server_uri = xds_flags.XDS_SERVER_URI.value cls.compute_api_version = xds_flags.COMPUTE_API_VERSION.value + cls.enable_dualstack = xds_flags.ENABLE_DUALSTACK.value # Firewall cls.ensure_firewall = xds_flags.ENSURE_FIREWALL.value @@ -796,7 +799,11 @@ def setUp(self): self.client_namespace = KubernetesClientRunner.make_namespace_name( self.resource_prefix, self.resource_suffix ) - self.client_runner = self.initKubernetesClientRunner() + self.client_runner = self.initKubernetesClientRunner( + deployment_args=ClientDeploymentArgs( + enable_dualstack=self.enable_dualstack + ) + ) # Create healthcheck firewall rules if necessary. if self.ensure_firewall: @@ -940,6 +947,7 @@ def initTrafficDirectorManager(self) -> TrafficDirectorManager: resource_suffix=self.resource_suffix, network=self.network, compute_api_version=self.compute_api_version, + enable_dualstack=self.enable_dualstack, ) def initKubernetesServerRunner(self, **kwargs) -> KubernetesServerRunner: @@ -957,6 +965,7 @@ def initKubernetesServerRunner(self, **kwargs) -> KubernetesServerRunner: network=self.network, debug_use_port_forwarding=self.debug_use_port_forwarding, enable_workload_identity=self.enable_workload_identity, + enable_dualstack=self.enable_dualstack, **kwargs, ) @@ -1014,6 +1023,7 @@ def initTrafficDirectorManager(self) -> TrafficDirectorAppNetManager: resource_suffix=self.resource_suffix, network=self.network, compute_api_version=self.compute_api_version, + enable_dualstack=self.enable_dualstack, ) @@ -1051,6 +1061,7 @@ def initTrafficDirectorManager(self) -> TrafficDirectorSecureManager: resource_suffix=self.resource_suffix, network=self.network, compute_api_version=self.compute_api_version, + enable_dualstack=self.enable_dualstack, ) def initKubernetesServerRunner(self, **kwargs) -> KubernetesServerRunner: @@ -1068,6 +1079,7 @@ def initKubernetesServerRunner(self, **kwargs) -> KubernetesServerRunner: xds_server_uri=self.xds_server_uri, deployment_template="server-secure.deployment.yaml", debug_use_port_forwarding=self.debug_use_port_forwarding, + enable_dualstack=self.enable_dualstack, **kwargs, )