Skip to content

OLS-3219 - creating script for running e2e tests in a real cluster with real sandbox#170

Open
JoaoFula wants to merge 8 commits into
openshift:mainfrom
JoaoFula:implement-ols-3219
Open

OLS-3219 - creating script for running e2e tests in a real cluster with real sandbox#170
JoaoFula wants to merge 8 commits into
openshift:mainfrom
JoaoFula:implement-ols-3219

Conversation

@JoaoFula

@JoaoFula JoaoFula commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Add scripts/e2e-cluster.sh and scripts/e2e-lib.sh — the entry point for running the existing e2e test suite against real LLM providers (Claude, Gemini, OpenAI) instead of the mock agent.

Rather than creating a separate product-e2e test suite, this parameterizes the existing e2e tests via env vars. When E2E_PROVIDER is set, helpers_test.go creates real provider fixtures (Secret, LLMProvider, Agent CRs with actual credentials). When unset, the existing mock agent path is unchanged — PR/integration CI runs are unaffected.

What's included

  • scripts/e2e-cluster.sh — orchestrator that parses args, checks prerequisites (oc, make, go, jq), deploys the operator idempotently via install-operator.sh, then loops through each provider: creates fixtures, runs make test-e2e with provider env vars, collects artifacts, cleans up, and reports per-provider pass/fail
  • scripts/e2e-lib.sh — reusable functions for operator lifecycle, fixture CRUD, artifact collection, and logging
  • test/e2e/helpers_test.go — new createRealProviderFixtures() path that reads E2E_PROVIDER, E2E_MODEL, E2E_PROVIDER_KEY_PATH (and Vertex-specific vars) to create properly-typed CRs with real credentials; pollTimeout is now overridable via E2E_POLL_TIMEOUT env var

Usage

# Run against specific providers:
IMG=quay.io/... VERTEX_PROVIDER_KEY_PATH=/path/to/sa.json \
  VERTEX_PROJECT_ID=my-project OPENAI_PROVIDER_KEY_PATH=/path/to/key \
  bash scripts/e2e-cluster.sh claude openai

# Run all providers (default: claude gemini openai):
bash scripts/e2e-cluster.sh

Provider mapping

Provider LLMProvider type Default model
claude GoogleCloudVertex (Anthropic) claude-sonnet-4-6
gemini GoogleCloudVertex (Google) gemini-2.5-flash
openai OpenAI gpt-4.1-mini

Jira: https://redhat.atlassian.net/browse/OLS-3219

@coderabbitai

coderabbitai Bot commented Jun 19, 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: Enterprise

Run ID: 2655c108-922f-4dc7-b3bf-5e962619f319

📥 Commits

Reviewing files that changed from the base of the PR and between 4fbff65 and 67bb6fb.

📒 Files selected for processing (3)
  • scripts/e2e-cluster.sh
  • scripts/e2e-lib.sh
  • test/e2e/helpers_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/lightspeed-agentic-sandbox (manual)
🚧 Files skipped from review as they are similar to previous changes (3)
  • scripts/e2e-cluster.sh
  • scripts/e2e-lib.sh
  • test/e2e/helpers_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Expanded end-to-end test infrastructure to run against multiple LLM providers (Claude, Gemini, OpenAI).
    • Added provider-aware orchestration with per-provider setup, teardown, and PASS/FAIL reporting.
    • Made E2E polling configurable via E2E_POLL_TIMEOUT and enabled real-provider fixtures driven by environment variables (including model selection and credential handling).
    • Improved test artifact collection when ARTIFACT_DIR is set, capturing relevant cluster outputs per provider.

Walkthrough

Adds scripts/e2e-lib.sh (Bash helper library with logging, prerequisite checks, operator lifecycle, provider fixture management, and artifact collection), scripts/e2e-cluster.sh (orchestration script running make test-e2e against multiple LLM providers), and updates test/e2e/helpers_test.go to route fixture creation to real-provider CRs when E2E_PROVIDER is set.

Changes

E2E Real-Provider Testing Infrastructure

