test(async-cleanup): align tracker scenarios
CI / lint (pull_request) Successful in 37s
CI / build (pull_request) Successful in 34s
CI / quality (pull_request) Successful in 56s
CI / typecheck (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m16s
CI / helm (pull_request) Successful in 26s
CI / push-validation (pull_request) Successful in 21s
CI / e2e_tests (pull_request) Failing after 3m43s
CI / integration_tests (pull_request) Failing after 6m37s
CI / unit_tests (pull_request) Failing after 8m0s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 4s
CI / lint (pull_request) Successful in 37s
CI / build (pull_request) Successful in 34s
CI / quality (pull_request) Successful in 56s
CI / typecheck (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m16s
CI / helm (pull_request) Successful in 26s
CI / push-validation (pull_request) Successful in 21s
CI / e2e_tests (pull_request) Failing after 3m43s
CI / integration_tests (pull_request) Failing after 6m37s
CI / unit_tests (pull_request) Failing after 8m0s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 4s
This commit is contained in:
@@ -82,14 +82,13 @@ Feature: Async Resource Tracker
|
||||
Then async cleanup should complete without errors
|
||||
And async cleanup tracker should have 0 open resources
|
||||
|
||||
Scenario: Clear timed_out_resources on each close_all
|
||||
Scenario: Preserve timeout diagnostics across idempotent close_all
|
||||
Given async cleanup has an empty resource tracker
|
||||
And async cleanup has a slow resource named "slow_1" that takes 5.0 seconds to close
|
||||
When async cleanup registers the resource with the tracker
|
||||
And async cleanup closes all resources with timeout 0.1
|
||||
Then async cleanup resource "slow_1" should be in timed_out_resources
|
||||
When async cleanup registers a mock resource named "fast_resource"
|
||||
And async cleanup closes all resources with timeout 30.0
|
||||
When async cleanup closes all resources again with timeout 30.0
|
||||
Then async cleanup timed_out_resources should only contain "slow_1"
|
||||
|
||||
# --- Query scenarios ---
|
||||
@@ -152,8 +151,10 @@ Feature: Async Resource Tracker
|
||||
When async cleanup closes all resources with timeout 30.0
|
||||
Then async cleanup custom object close should have been called
|
||||
|
||||
Scenario: Reject object without async close method
|
||||
Scenario: Register object without async close method and report close failure
|
||||
Given async cleanup has an empty resource tracker
|
||||
And async cleanup has an object without an async close method
|
||||
When async cleanup attempts to register the object with the tracker
|
||||
Then async cleanup should raise TypeError
|
||||
Then async cleanup tracker should have 1 open resource
|
||||
When async cleanup closes all resources with timeout 30.0
|
||||
Then async cleanup should log an exception for "bad"
|
||||
|
||||
@@ -11,9 +11,8 @@ from behave import given, then, when
|
||||
from cleveragents.core.async_cleanup import AsyncResource, AsyncResourceTracker
|
||||
|
||||
|
||||
# Configure logging to capture warnings
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger("cleveragents.core.async_cleanup")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
# --- Background ---
|
||||
@@ -45,6 +44,14 @@ def step_mock_resource(context: Any, name: str) -> None:
|
||||
context.resources[name] = resource
|
||||
|
||||
|
||||
@given('async cleanup has a mock resource named ""')
|
||||
def step_mock_resource_empty_name(context: Any) -> None:
|
||||
"""Create a mock async resource with an empty registration name."""
|
||||
resource = AsyncMock(spec=AsyncResource)
|
||||
resource.close = AsyncMock()
|
||||
context.resources[""] = resource
|
||||
|
||||
|
||||
@given(
|
||||
'async cleanup has a slow resource named "{name}" that takes {seconds:f} seconds to close'
|
||||
)
|
||||
@@ -168,7 +175,12 @@ def step_query_open_count(context: Any) -> None:
|
||||
def step_register_new_resource(context: Any, name: str) -> None:
|
||||
"""Register a new mock resource."""
|
||||
resource = AsyncMock(spec=AsyncResource)
|
||||
context.tracker.register(name, resource)
|
||||
resource.close = AsyncMock()
|
||||
context.resources[name] = resource
|
||||
try:
|
||||
context.tracker.register(name, resource)
|
||||
except Exception as e:
|
||||
context.last_exception = e
|
||||
|
||||
|
||||
@when("async cleanup uses the tracker as an async context manager")
|
||||
@@ -280,6 +292,12 @@ def step_check_open_count(context: Any, count: int) -> None:
|
||||
)
|
||||
|
||||
|
||||
@then("async cleanup tracker should have {count:d} open resources")
|
||||
def step_check_open_count_plural(context: Any, count: int) -> None:
|
||||
"""Verify the number of open resources using plural wording."""
|
||||
step_check_open_count(context, count)
|
||||
|
||||
|
||||
@then('async cleanup resource should be registered under "{name}"')
|
||||
def step_check_resource_registered(context: Any, name: str) -> None:
|
||||
"""Verify a resource is registered."""
|
||||
|
||||
Reference in New Issue
Block a user