Skip to content

ROB-1873-validate-datadog-logs-query-working-as-expected - #780

Merged
moshemorad merged 14 commits into
masterfrom
add_test
Aug 5, 2025
Merged

moshemorad merged 14 commits into
masterfrom
add_test

Conversation

@moshemorad

Copy link
Copy Markdown
Collaborator

No description provided.

@moshemorad
moshemorad requested a review from aantn August 4, 2025 12:47
Comment thread tests/llm/utils/mock_toolset.py
Comment thread holmes/core/tools_utils/toolset_utils.py
aantn
aantn previously approved these changes Aug 4, 2025
@coderabbitai

coderabbitai Bot commented Aug 4, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@moshemorad has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between fb3cae5 and 32eb810.

📒 Files selected for processing (1)
  • tests/llm/utils/test_case_utils.py (6 hunks)

Walkthrough

This set of changes introduces new test fixtures and test cases for Datadog integration, refines mock toolset and file management with enhanced thread safety and error handling, and updates test utilities and configuration. It also adjusts type annotations and logic for toolset filtering, modifies test fixture key naming, and adds a new development dependency for handling environment variables in pytest. Additionally, the test execution logic is updated to prioritize test case test_type over environment variables.

Changes

Cohort / File(s) Change Summary
Mock Toolset Infrastructure
tests/llm/utils/mock_toolset.py
Added thread-safety to mock cache loading, improved old-format mock file error detection, refactored invocation logic into live and mock helpers, extended prerequisite checks to mock generation mode, and added original toolset type tracking in SimplifiedMockToolset. Removed has_mock_files method.
Test Case Utilities
tests/llm/utils/test_case_utils.py
Forbids extra fields in Pydantic models, adds optional fields to HolmesTestCase, renames internal fields in AskHolmesTestCase, updates variant config key names, and modifies MockHelper methods to reflect these changes.
Toolset Filtering Utility
holmes/core/tools_utils/toolset_utils.py
Changed type annotation for toolsets, refactored logic to detect wrapped toolsets by checking for original_toolset_type attribute, improving subclass detection for logging toolsets.
Test Configuration and Fixtures
tests/llm/conftest.py
Modified mock_generation_config fixture to require RUN_LIVE environment variable for mock generation, changed logic for mock mode determination, and improved test skipping behavior.
Test Case Key Update
tests/llm/fixtures/test_ask_holmes/88_affinity_like_but_taints/test_case.yaml
Renamed YAML key from user_question to user_prompt.
New Datadog Integration Test Case and Fixtures
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/conversation_history.json,
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt,
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-f7687cb4-zsngc_-3600.txt,
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml,
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/toolsets.yaml
Added new test case and supporting fixtures for Datadog logs and metrics integration, including conversation history, toolset configs, and mock log data.
Test Execution Logic
tests/llm/test_ask_holmes.py
Modified ask_holmes function to prioritize test_type from the test case over the environment variable for test type selection.
Development Dependency
pyproject.toml
Added pytest-dotenv as a development dependency for environment variable support in pytest.
Model Update
holmes/core/models.py
Added optional request attribute to WorkloadHealthRequest class.
Documentation Update
docs/development/evals/writing.md
Changed example YAML keys from hyphenated to underscore-separated format for setup and teardown commands.
Test Fixture Key Naming Consistency
tests/llm/fixtures/test_investigate/03_cpu_throttling/test_case.yaml
Renamed keys before-test and after-test to before_test and after_test for consistency.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant MockToolsetManager
    participant MockFileManager
    participant MockableToolWrapper
    participant RealToolset

    Tester->>MockToolsetManager: Run test (LIVE/GENERATE/MOCK)
    MockToolsetManager->>MockFileManager: Load mocks (thread-safe)
    MockToolsetManager->>MockableToolWrapper: Wrap toolset
    MockableToolWrapper->>MockFileManager: Try to read mock
    alt Mock found
        MockableToolWrapper-->>Tester: Return mock result
    else No mock found
        alt GENERATE mode
            MockableToolWrapper->>RealToolset: Call live tool
            MockableToolWrapper->>MockFileManager: Write new mock
            MockableToolWrapper-->>Tester: Return live result
        else LIVE mode
            MockableToolWrapper->>RealToolset: Call live tool
            MockableToolWrapper-->>Tester: Return live result
        else MOCK mode
            MockableToolWrapper-->>Tester: Raise error (no mock)
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • WIP: Fix more evals2 #724: Adds and sets original_toolset_type attribute in mock toolsets, directly related to improved subclass detection in this PR.
  • Improve evals mock generation #687: Introduces original_toolset_type and wrapping logic in mock toolsets, closely connected to the detection logic changes here.
  • ROB-1739: datadog/traces toolset #648: Adds original_toolset_type attribute and refactors mock toolset wrapping, directly related to this PR’s changes in toolset subclass detection.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add_test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (2)
tests/llm/utils/test_case_utils.py (2)

187-188: Remove unused request field assignment.

Line 187 sets config_dict["request"] = TypeAdapter(InvestigateRequest) but InvestigateTestCase doesn't have a request field. This causes validation to fail with extra="forbid".

-                    config_dict["request"] = TypeAdapter(InvestigateRequest)
                     test_case = TypeAdapter(InvestigateTestCase).validate_python(
                         config_dict
                     )

83-86: Fix extra “request” field in InvestigateTestCase and HealthCheckTestCase

The _original_user_prompt field in AskHolmesTestCase is already declared and will be accepted by Pydantic, so no change is needed there. The pipeline failures are due to assigning a request key to models that don’t define it:

• In tests/llm/utils/test_case_utils.py around line 187:

  • Remove or correct
    config_dict["request"] = TypeAdapter(InvestigateRequest)

since InvestigateTestCase expects investigate_request, not request.

• In the same file around line 199:

  • Remove or correct
    config_dict["request"] = TypeAdapter(WorkloadHealthRequest)

for HealthCheckTestCase, which expects workload_health_request.

Either drop these lines (you already load and assign the correct fields) or add a request: InvestigateRequest / request: WorkloadHealthRequest field with an alias in the respective Pydantic models.

🧹 Nitpick comments (2)
tests/llm/fixtures/test_ask_holmes/91_calling_datadog/fetch_pod_logssock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt (1)

1-2: Filename formatting makes globbing brittle

We rely on <tool>_<resource>_<offset>.txt elsewhere, but this file omits the underscore between logs and the pod identifier:

fetch_pod_logssock-shop_catalogue-db-… ← missing _ after logs.

Down-stream helpers such as MockToolset.load_json_fixture() split on that underscore. Rename to fetch_pod_logs_sock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt for consistency.

tests/llm/fixtures/test_ask_holmes/91_calling_datadog/toolsets.yaml (1)

4-12: Normalise boolean literals for cleaner diffs

YAML treats true/false and True/False identically, but mixing styles (Lines 5, 7 use lowercase; Line 11 uses title-case) produces noisy diffs and lint warnings (yamllint rule truthy). Pick one convention—lowercase is prevalent in the repo.

-    enabled: True
+    enabled: true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4fedfc and fc2f316.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • holmes/core/tools_utils/toolset_utils.py (1 hunks)
  • pyproject.toml (1 hunks)
  • tests/llm/conftest.py (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/88_affinity_like_but_taints/test_case.yaml (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/91_calling_datadog/conversation_history.json (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/91_calling_datadog/fetch_pod_logssock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/91_calling_datadog/fetch_pod_logssock-shop_catalogue-f7687cb4-zsngc_-3600.txt (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/91_calling_datadog/test_case.yaml (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/91_calling_datadog/toolsets.yaml (1 hunks)
  • tests/llm/utils/mock_toolset.py (9 hunks)
  • tests/llm/utils/test_case_utils.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: ALWAYS place Python imports at the top of the file, not inside functions or methods
Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • holmes/core/tools_utils/toolset_utils.py
  • tests/llm/conftest.py
  • tests/llm/utils/mock_toolset.py
  • tests/llm/utils/test_case_utils.py
🧬 Code Graph Analysis (2)
holmes/core/tools_utils/toolset_utils.py (2)
holmes/core/tools.py (1)
  • Toolset (333-475)
holmes/plugins/toolsets/logging_utils/logging_api.py (1)
  • BasePodLoggingToolset (38-46)
tests/llm/conftest.py (1)
tests/llm/utils/mock_toolset.py (1)
  • MockMode (61-66)
🪛 GitHub Actions: Evaluate LLM test cases
tests/llm/utils/test_case_utils.py

[error] 176-176: Pydantic validation error in AskHolmesTestCase: Extra inputs are not permitted for field '_original_user_prompt'.


[error] 188-188: Pydantic validation error in InvestigateTestCase: Extra inputs are not permitted for field 'request'.

🔇 Additional comments (18)
pyproject.toml (1)

78-78: Add a pytest-plugin pin or assert compatibility

pytest-dotenv 0.5.2 is fine with pytest>=7, but we just bumped pytest to 8.3.3 (Line 67). Up-stream has not yet published wheels that declare compatibility with the new pytest 8-series, so installs may warn or break once the plugin imports pytest.hookspec.

Either:

  1. Pin pytest<8 in dev extras until the plugin officially supports 8.x, or
  2. Add pytest-dotenv >=0.5.2,<0.6,!=0.5.2 once a compatible release appears.

Without this, the CI matrix that installs the dev group can silently skip env-file loading and hide configuration-dependent failures.

tests/llm/fixtures/test_ask_holmes/88_affinity_like_but_taints/test_case.yaml (1)

7-7: All fixtures now use user_prompt

Ran rg -n '^user_question:' tests/llm/fixtures – no matches found. No remaining user_question fields.

tests/llm/fixtures/test_ask_holmes/91_calling_datadog/toolsets.yaml (1)

13-27: Double-check secret interpolation

dd_app_key / dd_api_key are injected via {{ env.VAR }} Jinja syntax. The fixture runner aborts with a KeyError if the variables are missing. Ensure pytest-dotenv loads a .env that defines these keys during CI; otherwise mark the test with pytest.mark.network and skip when absent.

tests/llm/conftest.py (2)

56-63: LGTM - Proper enforcement of RUN_LIVE requirement for mock generation.

The validation logic correctly ensures that mock generation only proceeds when RUN_LIVE is enabled. The early skip with a clear warning message provides good user feedback when the configuration is invalid.


67-72: LGTM - Clear precedence order for mock mode determination.

The reordered logic is more intuitive: generate_mocks takes precedence to set MockMode.GENERATE, followed by run_live for MockMode.LIVE, with MockMode.MOCK as the default fallback. This aligns well with the enhanced mock infrastructure described in the AI summary.

holmes/core/tools_utils/toolset_utils.py (2)

19-19: Type annotation correctly generalized.

The change from list[BasePodLoggingToolset] to list[Toolset] is appropriate since the function now handles wrapped toolsets that may not directly inherit from BasePodLoggingToolset but represent them through the original_toolset_type attribute.


23-29: Proper handling of wrapped toolsets.

The logic correctly checks for original_toolset_type attribute before falling back to type(ts). This handles mock toolsets that wrap original toolsets while preserving their original class type information, as mentioned in the past review comments about SimplifiedMockToolset.

tests/llm/fixtures/test_ask_holmes/91_calling_datadog/conversation_history.json (1)

1-258: Well-structured test fixture for Datadog integration validation.

The conversation history JSON properly simulates a realistic interaction flow from Kubernetes pod inspection to Datadog metrics queries. The structure follows the expected format with appropriate role, content, tool_calls, and token_count fields. The progression from kubectl commands to Datadog metric queries that return null results effectively tests the scenario described in the PR title (ROB-1873-validate-datadog-logs-query-working-as-expected).

tests/llm/fixtures/test_ask_holmes/91_calling_datadog/fetch_pod_logssock-shop_catalogue-f7687cb4-zsngc_-3600.txt (1)

1-1003: LGTM! Test fixture file is well-structured.

The test fixture file follows the expected format with proper JSON metadata and realistic pod log entries. The repetitive health check logs accurately simulate real pod log output.

tests/llm/utils/test_case_utils.py (4)

46-48: Good addition of strict validation with extra="forbid".

Adding Config classes with extra="forbid" improves test case validation by preventing unknown fields. This helps catch configuration errors early.

Also applies to: 72-74


66-68: Useful optional fields for enhanced test metadata.

The new fields (description, generate_mocks, toolsets) provide better test documentation and configuration capabilities.


125-125: Cleaner return statement.

Removing the unnecessary cast improves code readability since load_test_cases() already returns the correct type.


203-206: Good error handling for invalid test folders.

Explicitly raising ValueError for unrecognized test case folders improves debugging compared to silent failures.

tests/llm/utils/mock_toolset.py (5)

191-191: Good addition of thread safety for concurrent test execution.

Adding a threading lock to _load_all_mocks prevents race conditions when multiple tests access the mock cache concurrently. This is essential for pytest-xdist parallel execution.

Also applies to: 306-309


336-352: Excellent error handling for old mock file format.

The detailed error message with PR reference helps users understand the format change and how to fix their mock files. This improves the migration experience.


407-437: Clean refactoring of invocation logic.

Extracting _call_live_invoke and _call_mock_invoke as separate methods improves code organization and readability. The improved error messages in _call_mock_invoke help distinguish between missing mocks and format issues.


479-479: Good preservation of original toolset type information.

Adding original_toolset_type allows proper type checking even when toolsets are wrapped, which is important for toolset filtering logic.

Also applies to: 636-636


587-587: Correct extension of prerequisite checks to GENERATE mode.

Checking prerequisites in GENERATE mode ensures the toolset is properly configured before attempting to generate mocks, preventing failures during mock generation.

Comment thread tests/llm/fixtures/test_ask_holmes/91_calling_datadog/test_case.yaml Outdated
Comment thread tests/llm/utils/mock_toolset.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/llm/fixtures/test_ask_holmes/93_calling_datadog/conversation_history.json (1)

173-175: Typo in user utterance

"can you hosw this as graph?" → "can you show this as graph?"

-        "content": "can you hosw this as graph?",
+        "content": "can you show this as graph?",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc2f316 and dea9011.

📒 Files selected for processing (6)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/conversation_history.json (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-f7687cb4-zsngc_-3600.txt (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml (1 hunks)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/toolsets.yaml (1 hunks)
  • tests/llm/utils/test_case_utils.py (7 hunks)
✅ Files skipped from review due to trivial changes (4)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/toolsets.yaml
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-db-c948fd796-w4vzl_-3600.txt
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/fetch_pod_logssock-shop_catalogue-f7687cb4-zsngc_-3600.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/llm/utils/test_case_utils.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dea9011 and c1edd62.

📒 Files selected for processing (3)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml (1 hunks)
  • tests/llm/test_ask_holmes.py (1 hunks)
  • tests/llm/utils/test_case_utils.py (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml
  • tests/llm/utils/test_case_utils.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: ALWAYS place Python imports at the top of the file, not inside functions or methods
Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • tests/llm/test_ask_holmes.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: New toolsets require integration tests with mocks
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: Applies to tests/llm/fixtures/*/ : Mock data must be placed in tests/llm/fixtures/{test_name}/
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: All new features require unit tests
📚 Learning: in llm-as-judge test cases for holmesgpt, expected outputs should be descriptive rather than prescri...
Learnt from: Sheeproid
PR: robusta-dev/holmesgpt#586
File: tests/llm/fixtures/test_ask_holmes/03_what_is_the_command_to_port_forward/test_case.yaml:4-4
Timestamp: 2025-07-02T10:27:17.231Z
Learning: In LLM-as-judge test cases for HolmesGPT, expected outputs should be descriptive rather than prescriptive when testing for flexible responses like port numbers. Using specific values in expected outputs can cause unnecessary test failures when the AI generates different but equally valid responses.

Applied to files:

  • tests/llm/test_ask_holmes.py
📚 Learning: when suggesting improvements to environment variable handling in robusta-dev/holmesgpt, check first ...
Learnt from: nherment
PR: robusta-dev/holmesgpt#610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: When suggesting improvements to environment variable handling in robusta-dev/holmesgpt, check first if validation logic already exists rather than reimplementing it.

Applied to files:

  • tests/llm/test_ask_holmes.py
📚 Learning: the robusta-dev/holmesgpt codebase has comprehensive existing validation for azure environment varia...
Learnt from: nherment
PR: robusta-dev/holmesgpt#610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: The robusta-dev/holmesgpt codebase has comprehensive existing validation for Azure environment variables (AZURE_API_BASE, AZURE_API_KEY, AZURE_API_VERSION) and MODEL in tests/llm/utils/classifiers.py, tests/llm/conftest.py, and holmes/core/llm.py. Don't suggest adding redundant validation logic.

Applied to files:

  • tests/llm/test_ask_holmes.py
🪛 GitHub Actions: Evaluate LLM test cases
tests/llm/test_ask_holmes.py

[error] 276-276: Test 77_liveness_probe_misconfiguration failed: Actual output did not identify that the web app keeps restarting due to liveness probe configured on wrong port. Instead, it reported inability to locate the pod.


[error] 276-276: Test 60_count_less_than failed: Actual output unable to retrieve number of pods with fewer than 3 restarts due to missing data; expected count was 6.


[error] 276-276: Test 39_failed_toolset failed: Actual output did not quote a specific error for RabbitMQ integration failure; only general unavailability message provided.


[error] 276-276: Test 13a_pending_node_selector_basic failed: Actual output did not mention 'node selector mismatch' but gave generic reasons for pod Pending state and suggested next steps.


[error] 276-276: Test 02_what_is_wrong_with_pod failed: Actual output unable to retrieve pod info due to missing data; expected output was pod killed due to out of memory.


[error] 276-276: Test 24_misconfigured_pvc failed: Actual output unable to locate Redis-related resources or identify issue due to missing data; expected output was PersistentVolumeClaim misconfiguration.


[error] 276-276: Test 79_configmap_mount_issue failed: Actual output unable to retrieve details about app-server pod; expected output was app server stuck in ContainerCreating due to missing ConfigMap.


[error] 276-276: Test 93_calling_datadog[2] failed: Actual output indicated log access not configured; expected output was logs showing consistent health checks with no errors.


[error] 276-276: Test 93_calling_datadog[1] failed: Actual output indicated log access not configured and suggested enabling logging tools; expected output was logs showing consistent health checks with no errors.


[error] 276-276: Test 93_calling_datadog[0] failed: Actual output indicated Datadog logs toolset not enabled with setup instructions; expected output was logs showing consistent health checks with no errors.


[error] 276-276: Test 03_what_is_the_command_to_port_forward failed: Actual output unable to locate Grafana pod in namespace or cluster; expected output required actual pod name, port, and full kubectl port-forward command.


[error] 276-276: Test 88_affinity_like_but_taints failed: Actual output unable to locate database-primary deployment or related info; expected output required mention of missing tolerations for node taints and pod status details.


[error] 276-276: Test 42_dns_issues_steps_new_tools failed: Actual output unable to verify DNS pods running due to missing data; expected output was issue due to network policy named default-deny-egress.


[error] 276-276: Test 86_configmap_like_but_secret failed: Actual output unable to retrieve info about frontend deployment; expected output was issue identified as missing Secret mount (frontend-api-keys).


[error] 276-276: Test 24a_misconfigured_pvc_basic failed: Actual output shows Redis pod stuck in Pending state with no mention of PersistentVolumeClaim misconfiguration as expected.


[error] 276-276: Test 05_image_version failed: Actual output unable to locate pod 'sea-turtle'; expected output was image version of pod is '1.23.4'.


[error] 276-276: Test 83_secret_not_found failed: Actual output unable to locate database pod or related resources; expected output was pod failing to start due to missing Secret 'database-secret'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
🔇 Additional comments (1)
tests/llm/test_ask_holmes.py (1)

304-306: LGTM: Test type prioritization logic is correct.

The change appropriately prioritizes the test case's test_type attribute over the environment variable, which provides better test-level control. The fallback chain (test_case.test_type → ASK_HOLMES_TEST_TYPE env var → "cli" default) is logical and maintains backward compatibility.

Comment thread tests/llm/test_ask_holmes.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
tests/llm/utils/mock_toolset.py (1)

441-446: Consider the --generate flag behavior.

The current implementation reuses existing mocks in GENERATE mode, which may not match user expectations as discussed in the previous review.

🧹 Nitpick comments (1)
tests/llm/utils/mock_toolset.py (1)

585-587: Update comment to reflect GENERATE mode.

The prerequisite check now runs in both LIVE and GENERATE modes, but the comment only mentions LIVE mode.

-            # Only check prerequisites in LIVE mode - for MOCK/GENERATE modes we don't need real connections
+            # Check prerequisites in LIVE and GENERATE modes - only MOCK mode doesn't need real connections
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1edd62 and e7d2d96.

📒 Files selected for processing (4)
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml (1 hunks)
  • tests/llm/test_ask_holmes.py (1 hunks)
  • tests/llm/utils/mock_toolset.py (9 hunks)
  • tests/llm/utils/test_case_utils.py (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/llm/test_ask_holmes.py
  • tests/llm/utils/test_case_utils.py
  • tests/llm/fixtures/test_ask_holmes/93_calling_datadog/test_case.yaml
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: ALWAYS place Python imports at the top of the file, not inside functions or methods
Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • tests/llm/utils/mock_toolset.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: New toolsets require integration tests with mocks
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: Applies to tests/llm/fixtures/*/ : Mock data must be placed in tests/llm/fixtures/{test_name}/
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: All new features require unit tests
📚 Learning: new toolsets require integration tests with mocks...
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-03T07:25:36.018Z
Learning: New toolsets require integration tests with mocks

Applied to files:

  • tests/llm/utils/mock_toolset.py
📚 Learning: the init_config method in toolsets should be idempotent - safely callable multiple times without err...
Learnt from: nherment
PR: robusta-dev/holmesgpt#535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.

Applied to files:

  • tests/llm/utils/mock_toolset.py
🔇 Additional comments (6)
tests/llm/utils/mock_toolset.py (6)

8-10: LGTM!

The imports are correctly placed at the top of the file and are necessary for the new functionality.


65-65: Improved documentation clarity.

The updated comment better describes the GENERATE mode behavior.


191-191: Excellent thread safety implementation.

The threading lock correctly protects the mock cache from concurrent access issues.

Also applies to: 306-309


334-352: Well-implemented format migration error handling.

The error detection and messaging for old format mock files is clear and actionable, providing users with specific guidance on how to fix the issue.


407-467: Excellent refactoring of invoke logic.

The separation of live and mock invocation into dedicated methods improves code clarity and maintainability. The enhanced error messages help users diagnose mock-related issues more effectively.


479-479: Good design for preserving type information.

The original_toolset_type attribute correctly preserves the original toolset class type through the wrapper pattern, enabling proper type detection downstream.

Also applies to: 636-636

@moshemorad
moshemorad requested a review from aantn August 5, 2025 08:43
@github-actions

github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 26/41 test cases were successful, 0 regressions, 1 skipped, 14 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe ✅
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ✅
ask 39_failed_toolset 🔧
ask 41_setup_argo ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 77_liveness_probe_misconfiguration 🔧
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 86_configmap_like_but_secret 🔧
ask 88_affinity_like_but_taints 🔧
ask 89_runbook_missing_cloudwatch 🔧
ask 90_runbook_basic_selection 🔧
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 100_historical_logs 🔧
ask 24a_misconfigured_pvc_basic 🔧
ask 13a_pending_node_selector_basic 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@moshemorad
moshemorad merged commit 7c87def into master Aug 5, 2025
@moshemorad
moshemorad deleted the add_test branch August 5, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants