c65e8a5285
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 16s
CI / lint (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 59s
CI / security (pull_request) Successful in 59s
CI / unit_tests (pull_request) Successful in 3m9s
CI / integration_tests (pull_request) Successful in 3m34s
CI / e2e_tests (pull_request) Successful in 3m54s
CI / docker (pull_request) Successful in 55s
CI / coverage (pull_request) Successful in 6m1s
CI / build (push) Successful in 15s
CI / lint (push) Successful in 16s
CI / quality (push) Successful in 27s
CI / typecheck (push) Successful in 38s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 48s
CI / unit_tests (push) Successful in 3m14s
CI / integration_tests (push) Successful in 3m30s
CI / docker (push) Successful in 56s
CI / e2e_tests (push) Successful in 4m43s
CI / coverage (push) Successful in 6m1s
CI / benchmark-publish (push) Successful in 19m50s
CI / benchmark-regression (pull_request) Successful in 37m17s
Implement cloud resource types (aws, gcp, azure) with credential fields, region/tenant metadata, and stubbed sandbox strategies. Credential resolution uses environment variables and profile names with no secrets logged. Key changes: - Add CloudResourceHandler with aws/gcp/azure type definitions - Add credential resolution from env vars and profile names - Add stubbed sandbox strategies (validate config, raise NotImplementedError) - Register cloud types in bootstrap_builtin_types - Credential masking via existing redaction patterns - Add Behave BDD tests, Robot integration tests, ASV benchmarks ISSUES CLOSED: #343
159 lines
4.5 KiB
Python
159 lines
4.5 KiB
Python
"""ASV benchmarks for Automation Profile CLI command throughput.
|
|
|
|
Measures the performance of:
|
|
- Add profile from YAML config
|
|
- List profiles rendering
|
|
- Show profile rendering
|
|
- Remove profile
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import importlib
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
# Ensure the local *source* tree is importable even when ASV has an
|
|
# older build of the package installed.
|
|
_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 typer.testing import CliRunner # noqa: E402
|
|
|
|
from cleveragents.application.services.automation_profile_service import ( # noqa: E402
|
|
AutomationProfileService,
|
|
)
|
|
from cleveragents.cli.commands.automation_profile import ( # noqa: E402
|
|
app as profile_app,
|
|
)
|
|
from cleveragents.domain.models.core.automation_profile import ( # noqa: E402
|
|
AutomationProfile,
|
|
)
|
|
|
|
|
|
class _InMemoryProfileRepository:
|
|
"""In-memory repository satisfying the duck-type contract.
|
|
|
|
Provides the four methods expected by ``AutomationProfileService``:
|
|
``get_by_name``, ``list_all``, ``upsert``, and ``delete``.
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
self._store: dict[str, AutomationProfile] = {}
|
|
|
|
def get_by_name(self, name: str) -> AutomationProfile | None:
|
|
return self._store.get(name)
|
|
|
|
def list_all(self) -> list[AutomationProfile]:
|
|
return list(self._store.values())
|
|
|
|
def upsert(self, profile: AutomationProfile) -> None:
|
|
self._store[profile.name] = profile
|
|
|
|
def delete(self, name: str) -> None:
|
|
self._store.pop(name, None)
|
|
|
|
|
|
_VALID_YAML = """\
|
|
name: bench/test-profile
|
|
description: Benchmark test profile
|
|
schema_version: "1.0"
|
|
auto_strategize: 0.5
|
|
auto_execute: 0.5
|
|
auto_apply: 1.0
|
|
auto_decisions_strategize: 0.5
|
|
auto_decisions_execute: 0.5
|
|
auto_validation_fix: 0.5
|
|
auto_strategy_revision: 0.5
|
|
auto_reversion_from_apply: 0.5
|
|
auto_child_plans: 0.5
|
|
auto_retry_transient: 0.0
|
|
auto_checkpoint_restore: 0.5
|
|
safety:
|
|
require_sandbox: true
|
|
require_checkpoints: true
|
|
allow_unsafe_tools: false
|
|
"""
|
|
|
|
_runner = CliRunner()
|
|
|
|
|
|
def _patch_service() -> None:
|
|
"""Patch ``_get_service`` in the CLI module to use an in-memory repo.
|
|
|
|
Each call creates a fresh repo + service so benchmark iterations
|
|
are isolated from each other and safe for parallel execution.
|
|
"""
|
|
import cleveragents.cli.commands.automation_profile as ap_mod
|
|
|
|
repo = _InMemoryProfileRepository()
|
|
service = AutomationProfileService(repo=repo) # type: ignore[arg-type]
|
|
ap_mod._get_service = lambda: service
|
|
|
|
|
|
class AutomationProfileCLIAddSuite:
|
|
"""Benchmark automation-profile add --config throughput."""
|
|
|
|
def setup(self) -> None:
|
|
"""Write a temporary YAML file and patch service."""
|
|
_patch_service()
|
|
fd, self._path = tempfile.mkstemp(suffix=".yaml")
|
|
with os.fdopen(fd, "w") as fh:
|
|
fh.write(_VALID_YAML)
|
|
|
|
def teardown(self) -> None:
|
|
"""Clean up."""
|
|
Path(self._path).unlink(missing_ok=True)
|
|
|
|
def time_add_from_config(self) -> None:
|
|
"""Benchmark add --config end-to-end."""
|
|
_patch_service()
|
|
_runner.invoke(profile_app, ["add", "--config", self._path])
|
|
|
|
|
|
class AutomationProfileCLIListSuite:
|
|
"""Benchmark automation-profile list throughput."""
|
|
|
|
def setup(self) -> None:
|
|
"""Set up with built-in profiles."""
|
|
_patch_service()
|
|
|
|
def time_list_all(self) -> None:
|
|
"""Benchmark listing all profiles."""
|
|
_runner.invoke(profile_app, ["list"])
|
|
|
|
def time_list_json(self) -> None:
|
|
"""Benchmark listing profiles as JSON."""
|
|
_runner.invoke(profile_app, ["list", "--format", "json"])
|
|
|
|
def time_list_with_regex(self) -> None:
|
|
"""Benchmark listing with regex filter."""
|
|
_runner.invoke(profile_app, ["list", "caut.*"])
|
|
|
|
|
|
class AutomationProfileCLIShowSuite:
|
|
"""Benchmark automation-profile show throughput."""
|
|
|
|
def setup(self) -> None:
|
|
"""Set up."""
|
|
_patch_service()
|
|
|
|
def time_show_rich(self) -> None:
|
|
"""Benchmark showing a profile in rich format."""
|
|
_runner.invoke(profile_app, ["show", "manual"])
|
|
|
|
def time_show_json(self) -> None:
|
|
"""Benchmark showing a profile in JSON format."""
|
|
_runner.invoke(profile_app, ["show", "manual", "--format", "json"])
|
|
|
|
def time_show_yaml(self) -> None:
|
|
"""Benchmark showing a profile in YAML format."""
|
|
_runner.invoke(profile_app, ["show", "manual", "--format", "yaml"])
|