Skip to content

test: add E2E tests for Tenant CR lifecycle#869

Open
somya-bhatnagar wants to merge 7 commits into
opendatahub-io:mainfrom
somya-bhatnagar:somya-e2e-match-the-new-format
Open

test: add E2E tests for Tenant CR lifecycle#869
somya-bhatnagar wants to merge 7 commits into
opendatahub-io:mainfrom
somya-bhatnagar:somya-e2e-match-the-new-format

Conversation

@somya-bhatnagar
Copy link
Copy Markdown
Contributor

@somya-bhatnagar somya-bhatnagar commented May 6, 2026

Summary

Adds E2E test suite for Tenant CR lifecycle validation as part of the test ownership reorganization (RHOAIENG-60709).

Related to https://redhat.atlassian.net/browse/RHOAIENG-59867

Changes

  • test/e2e/tests/test_tenant.py - 7 integration tests covering:

    • Tenant singleton existence
    • Ready condition and phase validation
    • Payload processing deployment checks (when Active)
    • Status contract compliance (phase, conditions)
    • Spec well-formedness
    • Kubernetes metav1 condition shape
    • False ownership prevention (MaaS CRs not owned by Tenant)
  • test/e2e/README.md - Streamlined documentation focusing on test execution

  • test/e2e/scripts/prow_run_smoke_test.sh - Enhanced to include Tenant tests in CI

Test Results

Validated on live OpenShift cluster with operator-based deployment:

  • ✅ 5 passing (contract tests, ownership validation, singleton checks)
  • ⏭️ 1 skipped (payload-processing not deployed)
  • Time: ~5s when Tenant is healthy

Test Ownership Context

This PR is part of Phase 1 (Tenant Tests) of the E2E test ownership reorganization:

  • Establishes baseline Tenant CR testing in MaaS CI
  • Validates contract between maas-controller and Tenant CR
  • Provides foundation for operator CI contract tests (Phase 2)

DSC enable/disable and Tenant deletion lifecycle remain in operator CI scope.

How to Run

cd test/e2e
export DEPLOYMENT_NAMESPACE="opendatahub"  # or wherever Tenant lives
source .venv/bin/activate
pytest tests/test_tenant.py -v

Full smoke test (includes all E2E modules):

./test/e2e/scripts/prow_run_smoke_test.sh

🤖 Generated with Claude Code

Adds comprehensive E2E test suite for validating Tenant CR behavior:

- 8 integration tests covering singleton, lifecycle, contract, and ownership
- Tests validated on live OpenShift cluster
- Properly detects when Tenant fails to reach Ready state
- Uses pytest with custom markers (unit, integration, smoke)

Test results on live cluster:
- 6 passing (contract, lifecycle, ownership validation)
- 2 skipped (payload-processing not deployed, DSC operator CI-only)
- Execution time: ~5s when Tenant is healthy

Also updates:
- test/e2e/README.md with Tenant test documentation
- prow_run_smoke_test.sh to support tenant tests

The tests successfully validated the PodMonitor RBAC and schema issues
documented in the E2E test ownership plan (RHOAIENG-60709).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Warning

Rate limit exceeded

@somya-bhatnagar has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 56 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 9a74579d-abd5-4966-bf29-aa5439734c15

📥 Commits

Reviewing files that changed from the base of the PR and between eef74cf and 0e04219.

📒 Files selected for processing (3)
  • test/e2e/README.md
  • test/e2e/scripts/prow_run_smoke_test.sh
  • test/e2e/tests/test_tenant.py
📝 Walkthrough

Walkthrough

The PR updates E2E testing infrastructure by reorganizing the README with structured Quick Start sections, updating the smoke test script to include Tenant and external models test modules in the pytest invocation, and introducing a comprehensive Tenant lifecycle test suite with helpers for cluster interaction via oc, CRUD status validation, readiness polling, and ownership protection checks.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Issues

test/e2e/tests/test_tenant.py

  1. Insufficient error handling in _oc_json() (Line 27-38): The function catches all exceptions and returns None on failure, masking failures from subprocess calls. Distinguish between JSON parse failures and command execution failures. Log the actual error for debugging.

  2. Hardcoded timeout without validation (Line 66-75): _wait_ready_true() uses default timeout of 300 seconds without bounds checking or configurable overrides. Add parameter validation or environment variable support for test duration control.

  3. Incomplete ownership validation (Line 142-152): The test_maas_user_crs_not_owned_by_tenant test checks ownerReferences but doesn't validate that ownerReferences are properly set on tenant-managed resources where expected. Test should confirm both negative (CRs not owned) and positive (control resources are owned) scenarios.

  4. Missing fixture dependency documentation: The require_tenant_crd fixture (Line 52-64) is not explicitly used in test class definitions, making dependency injection implicit and harder to trace.

test/e2e/scripts/prow_run_smoke_test.sh

  1. Assumption of module availability (Line 550-561): The script now imports test_external_models.py and test_tenant.py without verifying these files exist in the test directory or are discoverable. Add an existence check or explicit path validation.

test/e2e/README.md

  1. Incomplete environment setup guidance (Line 13-17): The SKIP_DEPLOYMENT=true example lacks documentation of required cluster state (existing tenant CRD, accessible kubeconfig). Add explicit prerequisites for skipped deployment mode.
🚥 Pre-merge checks | ✅ 4
✅ 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 'test: add E2E tests for Tenant CR lifecycle' directly and clearly describes the main change: adding end-to-end tests for Tenant Custom Resource lifecycle, which aligns with the primary changeset.
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.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

/group-test

@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

somya-bhatnagar and others added 2 commits May 7, 2026 13:32
Restores important documentation that was removed:
- Ownership guidance (MaaS CI vs Operator CI scope)
- Local prerequisites (setup instructions)
- Pytest modules table (quick reference for all test files)
- CI integration details
- External OIDC configuration

Keeps the updated test_tenant.py description reflecting the 7 tests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

/group-test

@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

/group-test

@openshift-ci openshift-ci Bot removed the approved label May 11, 2026
CI uses kustomize deployment mode, which does not create the Tenant CR
automatically (only operator-based deployments via DSC create Tenant).

Add module-level skip conditions:
1. Skip if Tenant CRD is missing
2. Skip if Tenant singleton doesn't exist

This allows the test suite to run in both kustomize mode (skips Tenant
tests) and operator mode (runs Tenant tests).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@somya-bhatnagar
Copy link
Copy Markdown
Contributor Author

Added a question on github ticket - https://redhat.atlassian.net/browse/RHOAIENG-59867?focusedCommentId=16945433

@rhods-ci-bot
Copy link
Copy Markdown

@somya-bhatnagar: The following test has Succeeded:

OCI Artifact Browser URL

View in Artifact Browser

Inspecting Test Artifacts Manually

To inspect your test artifacts manually, follow these steps:

  1. Install ORAS (see the ORAS installation guide).
  2. Download artifacts with the following commands:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/opendatahub/odh-ci-artifacts:maas-group-test-xdqdp

@somya-bhatnagar somya-bhatnagar added ready-for-review All changes are complete and CI checks have passed. approved labels May 12, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: somya-bhatnagar

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved ready-for-review All changes are complete and CI checks have passed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants