Skip to content

OLS-3327 - Bedrock tests - #2980

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
JoaoFula:add-tests-bedrock
Aug 11, 2026
Merged

OLS-3327 - Bedrock tests#2980
openshift-merge-bot[bot] merged 4 commits into
openshift:mainfrom
JoaoFula:add-tests-bedrock

Conversation

@JoaoFula

@JoaoFula JoaoFula commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

add bedrock test files and adaptations to existing scripts

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Tests

    • Added end-to-end coverage for Bedrock Anthropic and DeepSeek models, including tool-calling scenarios.
    • Expanded coverage for direct IAM and role-based authentication, including smoke tests.
    • Added configuration fixtures for filtering, authentication, logging, and data collection.
    • Updated invalid-question checks to accept additional valid responses.
  • Documentation

    • Updated Bedrock testing guidance, model coverage, configuration examples, and authentication options.
  • Chores

    • Improved automated setup of Bedrock IAM credentials for end-to-end testing.

@openshift-ci
openshift-ci Bot requested review from bparees and xrajesh July 1, 2026 09:09
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 811f9cab-b92a-4c34-8747-4751d843e127

📥 Commits

Reviewing files that changed from the base of the PR and between f5a1de2 and 15585e7.

📒 Files selected for processing (6)
  • .ai/spec/how/e2e-bedrock.md
  • tests/e2e/test_query_endpoint.py
  • tests/e2e/test_streaming_query_endpoint.py
  • tests/e2e/utils/ols_installer.py
  • tests/scripts/test-e2e-cluster-periodics.sh
  • tests/scripts/test-e2e-cluster.sh
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/scripts/test-e2e-cluster-periodics.sh
  • tests/e2e/utils/ols_installer.py
  • tests/scripts/test-e2e-cluster.sh
  • tests/e2e/test_query_endpoint.py

📝 Walkthrough

Walkthrough

Adds Bedrock OLSConfig fixtures for Anthropic, DeepSeek, and tool-calling scenarios. Adds IAM credential secret handling and wires Bedrock suites into e2e scripts. Broadens invalid-question response assertions.

Changes

Bedrock end-to-end coverage

Layer / File(s) Summary
Bedrock configurations and specification
.ai/spec/how/e2e-bedrock.md, tests/config/operator_install/olsconfig.crd.bedrock_*.yaml
Updates Bedrock coverage from OpenAI to Anthropic and DeepSeek. Adds model routing and tool-calling configurations.
Bedrock IAM credential provisioning
tests/e2e/utils/ols_installer.py, tests/scripts/test-e2e-cluster*.sh
Reads direct IAM and assume-role environment variables. Validates required values and creates the llmcreds secret for Bedrock providers.
Bedrock suite execution and assertions
tests/scripts/test-e2e-cluster*.sh, tests/e2e/test_query_endpoint.py, tests/e2e/test_streaming_query_endpoint.py
Adds Anthropic, DeepSeek, IAM-role, and tool-calling suites. Accepts additional invalid-question response wording.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2EScript as e2e cluster script
  participant Installer as ols_installer.py
  participant Environment as test environment
  participant Cluster as OpenShift cluster
  E2EScript->>Installer: create_secrets(Bedrock provider)
  Installer->>Environment: Read IAM or assume-role credentials
  Installer->>Cluster: Create llmcreds secret
  E2EScript->>Cluster: Run Bedrock suite
  Cluster-->>E2EScript: Return query responses
Loading

