Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import json
import os
from shutil import rmtree
from tempfile import NamedTemporaryFile, mkdtemp
Expand Down Expand Up @@ -109,6 +110,17 @@ def dump_logs(container: docker.models.containers.Container, file: str):
f.write(logs)


def dump_container_inspect(
client: docker.DockerClient,
container: docker.models.containers.Container,
file: str,
):
assert container.id is not None
container_inspect = client.api.inspect_container(container.id)
with open(file, 'w') as f:
json.dump(container_inspect, f, indent=2)


@pytest.fixture
def fact_config(
request: pytest.FixtureRequest,
Expand Down Expand Up @@ -250,10 +262,15 @@ def fact(
with open(metric_log, 'w') as f:
f.write(resp.text)

container.stop(timeout=2)
container.stop(timeout=5)
exit_status = container.wait(timeout=2)
dump_logs(container, container_log)
container.remove()
try:
dump_logs(container, container_log)
dump_container_inspect(
docker_client, container, os.path.join(logs_dir, 'container.json')
)
finally:
container.remove()
Comment thread
Molter73 marked this conversation as resolved.
assert exit_status['StatusCode'] == 0


Expand Down
Loading