9b9bb80e05
CI / lint (push) Waiting to run
CI / typecheck (push) Waiting to run
CI / security (push) Waiting to run
CI / quality (push) Waiting to run
CI / unit_tests (push) Waiting to run
CI / integration_tests (push) Waiting to run
CI / e2e_tests (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
CI / helm (push) Waiting to run
CI / push-validation (push) Waiting to run
CI / status-check (push) Blocked by required conditions
CI / benchmark-publish (push) Waiting to run
devcontainer-file is a read-only config file resource, not a running container. Including it in CONTAINER_RESOURCE_TYPES causes validate_container_available() to return True when only a config file is linked, even though no actual container is available. Closes #10598
107 lines
3.1 KiB
Python
107 lines
3.1 KiB
Python
"""Robot Framework helper for execution environment routing tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ensure local source tree is importable
|
|
_SRC = str(Path(__file__).resolve().parents[1] / "src")
|
|
if _SRC not in sys.path:
|
|
sys.path.insert(0, _SRC)
|
|
|
|
import cleveragents # noqa: E402
|
|
|
|
importlib.reload(cleveragents)
|
|
|
|
from cleveragents.application.services.execution_environment_resolver import ( # noqa: E402
|
|
CONTAINER_RESOURCE_TYPES,
|
|
ContainerUnavailableError,
|
|
ExecutionEnvironmentResolver,
|
|
)
|
|
from cleveragents.domain.models.core.plan import ExecutionEnvironment # noqa: E402
|
|
|
|
|
|
def _run_resolve_default() -> None:
|
|
"""Resolve with no overrides => host."""
|
|
resolver = ExecutionEnvironmentResolver()
|
|
result = resolver.resolve()
|
|
assert result == ExecutionEnvironment.HOST
|
|
print("resolve-default-ok")
|
|
|
|
|
|
def _run_resolve_priority() -> None:
|
|
"""Verify priority chain."""
|
|
resolver = ExecutionEnvironmentResolver()
|
|
|
|
# project overrides default
|
|
assert resolver.resolve(project_env="container") == ExecutionEnvironment.CONTAINER
|
|
|
|
# plan overrides project
|
|
assert (
|
|
resolver.resolve(plan_env="host", project_env="container")
|
|
== ExecutionEnvironment.HOST
|
|
)
|
|
|
|
# tool overrides plan
|
|
assert (
|
|
resolver.resolve(tool_env="container", plan_env="host")
|
|
== ExecutionEnvironment.CONTAINER
|
|
)
|
|
print("resolve-priority-ok")
|
|
|
|
|
|
def _run_container_validation() -> None:
|
|
"""Validate container availability checks."""
|
|
resolver = ExecutionEnvironmentResolver()
|
|
|
|
# Should pass with container resource
|
|
assert resolver.validate_container_available(["devcontainer-instance"]) is True
|
|
|
|
# Should raise without container resource
|
|
try:
|
|
resolver.validate_container_available(["git-checkout"])
|
|
print("FAIL: expected ContainerUnavailableError")
|
|
sys.exit(1)
|
|
except ContainerUnavailableError:
|
|
pass
|
|
|
|
print("container-validation-ok")
|
|
|
|
|
|
def _run_enum_values() -> None:
|
|
"""Verify enum values."""
|
|
assert ExecutionEnvironment.HOST.value == "host"
|
|
assert ExecutionEnvironment.CONTAINER.value == "container"
|
|
print("enum-values-ok")
|
|
|
|
|
|
def _run_resource_types() -> None:
|
|
"""Verify container resource types."""
|
|
assert "container-instance" in CONTAINER_RESOURCE_TYPES
|
|
assert "devcontainer-instance" in CONTAINER_RESOURCE_TYPES
|
|
assert "devcontainer-file" not in CONTAINER_RESOURCE_TYPES
|
|
assert "git-checkout" not in CONTAINER_RESOURCE_TYPES
|
|
print("resource-types-ok")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
cmd = sys.argv[1] if len(sys.argv) > 1 else "all"
|
|
dispatch = {
|
|
"resolve-default": _run_resolve_default,
|
|
"resolve-priority": _run_resolve_priority,
|
|
"container-validation": _run_container_validation,
|
|
"enum-values": _run_enum_values,
|
|
"resource-types": _run_resource_types,
|
|
}
|
|
|
|
if cmd == "all":
|
|
for fn in dispatch.values():
|
|
fn()
|
|
elif cmd in dispatch:
|
|
dispatch[cmd]()
|
|
else:
|
|
print(f"Unknown command: {cmd}")
|
|
sys.exit(1)
|