Suggested reviewers: bparees, xrajesh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the pull request as adding Bedrock tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/e2e/utils/ols_installer.py`:
- Around line 288-291: The Bedrock credential selection in the helper that maps
`creds` to env keys currently treats every non-`iam_role` value as IAM, which
can hide bad discriminator values and break `create_secrets()` recovery. Update
the branching in the Bedrock env-key helper to accept only the supported
credential modes (`iam` and `iam_role`) and raise a clear failure for anything
else, so typos in `PROVIDER_KEY_PATH` do not silently choose the wrong key set.

In `@tests/scripts/test-e2e-cluster-periodics.sh`:
- Around line 75-76: The Bedrock tool-calling run is placed too early in the
periodic suite order, which can leave the tool-calling CR shape active for later
suites. Move the bedrock_deepseek_tool_calling run into the existing
tool_calling section in test-e2e-cluster-periodics.sh, alongside the other
tool-calling suites, so rhoai_vllm, rhelai_vllm, and certificates still run
after the non-tool-calling setup. Use the run_suite calls for
bedrock_deepseek_tool_calling and the surrounding tool_calling section as the
unique markers when relocating it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d69150a1-6347-4793-b261-2298cffdd1f4

📥 Commits

Reviewing files that changed from the base of the PR and between 3442d5e and 0fe24bf.

📒 Files selected for processing (6)
  • tests/config/operator_install/olsconfig.crd.bedrock_anthropic.yaml
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek.yaml
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek_tool_calling.yaml
  • tests/e2e/utils/ols_installer.py
  • tests/scripts/test-e2e-cluster-periodics.sh
  • tests/scripts/test-e2e-cluster.sh

Comment thread tests/e2e/utils/ols_installer.py
Comment thread tests/scripts/test-e2e-cluster-periodics.sh Outdated
@JoaoFula
JoaoFula force-pushed the add-tests-bedrock branch from 0fe24bf to 75f3e95 Compare July 1, 2026 09:20
addressing comments

addressing comments
@JoaoFula
JoaoFula force-pushed the add-tests-bedrock branch from 75f3e95 to 13fdbd7 Compare July 1, 2026 09:24
@JoaoFula

JoaoFula commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@JoaoFula

JoaoFula commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

Copy link
Copy Markdown
Contributor Author

test_invalid_question failed because deepseek rejected answering "how to make a burger" in a different way from any other provider.

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/e2e/test_query_endpoint.py (1)

47-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

LGTM for the assertion broadening, but consider extracting the duplicated regex.

The r"(sorry|questions|assist|help)" pattern is now duplicated in two test functions here and again in tests/e2e/test_streaming_query_endpoint.py (line 76). If the accepted-keyword list changes again, all three locations must be updated in lockstep. Extracting a module-level constant (e.g., INVALID_QUESTION_RESPONSE_PATTERN) would keep them aligned and reduce the risk of divergence.

♻️ Suggested refactor: extract shared regex constant
+# Common pattern for responses to invalid/non-OCP questions.
+INVALID_QUESTION_RESPONSE_PATTERN = r"(sorry|questions|assist|help)"
+
 def test_invalid_question():
     """Check the REST API /v1/query with POST HTTP method for invalid question."""
     ...
     assert re.search(
-        r"(sorry|questions|assist|help)",
+        INVALID_QUESTION_RESPONSE_PATTERN,
         json_response["response"],
         re.IGNORECASE,
     )
     ...
 def test_invalid_question_without_conversation_id():
     ...
     assert re.search(
-        r"(sorry|questions|assist|help)",
+        INVALID_QUESTION_RESPONSE_PATTERN,
         json_response["response"],
         re.IGNORECASE,
     )

Also applies to: 77-81

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/e2e/test_query_endpoint.py` around lines 47 - 51, Extract the
duplicated invalid-response regex into a shared module-level constant such as
INVALID_QUESTION_RESPONSE_PATTERN, then update both assertions in
tests/e2e/test_query_endpoint.py and the corresponding assertion in
test_streaming_query_endpoint.py to reference it, preserving the existing
case-insensitive matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/e2e/test_query_endpoint.py`:
- Around line 47-51: Extract the duplicated invalid-response regex into a shared
module-level constant such as INVALID_QUESTION_RESPONSE_PATTERN, then update
both assertions in tests/e2e/test_query_endpoint.py and the corresponding
assertion in test_streaming_query_endpoint.py to reference it, preserving the
existing case-insensitive matching.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bb9f8059-cda7-49d1-98a7-726583ac3b4f

📥 Commits

Reviewing files that changed from the base of the PR and between 0fe24bf and 5789793.

📒 Files selected for processing (8)
  • tests/config/operator_install/olsconfig.crd.bedrock_anthropic.yaml
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek.yaml
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek_tool_calling.yaml
  • tests/e2e/test_query_endpoint.py
  • tests/e2e/test_streaming_query_endpoint.py
  • tests/e2e/utils/ols_installer.py
  • tests/scripts/test-e2e-cluster-periodics.sh
  • tests/scripts/test-e2e-cluster.sh
✅ Files skipped from review due to trivial changes (1)
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek.yaml
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/config/operator_install/olsconfig.crd.bedrock_anthropic.yaml
  • tests/config/operator_install/olsconfig.crd.bedrock_deepseek_tool_calling.yaml
  • tests/scripts/test-e2e-cluster.sh
  • tests/e2e/utils/ols_installer.py
  • tests/scripts/test-e2e-cluster-periodics.sh

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

3 similar comments
@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

…p over assist

adding a wait for ols and a retry to generated_service_certs_rotation, changed check condition for test_ca_service_certs_rotation and increased timeout (OKP pod takes longer to run)
@JoaoFula
JoaoFula force-pushed the add-tests-bedrock branch from 5789793 to 6b32244 Compare July 27, 2026 06:46
@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

Copy link
Copy Markdown
Contributor Author

failure was from known flakiness being investigated in parallel. retesting

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

3 similar comments
@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

@JoaoFula

JoaoFula commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@JoaoFula

JoaoFula commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@JoaoFula

JoaoFula commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@blublinsky blublinsky 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.

ensure_bedrock_iam_secret can silently fail: unlike other providers where create_secrets always creates llmcreds (even with creds == "empty"), for Bedrock this function IS the only path that creates llmcreds — so a silent skip (when env vars are missing) means no credentials exist at all after create_secrets returns.

Consider raising instead of returning when the required env vars are absent — the test will fail anyway, and an explicit error with the missing variable names is more helpful than a pod crash minutes later when the operator cannot mount the secret.

@JoaoFula

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@blublinsky

Copy link
Copy Markdown
Contributor

/retest

@blublinsky blublinsky 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.

Invalid-question regex: avoid global help

Agree that DeepSeek may need different refusal wording, but adding bare help to the shared pattern weakens the check for all providers. A non-refusal like "I can help you make a burger" would now pass.

Prefer scoping the DeepSeek quirk instead of diluting every suite:

  1. Gate on PROVIDER (e.g. allow help only for bedrock_deepseek), or
  2. Use a tighter DeepSeek-oriented phrase if refusals are consistent (e.g. can't help / cannot help).

Comment thread tests/e2e/test_query_endpoint.py Outdated
# Below assert is minimal due to model randomness.
assert re.search(
r"(sorry|questions|assist)",
r"(sorry|questions|assist|help)",

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.

Adding bare help here applies to every provider suite, not just DeepSeek. Prefer a PROVIDER-gated pattern (or a tighter phrase like can't help) rather than weakening this assert globally.

Same change is also at line 78 in this file and in test_streaming_query_endpoint.py.

Comment thread tests/e2e/test_query_endpoint.py Outdated
Comment thread tests/e2e/test_streaming_query_endpoint.py Outdated

@blublinsky blublinsky 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.

Nit (non-blocking): document Bedrock PROVIDER_KEY_PATH overload in script headers

The new Bedrock call sites correctly note that PROVIDER_KEY_PATH carries "iam" / "iam_role" instead of a file path. The script headers (line 5 in both test-e2e-cluster.sh and test-e2e-cluster-periodics.sh) still say it is only a credentials file path, and they do not list the required BEDROCK_AWS_* / BEDROCK_ROLE_* env vars.

Docs polish only — not a blocker.

Comment thread tests/scripts/test-e2e-cluster.sh
Comment thread tests/scripts/test-e2e-cluster-periodics.sh
changing gemini model to valid one

addressing comments
@blublinsky

blublinsky commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review note: OpenAI-prefix Bedrock coverage gap

Priority: must-fix (vs OLS-3327 / .ai/spec/how/e2e-bedrock.md)

What the AC/spec ask for

Bedrock load() has two distinct model-prefix branches that e2e was meant to cover:

  1. anthropic.*ChatBedrockConverse
  2. openai.*ChatOpenAI with base_url={mantle}/openai/v1 and use_responses_api=True

The planned second family was bedrock_openai (e.g. openai.gpt-5.4), plus iam_role smoke and tool_calling for that family.

What this PR does

Suite Model Path exercised
bedrock_anthropic anthropic.claude-sonnet-4-6 Anthropic / Converse ✅
bedrock_deepseek deepseek.v3.2 ChatOpenAI on {url}/v1, use_responses_api=False

deepseek.v3.2 does not start with openai., so it never enters the OpenAI-prefix branch in ols/src/llms/providers/bedrock.py (/openai/v1 + Responses API). It hits the default ChatOpenAI path instead — related, but not the branch named in the AC.

Why it matters

  • Anthropic coverage is fine (sonnet vs opus is a model choice on the same path).
  • DeepSeek still validates Bedrock + IAM + a ChatOpenAI-style client.
  • It does not e2e-prove Mantle’s OpenAI-compatible Responses endpoint wiring. A regression there would not be caught by these suites.

This is a coverage / AC mismatch, not a broken test run (e2e-ols-cluster already passed with DeepSeek).

How to resolve

Either:

  1. Add bedrock_openai (+ iam_role smoke + tool_calling) with an openai.* model as in the spec, or
  2. Keep DeepSeek and update OLS-3327 AC + .ai/spec/how/e2e-bedrock.md to document DeepSeek / generic /v1 ChatOpenAI as the second family, and mark openai.* Responses coverage as out of scope or deferred.

Until one of those is done, merge either ships incomplete AC or leaves the written plan out of date.


AI-assisted review finding — please validate before treating as a blocking request.

@blublinsky

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: blublinsky

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

@JoaoFula: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 6a90271 into openshift:main Aug 11, 2026
9 of 11 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants