4949from framework .test_app import server_app
5050
5151# Flags
52- _MODE = flags .DEFINE_enum (
53- "mode" ,
54- default = "default" ,
55- enum_values = [
56- "default" ,
57- "secure" ,
58- "app_net" ,
59- "gamma" ,
60- ],
61- help = "Select test mode" ,
62- )
63- _SECURITY = flags .DEFINE_enum (
64- "security" ,
65- default = None ,
66- enum_values = [
67- "mtls" ,
68- "tls" ,
69- "plaintext" ,
70- "mtls_error" ,
71- "server_authz_error" ,
72- ],
73- help = "Show info for a security setup" ,
74- )
7552flags .adopt_module_key_flags (common )
7653flags .adopt_module_key_flags (xds_flags )
7754flags .adopt_module_key_flags (xds_k8s_flags )
78- # Running outside of a test suite, so require explicit resource_suffix.
79- flags .mark_flag_as_required (xds_flags .RESOURCE_SUFFIX .name )
80-
81-
82- @flags .multi_flags_validator (
83- (xds_flags .SERVER_XDS_PORT .name , _MODE .name ),
84- message = (
85- "Run outside of a test suite, must provide"
86- " the exact port value (must be greater than 0)."
87- ),
88- )
89- def _check_server_xds_port_flag (flags_dict ):
90- if flags_dict [_MODE .name ] == "gamma" :
91- return True
92- return flags_dict [xds_flags .SERVER_XDS_PORT .name ] > 0
9355
9456
9557logger = logging .get_absl_logger ()
@@ -244,15 +206,19 @@ def main(argv):
244206 enable_workload_identity : bool = (
245207 xds_k8s_flags .ENABLE_WORKLOAD_IDENTITY .value
246208 )
247- is_secure : bool = bool (_SECURITY .value )
209+ is_secure : bool = bool (common .SECURITY .value )
210+ security_mode = common .SECURITY .value
211+ if security_mode :
212+ flags .set_default (common .MODE , "secure" )
213+ mode = common .MODE .value
248214
249215 # Server.
250216 server_namespace = common .make_server_namespace ()
251217 server_runner = common .make_server_runner (
252218 server_namespace ,
253219 port_forwarding = should_port_forward ,
254220 enable_workload_identity = enable_workload_identity ,
255- mode = _MODE . value ,
221+ mode = mode ,
256222 )
257223 # Find server pod.
258224 server_pods = common .get_server_pods (
@@ -270,7 +236,7 @@ def main(argv):
270236 client_namespace ,
271237 port_forwarding = should_port_forward ,
272238 enable_workload_identity = enable_workload_identity ,
273- mode = _MODE . value ,
239+ mode = mode ,
274240 )
275241 # Find client pod.
276242 client_pod : k8s .V1Pod = common .get_client_pod (
@@ -292,7 +258,7 @@ def main(argv):
292258 )
293259
294260 # Create client app for the client pod.
295- if _MODE . value == "gamma" :
261+ if mode == "gamma" :
296262 server_target = (
297263 f"xds:///{ server_runner .frontend_service_name } "
298264 f".{ server_runner .k8s_namespace .name } .svc.cluster.local"
@@ -309,9 +275,9 @@ def main(argv):
309275 )
310276
311277 with test_client , test_server :
312- if _SECURITY . value in ("mtls" , "tls" , "plaintext" ):
278+ if security_mode in ("mtls" , "tls" , "plaintext" ):
313279 debug_security_setup_positive (test_client , test_server )
314- elif _SECURITY . value in ("mtls_error" , "server_authz_error" ):
280+ elif security_mode in ("mtls_error" , "server_authz_error" ):
315281 debug_security_setup_negative (test_client )
316282 else :
317283 debug_basic_setup (test_client , test_server )
0 commit comments