Skip to content

Commit 6949e95

Browse files
committed
fix fixture
1 parent 8589eb4 commit 6949e95

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/pytest-simcore/src/pytest_simcore/aws_ec2_service.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,17 @@ async def aws_vpc_id(
6262

6363
@pytest.fixture
6464
def create_subnet_cidr_block(faker: Faker) -> Callable[[], str]:
65+
# Keep track of used subnet numbers to avoid overlaps
66+
used_subnets: set[int] = set()
67+
6568
def _() -> str:
66-
return faker.ipv4_public(network=True)
69+
# Generate subnet CIDR blocks within the VPC range 10.0.0.0/16
70+
# Using /24 subnets (10.0.X.0/24) where X is between 1-255
71+
while True:
72+
subnet_number = faker.random_int(min=1, max=255)
73+
if subnet_number not in used_subnets:
74+
used_subnets.add(subnet_number)
75+
return f"10.0.{subnet_number}.0/24"
6776

6877
return _
6978

@@ -73,6 +82,7 @@ def subnet_cidr_block(create_subnet_cidr_block: Callable[[], str]) -> str:
7382
return create_subnet_cidr_block()
7483

7584

85+
@pytest.fixture
7686
async def create_aws_subnet_id(
7787
aws_vpc_id: str,
7888
ec2_client: EC2Client,

0 commit comments

Comments
 (0)