-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
167 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
backend/tests/integration/ipam/test_load_concurrent_prefixes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import ipaddress | ||
|
||
from infrahub.database import InfrahubDatabase | ||
from tests.integration.ipam.base import TestIpam | ||
|
||
|
||
# See https://github.com/opsmill/infrahub/issues/4523 | ||
class TestLoadConcurrentPrefixes(TestIpam): | ||
async def test_load_concurrent_prefixes( | ||
self, | ||
db: InfrahubDatabase, | ||
default_branch, | ||
client, | ||
default_ipnamespace, | ||
register_ipam_schema, | ||
): | ||
prefixes_batch = await client.create_batch() | ||
network_8 = ipaddress.IPv4Network("10.0.0.0/8") | ||
networks_16 = list(network_8.subnets(new_prefix=16)) | ||
|
||
networks = [network_8] + networks_16[0:10] | ||
|
||
for network in networks: | ||
prefix = await client.create("IpamIPPrefix", prefix=f"{network}") | ||
prefixes_batch.add(task=prefix.save, node=prefix, allow_upsert=True) | ||
|
||
async for _, _ in prefixes_batch.execute(): | ||
pass | ||
|
||
nodes = await client.all("IpamIPPrefix", prefetch_relationships=True, populate_store=True) | ||
for n in nodes: | ||
if n.prefix.value != network_8: | ||
assert n.parent.peer.prefix.value == network_8 |