-
Notifications
You must be signed in to change notification settings - Fork 0
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
patrick borowy
committed
Mar 20, 2024
1 parent
484940b
commit c4ad24f
Showing
3 changed files
with
213 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import pytest | ||
import json | ||
import logging | ||
from aiodocker import Docker | ||
from update import recreate_container | ||
import asyncio | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_get_container_configuration(): | ||
client = Docker() | ||
container = await client.containers.create_or_replace( | ||
name="test_container", | ||
config={ | ||
"Image": "exordelabs/orchestrator", | ||
"Labels": { | ||
"network.exorde.test": "true" | ||
} | ||
} | ||
) | ||
await container.start() | ||
|
||
info = await container.show() | ||
config = info["Config"] | ||
|
||
logging.info(f"{json.dumps(config, indent=4)}") | ||
|
||
await container.stop() | ||
await container.delete() | ||
await client.close() | ||
|
||
@pytest.fixture | ||
def container_cleanup(): | ||
yield | ||
async def run(): | ||
logging.info("Removing dangling test containers") | ||
client = Docker() | ||
containers = await client.containers.list( | ||
filters={'label': ["network.exorde.test=true"] }, all=True | ||
) | ||
for container in containers: | ||
await container.stop() | ||
await container.delete() | ||
await client.close() | ||
asyncio.run(run()) | ||
|
||
@pytest.mark.asyncio | ||
async def test_container_recreation(container_cleanup): | ||
client = Docker() | ||
container = await client.containers.create_or_replace( | ||
name="test_container", | ||
config={ | ||
"Image": "exordelabs/transactioneer", | ||
"Labels": { | ||
"network.exorde.test": "true" | ||
} | ||
} | ||
) | ||
await container.start() | ||
|
||
containers = await client.containers.list( | ||
filters={'label': ["network.exorde.test=true"] }, all=True | ||
) | ||
assert len(containers) == 1 | ||
await recreate_container(client, container) | ||
|
||
containers = await client.containers.list( | ||
filters={'label': ["network.exorde.test=true"] }, all=True | ||
) | ||
assert len(containers) == 1 | ||
await client.close() |
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