4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
77 lines
2.7 KiB
Python
77 lines
2.7 KiB
Python
"""Tests for TracerFailedRunTool (function-based, @tool decorated)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from integrations.tracer import PipelineRunSummary
|
|
from integrations.tracer.tools.tracer_failed_run_tool import fetch_failed_run
|
|
from tests.tools.conftest import BaseToolContract
|
|
|
|
|
|
class TestTracerFailedRunToolContract(BaseToolContract):
|
|
def get_tool_under_test(self):
|
|
return fetch_failed_run.__opensre_registered_tool__
|
|
|
|
|
|
def test_is_available_requires_tracer_web() -> None:
|
|
rt = fetch_failed_run.__opensre_registered_tool__
|
|
assert rt.is_available({"tracer_web": {"some": "data"}}) is True
|
|
assert rt.is_available({}) is False
|
|
|
|
|
|
def test_run_no_failed_run_found() -> None:
|
|
mock_client = MagicMock()
|
|
mock_client.get_pipelines.return_value = [MagicMock(pipeline_name="pipeline-1")]
|
|
mock_client.get_pipeline_runs.return_value = []
|
|
mock_client.organization_slug = "my-org"
|
|
with patch(
|
|
"integrations.tracer.tools.tracer_failed_run_tool.get_tracer_web_client",
|
|
return_value=mock_client,
|
|
):
|
|
result = fetch_failed_run()
|
|
assert result["found"] is False
|
|
|
|
|
|
def test_run_finds_failed_run() -> None:
|
|
mock_run = MagicMock(spec=PipelineRunSummary)
|
|
mock_run.pipeline_name = "pipeline-1"
|
|
mock_run.trace_id = "trace-abc"
|
|
mock_run.run_id = "run-1"
|
|
mock_run.run_name = "Run 1"
|
|
mock_run.status = "failed"
|
|
mock_run.start_time = "2024-01-01T00:00:00Z"
|
|
mock_run.end_time = "2024-01-01T01:00:00Z"
|
|
mock_run.run_cost = 1.50
|
|
mock_run.tool_count = 5
|
|
mock_run.user_email = "user@example.com"
|
|
mock_run.instance_type = "m5.large"
|
|
mock_run.region = "us-east-1"
|
|
mock_run.log_file_count = 3
|
|
|
|
mock_client = MagicMock()
|
|
mock_client.get_pipelines.return_value = [MagicMock(pipeline_name="pipeline-1")]
|
|
mock_client.get_pipeline_runs.return_value = [mock_run]
|
|
mock_client.organization_slug = "my-org"
|
|
with patch(
|
|
"integrations.tracer.tools.tracer_failed_run_tool.get_tracer_web_client",
|
|
return_value=mock_client,
|
|
):
|
|
result = fetch_failed_run()
|
|
assert result["found"] is True
|
|
assert result["trace_id"] == "trace-abc"
|
|
assert result["status"] == "failed"
|
|
|
|
|
|
def test_run_with_pipeline_name_filter() -> None:
|
|
mock_client = MagicMock()
|
|
mock_client.get_pipeline_runs.return_value = []
|
|
mock_client.organization_slug = "my-org"
|
|
with patch(
|
|
"integrations.tracer.tools.tracer_failed_run_tool.get_tracer_web_client",
|
|
return_value=mock_client,
|
|
):
|
|
result = fetch_failed_run(pipeline_name="specific-pipeline")
|
|
assert result["found"] is False
|
|
mock_client.get_pipelines.assert_not_called()
|