mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-09 04:40:57 +00:00
fix(cloud): enforce instance capacity ceilings
This commit is contained in:
@@ -88,6 +88,18 @@ async def test_runtime_resource_stats_are_aggregate_and_constant_time() -> None:
|
||||
app.pipeline_mgr = SimpleNamespace(_pipelines_by_key={})
|
||||
app.rag_mgr = SimpleNamespace(knowledge_bases={})
|
||||
app.plugin_connector = SimpleNamespace(_known_desired_states={'installation': object()})
|
||||
app.persistence_mgr = SimpleNamespace(
|
||||
get_resource_stats=lambda: {
|
||||
'configured_capacity': 20,
|
||||
'checked_out': 3,
|
||||
}
|
||||
)
|
||||
app.directory_projection_service = SimpleNamespace(
|
||||
resource_snapshot=lambda: {
|
||||
'active_workspaces': 10,
|
||||
'max_active_workspaces': 1000,
|
||||
}
|
||||
)
|
||||
app.tool_mgr = SimpleNamespace(
|
||||
mcp_tool_loader=SimpleNamespace(
|
||||
_sessions={},
|
||||
@@ -113,6 +125,14 @@ async def test_runtime_resource_stats_are_aggregate_and_constant_time() -> None:
|
||||
'total': 5,
|
||||
'completed': 2,
|
||||
}
|
||||
assert stats['database_pool'] == {
|
||||
'configured_capacity': 20,
|
||||
'checked_out': 3,
|
||||
}
|
||||
assert stats['directory'] == {
|
||||
'active_workspaces': 10,
|
||||
'max_active_workspaces': 1000,
|
||||
}
|
||||
assert stats['query_pool'] == {
|
||||
'queued': 1,
|
||||
'cached': 0,
|
||||
|
||||
@@ -64,6 +64,20 @@ class TestApplyEnvOverridesToConfig:
|
||||
assert result['concurrency']['pipeline'] == 10
|
||||
assert isinstance(result['concurrency']['pipeline'], int)
|
||||
|
||||
def test_cloud_directory_limit_override_keeps_integer_type_on_upgraded_config(self):
|
||||
load_config = get_load_config_module()
|
||||
cfg = load_config._complete_runtime_policy_defaults({})
|
||||
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{'CLOUD__DIRECTORY__MAX_ACTIVE_WORKSPACES': '250'},
|
||||
clear=True,
|
||||
):
|
||||
result = load_config._apply_env_overrides_to_config(cfg)
|
||||
|
||||
assert result['cloud']['directory']['max_active_workspaces'] == 250
|
||||
assert isinstance(result['cloud']['directory']['max_active_workspaces'], int)
|
||||
|
||||
def test_override_int_value_invalid_conversion(self):
|
||||
"""Test that invalid int conversion keeps string value."""
|
||||
load_config = get_load_config_module()
|
||||
|
||||
Reference in New Issue
Block a user