Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions sdks/python/boxlite/simplebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,15 @@ async def collect_stderr():
error_message=error_message,
)

async def metrics(self):
"""Get box metrics (CPU, memory usage)."""
if not self._started:
raise RuntimeError(
"Box not started. Use 'async with SimpleBox(...) as box:' "
"or call 'await box.start()' first."
)
return await self._box.metrics()

async def stop(self):
"""
Stop the box and release resources.
Expand Down
18 changes: 18 additions & 0 deletions sdks/python/tests/test_simplebox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Integration tests for the async SimpleBox convenience wrapper."""

from __future__ import annotations

import pytest

import boxlite

pytestmark = [pytest.mark.integration, pytest.mark.asyncio]


async def test_simplebox_metrics(shared_runtime):
"""Async SimpleBox exposes box metrics like SyncSimpleBox."""
async with boxlite.SimpleBox(image="alpine:latest", runtime=shared_runtime) as box:
await box.exec("echo", "test")
metrics = await box.metrics()
assert metrics is not None
assert metrics.commands_executed_total >= 1
Loading