Layer / File(s) Summary
e2e-lib.sh: Logging, prerequisites, snapshot parsing
scripts/e2e-lib.sh
Adds log_info/warn/error helpers, check_prerequisites() verifying oc/make/go/jq and OpenShift login, and parse_snapshot() resolving IMG from SNAPSHOT JSON via jq or pre-set env var.
e2e-lib.sh: Operator deployment and lifecycle
scripts/e2e-lib.sh
Adds deploy_operator() with Available-state guard, wait_for_deployment() with timeout diagnostics, and cleanup_operator() gated on _OPERATOR_DEPLOYED_BY_SCRIPT.
e2e-lib.sh: Provider model resolution and fixture lifecycle
scripts/e2e-lib.sh
Implements resolve_model() for provider-based defaults, create_provider_fixtures() producing Vertex/OpenAI LLMProvider + Agent CRs with credential secrets, cleanup_provider_fixtures() with --ignore-not-found, and collect_artifacts() exporting logs and CR YAMLs per provider.
helpers_test.go: Real-provider fixture support
test/e2e/helpers_test.go
Routes createFixtures() to createRealProviderFixtures() when E2E_PROVIDER is set; builds LLMProvider, Agent, ApprovalPolicy, and Secret from E2E_PROVIDER/E2E_MODEL/E2E_PROVIDER_KEY_PATH; updates fake fixture path with namespace creation guards; makes pollTimeout configurable via E2E_POLL_TIMEOUT environment variable.
e2e-cluster.sh: Multi-provider test orchestration
scripts/e2e-cluster.sh
Orchestrates e2e testing across multiple LLM providers: deploys operator once, runs provider-specific test loop with fault tolerance and per-provider exit code tracking, collects per-provider logs and artifacts, and reports aggregated PASS/FAIL results table before exiting with failure status if any provider failed.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% 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
Title check ✅ Passed The title clearly summarizes the main change: adding a script to run e2e tests against real LLM providers in a real cluster environment.
Description check ✅ Passed The description is directly related to the changeset, providing clear context about what was added and why, with concrete examples of usage and provider mapping.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@openshift-ci openshift-ci Bot requested review from harche and xrajesh June 19, 2026 08:35
@openshift-ci

openshift-ci Bot commented Jun 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign joshuawilson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@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: 3

🧹 Nitpick comments (1)
scripts/e2e-cluster.sh (1)

72-72: 🏗️ Heavy lift

Consolidate fixture ownership to one layer.

create_provider_fixtures here and createRealProviderFixtures in test/e2e/helpers_test.go both create provider resources. Keeping both paths risks drift and cross-layer contract breaks. Prefer one source of truth and let the other layer only pass configuration.

🤖 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 `@scripts/e2e-cluster.sh` at line 72, The call to create_provider_fixtures in
the bash script duplicates the functionality of createRealProviderFixtures in
the Go test file, creating two separate sources of truth for provider resource
creation that risk diverging. Consolidate fixture ownership to a single layer by
removing one of these creation paths and ensuring the other layer (bash script
or Go tests) handles all provider fixture creation, while the alternate layer
focuses only on passing necessary configuration parameters to the primary
creation mechanism.
🤖 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 `@scripts/e2e-cluster.sh`:
- Around line 81-83: The E2E_POLL_TIMEOUT variable is hardcoded to "20m" in the
provider runs section, preventing caller environment overrides. Change the
hardcoded assignment `E2E_POLL_TIMEOUT="20m"` to use the same pattern as
VERTEX_PROJECT_ID and VERTEX_REGION by using parameter expansion syntax to allow
environment variable override with a default fallback. Apply this same fix to
all occurrences mentioned in lines 90-92 where similar hardcoding exists.

In `@scripts/e2e-lib.sh`:
- Around line 98-103: The cleanup_operator() function runs `make undeploy` from
the caller's current working directory without ensuring it's in the repository
root, which can cause the command to fail silently due to the error suppression.
To fix this, modify the function to either change directory to the repository
root before executing the make undeploy command, or use an absolute path to
invoke make from the correct location. Ensure the directory change happens
before the `make undeploy ignore-not-found=true` call and that it properly
handles the case where the script is invoked from outside the repo root so the
operator is actually cleaned up instead of silently failing.

In `@test/e2e/helpers_test.go`:
- Around line 300-301: The error returned by c.Create(ctx, stagingNS) is being
ignored using the blank identifier, which masks potential cluster, RBAC, or API
failures and makes test failures harder to diagnose. Instead of ignoring the
error, explicitly check the error returned by c.Create and fail the test fast if
it is not nil, except when the error is an AlreadyExists error which can be
safely ignored. This ensures that any real failures during namespace creation
are caught immediately rather than causing cryptic failures later in the test.

---

Nitpick comments:
In `@scripts/e2e-cluster.sh`:
- Line 72: The call to create_provider_fixtures in the bash script duplicates
the functionality of createRealProviderFixtures in the Go test file, creating
two separate sources of truth for provider resource creation that risk
diverging. Consolidate fixture ownership to a single layer by removing one of
these creation paths and ensuring the other layer (bash script or Go tests)
handles all provider fixture creation, while the alternate layer focuses only on
passing necessary configuration parameters to the primary creation mechanism.
🪄 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: 98c0d768-76ff-49d4-baf8-ed401bbeb42f

📥 Commits

Reviewing files that changed from the base of the PR and between 7a57ce7 and 4fbff65.

📒 Files selected for processing (3)
  • scripts/e2e-cluster.sh
  • scripts/e2e-lib.sh
  • test/e2e/helpers_test.go
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/lightspeed-agentic-sandbox (manual)

Comment thread scripts/e2e-cluster.sh Outdated
Comment thread scripts/e2e-lib.sh
Comment thread test/e2e/helpers_test.go Outdated
addressing comments
@JoaoFula JoaoFula force-pushed the implement-ols-3219 branch from 4fbff65 to 67bb6fb Compare June 19, 2026 09:54
@openshift-ci

openshift-ci Bot commented Jun 19, 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.

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.

1 participant