Skip to content

Conversation

@telemaco
Copy link
Collaborator

@telemaco telemaco commented Dec 19, 2025

  • Migrate to e2e pytest the test/system/070-rag.bats bat test.

Summary by Sourcery

Add end-to-end pytest coverage for the rag command, including dry-run behavior and error handling for various inputs and container engines.

Enhancements:

  • Add a Podman-specific skip marker to the test configuration for selectively excluding tests when Podman is the active container engine.

Tests:

  • Introduce comprehensive e2e pytest suite for ramalama rag and run --rag dry-run behavior across HTTP, file, and folder inputs, including debug mode.
  • Verify container runtime options, mount behavior, image selection/override semantics, and user/network flags differ correctly between Docker and Podman.
  • Add e2e tests for error conditions such as missing files and invalid image references with appropriate exit codes and messages.
  • Assert successful rag execution with multiple sources and clean up the generated RAG image after the run.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 19, 2025

Reviewer's Guide

Adds a new pytest-based end-to-end test suite for the ramalama rag command (migrated from the old BATS test), including various dry-run behaviors, error cases, and integration with run --rag, plus a new skip marker for podman-based environments.

File-Level Changes

Change Details Files
Introduce pytest e2e coverage for ramalama rag and run --rag dry-run behavior and error handling, including container-engine–specific expectations.
  • Create test_rag_dry_run parametrized test to validate dry-run output flags and doc2rag invocation for HTTP, local file, and URI inputs, including container-engine–specific behavior for --user and --network, and ocr/format flags.
  • Add test_rag_dry_run_with_file_uri, test_rag_dry_run_with_debug, and failure-mode tests to verify missing local file handling and invalid image reference format, asserting specific return codes and error messages from the CLI.
  • Add test_run_dry_run parametrized coverage for ramalama run --rag to verify llama-server startup, rag image selection/override, mount behavior, and pull policy, plus auxiliary tests for debug output and local-folder mounts.
  • Add a non-dry-run test_rag that runs ramalama rag end-to-end against local and HTTP inputs and then removes the generated RAG image via the active container engine.
test/e2e/test_rag.py
Add a new pytest marker to skip tests when running under podman.
  • Define skip_if_podman in test/conftest.py mirroring skip_if_docker, using config.option.container_engine to conditionally skip tests when the container engine is podman.
  • Apply skip_if_podman to selected rag dry-run tests whose expectations differ between docker and podman (e.g., --user behavior and image mount semantics).
test/conftest.py
test/e2e/test_rag.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @telemaco, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing infrastructure by migrating the existing rag command system test from bats to a more robust pytest end-to-end framework. The new tests provide extensive coverage for the ramalama rag and run commands, validating their behavior across different configurations, including dry-run modes, file input types, and error handling, while also introducing a specific marker for Podman-related test skipping.

Highlights

  • Test Migration: The existing 070-rag.bats system test has been successfully migrated to the pytest end-to-end testing framework, enhancing test maintainability and robustness.
  • Comprehensive RAG Tests: A new suite of end-to-end tests for the ramalama rag command has been introduced, covering various dry-run scenarios, file handling (local and HTTP), error conditions, and specific behaviors related to container engines.
  • Podman Skip Marker: A new skip_if_podman pytest marker was added to test/conftest.py, allowing for conditional test execution to skip tests specifically when Podman is the active container engine.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • In test_run_dry_run the parametrized model argument is never used and OLLAMA_MODEL is always passed to check_output, which makes the model parameter misleading; either use model in the command or remove it from the parametrization.
  • In test_rag_dry_run_with_file_uri the raw f-string mixes double quotes around README.md inside a double-quoted f-string, which is invalid syntax; switch the inner quotes to single quotes or build the path in a separate variable before interpolating it into the regex.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_run_dry_run` the parametrized `model` argument is never used and `OLLAMA_MODEL` is always passed to `check_output`, which makes the `model` parameter misleading; either use `model` in the command or remove it from the parametrization.
- In `test_rag_dry_run_with_file_uri` the raw f-string mixes double quotes around `README.md` inside a double-quoted f-string, which is invalid syntax; switch the inner quotes to single quotes or build the path in a separate variable before interpolating it into the regex.

## Individual Comments

### Comment 1
<location> `test/e2e/test_rag.py:92-93` </location>
<code_context>
+        file_path.touch()
+        file_uri = file_path.as_uri()
+
+        result = ctx.check_output(RAG_DRY_RUN + [file_uri, RAG_MODEL])
+        assert re.search(fr".*-v {Path(ctx.workspace_dir) / "README.md"}:/docs/README.md:ro", result)
+
+
</code_context>

<issue_to_address>
**issue (bug_risk):** The f-string in this assertion is syntactically invalid due to nested double quotes.

`fr"... {Path(ctx.workspace_dir) / "README.md"} ..."` is invalid because the inner `"README.md"` closes the outer string. Use different quotes or build the path first, for example:

```python
target = Path(ctx.workspace_dir) / "README.md"
result = ctx.check_output(RAG_DRY_RUN + [file_uri, RAG_MODEL])
assert re.search(fr".*-v {target}:/docs/README.md:ro", result)
```

This avoids the syntax error so the test can run.
</issue_to_address>

### Comment 2
<location> `test/e2e/test_rag.py:19-28` </location>
<code_context>
+@pytest.mark.parametrize(
</code_context>

<issue_to_address>
**issue (testing):** The `model` parameter in `test_run_dry_run` is unused; the test always uses `OLLAMA_MODEL`.

In the parametrized test, `model` is in the signature but the command always uses `OLLAMA_MODEL`, so the parametrization has no effect and is misleading. Either remove `model` from the params and signature if you always want `OLLAMA_MODEL`, or use it in the command:

```python
result = ctx.check_output(RUN_DRY_RUN + params + [model])
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of adding comprehensive e2e tests for the rag command, migrating from the old BATS test. The new tests cover various scenarios including dry-runs, different input types, and error handling, which significantly improves test coverage.

I've made a few suggestions to improve the readability of assertions and remove a redundant test case. Overall, this is a solid contribution.

@telemaco telemaco force-pushed the e2e-pytest-rag-cmd branch 3 times, most recently from b22330d to 4703ead Compare December 19, 2025 16:53
@telemaco
Copy link
Collaborator Author

@olliewalsh I think we have here a new path inconsistency on windows

@telemaco telemaco force-pushed the e2e-pytest-rag-cmd branch 2 times, most recently from 8f88c99 to b1ee331 Compare December 22, 2025 11:54
@telemaco
Copy link
Collaborator Author

PTAL @olliewalsh . I've declared as xfail the windows ones. The PR is ready.

@telemaco telemaco force-pushed the e2e-pytest-rag-cmd branch 2 times, most recently from eb43c73 to b8fc1ca Compare January 8, 2026 09:20
- Migrate to e2e pytest the `test/system/070-rag.bats` bat test.

Signed-off-by: Roberto Majadas <rmajadas@redhat.com>
@telemaco telemaco force-pushed the e2e-pytest-rag-cmd branch from b8fc1ca to cf7f78c Compare January 9, 2026 12:29
Copy link
Collaborator

@olliewalsh olliewalsh left a comment

Choose a reason for hiding this comment

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

LGTM

@olliewalsh olliewalsh merged commit 022d799 into containers:main Jan 9, 2026
33 checks passed
@telemaco telemaco linked an issue Jan 9, 2026 that may be closed by this pull request
12 tasks
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.

E2E Tests to Pytest

2 participants