Skip to content

Commit 364b45c

Browse files
hehe7318gmarciani
authored andcommitted
Reformat
1 parent 8a5b091 commit 364b45c

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

tests/integration-tests/tests/ad_integration/test_ad_integration.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
from cfn_stacks_factory import CfnStack, CfnVpcStack
2626
from conftest_networking import unmarshal_az_override
2727
from framework.fixture_utils import xdist_session_fixture
28-
from paramiko import Ed25519Key
29-
3028
from framework.tests_configuration.config_utils import get_all_regions
29+
from paramiko import Ed25519Key
3130
from remote_command_executor import RemoteCommandExecutor
3231
from retrying import retry
3332
from time_utils import seconds
@@ -231,7 +230,7 @@ def _check_ssm_success(ssm_client, command_id, instance_id):
231230

232231

233232
@xdist_session_fixture(autouse=True)
234-
def directory_stacks_shared(cfn_stacks_factory, request, vpc_stacks_shared):
233+
def directory_stacks_shared(cfn_stacks_factory, request, vpc_stacks_shared): # noqa C901
235234
"""
236235
Build and share AD Directory CFN stacks across xdist workers (session-scoped).
237236
@@ -244,13 +243,12 @@ def directory_stacks_shared(cfn_stacks_factory, request, vpc_stacks_shared):
244243
"""
245244
# Collect regions from CLI (same style as vpc_stacks_shared)
246245
regions = request.config.getoption("regions") or get_all_regions(request.config.getoption("tests_config"))
247-
credential = request.config.getoption("credential")
248246

249247
# AD types you need to support in tests. If you have a CLI to limit types, you can read it here.
250248
directory_types = ["SimpleAD", "MicrosoftAD"]
251249

252-
stacks = {} # (region, dir_type) -> stack_name
253-
created_by_this_fixture = set() # track which stacks were created here
250+
stacks = {} # (region, dir_type) -> stack_name
251+
created_by_this_fixture = set()
254252

255253
# Build per-region stacks
256254
for region in regions:
@@ -263,23 +261,19 @@ def directory_stacks_shared(cfn_stacks_factory, request, vpc_stacks_shared):
263261
logging.info("Directory type %s not supported in region %s, skipping.", dir_type, region)
264262
continue
265263

266-
# If user provided a pre-existing stack, just use it and do not manage its lifecycle
267264
existing_name = request.config.getoption("directory_stack_name")
268265
if existing_name:
269266
stacks[(region, dir_type)] = existing_name
270267
logging.info("Using pre-existing directory stack %s for (%s, %s).", existing_name, region, dir_type)
271268
continue
272269

273-
# Try to find a pre-existing shared stack by tag+prefix (reuse if present)
274270
stack_prefix = f"integ-tests-MultiUserInfraStack{dir_type}"
275271
name = find_stack_by_tag("parallelcluster:integ-tests-ad-stack", region, stack_prefix)
276272

277273
if not name:
278274
# Create a new stack bound to the region's shared VPC
279275
vpc_stack = vpc_stacks_shared[region]
280-
directory_stack = _create_directory_stack(
281-
cfn_stacks_factory, request, dir_type, region, vpc_stack
282-
)
276+
directory_stack = _create_directory_stack(cfn_stacks_factory, request, dir_type, region, vpc_stack)
283277
name = directory_stack.name
284278
created_by_this_fixture.add((region, dir_type))
285279
logging.info("Created directory stack %s for (%s, %s).", name, region, dir_type)
@@ -294,7 +288,7 @@ def directory_stacks_shared(cfn_stacks_factory, request, vpc_stacks_shared):
294288
logging.info("Retain/no-delete set; not deleting directory stacks created by this fixture.")
295289
return
296290

297-
for (region, dir_type) in created_by_this_fixture:
291+
for region, dir_type in created_by_this_fixture:
298292
name = stacks.get((region, dir_type))
299293
if not name:
300294
continue
@@ -314,6 +308,7 @@ def directory_factory(directory_stacks_shared):
314308
- If an explicit existing stack name is provided, return it (use-only).
315309
- Otherwise, look up the stack from the session-shared directory_stacks_shared mapping.
316310
"""
311+
317312
def _factory(existing_directory_stack_name, directory_type, region):
318313
# Use-only path if explicitly specified by the test/CLI
319314
if existing_directory_stack_name:
@@ -322,8 +317,9 @@ def _factory(existing_directory_stack_name, directory_type, region):
322317
key = (region, directory_type)
323318
# Fail fast if the key is not present (e.g., unsupported region/type)
324319
if key not in directory_stacks_shared:
325-
raise RuntimeError(f"No directory stack available for key={key}. "
326-
f"Check is_directory_supported and session setup.")
320+
raise RuntimeError(
321+
f"No directory stack available for key={key}. " f"Check is_directory_supported and session setup."
322+
)
327323
return directory_stacks_shared[key]
328324

329325
return _factory

0 commit comments

Comments
 (0)