Skip to content

Fix fleet e2e test SL count off-by-one in port-forward mode - #272

Open
redhat-chai-bot wants to merge 1 commit into
openshift:masterfrom
redhat-chai-bot:fix/fleet-e2e-port-forward
Open

Fix fleet e2e test SL count off-by-one in port-forward mode#272
redhat-chai-bot wants to merge 1 commit into
openshift:masterfrom
redhat-chai-bot:fix/fleet-e2e-port-forward

Conversation

@redhat-chai-bot

@redhat-chai-bot redhat-chai-bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the HCP fleet mode e2e test failure (Expected SL count: 27, Got SL count: 26) when running in Prow CI with OCM_AGENT_URL port-forward mode.

Root Cause

When OCM_AGENT_URL is set (Prow CI uses localhost:8081 via kubectl port-forward), the fleet mode test sends alerts to the regular ocm-agent endpoint instead of the ocm-agent-fleet endpoint. The regular ocm-agent ignores fleet alerts, so no service log is created.

The issue is in the fleet test's URL selection logic — the ocmAgentFleetURL override is skipped when OCM_AGENT_URL is set. The ocm-agent-fleet deployment is created dynamically by the test, so the step script's static PORT_FORWARD_SVC cannot reach it.

Fix

Both env var AND test-level port-forward (Option C):

  1. OCM_AGENT_FLEET_URL env var support — If set, overrides the fleet URL (like OCM_AGENT_URL does for the regular endpoint).

  2. Automatic kubectl port-forward — When OCM_AGENT_URL is set but OCM_AGENT_FLEET_URL is not, the test automatically runs kubectl port-forward svc/ocm-agent-fleet 8082:8081 after creating the fleet deployment, and sets ocmAgentFleetURL to localhost:8082. The port-forward process is cleaned up via defer cmd.Process.Kill().

  3. Fleet URL used for PostAlert — The fleet test now uses ocmAgentFleetURL (not ocmAgentURL) when posting fleet alerts, ensuring alerts reach the fleet-mode ocm-agent regardless of the operating mode.

Operating Modes

  • In-cluster (osde2e): Neither env var set — uses service DNS names (unchanged)
  • Port-forward (Prow): OCM_AGENT_URL set — auto port-forwards fleet svc to localhost:8082
  • Explicit fleet URL: Both env vars set — uses provided URLs directly

Testing

  • make lint — 0 issues
  • make test — all unit tests pass

Ref: ROSAENG-61843


AI-generated. Review for accuracy.

@dustman9000 requested via Chai Bot

When OCM_AGENT_URL is set (Prow CI port-forward mode), the HCP fleet
test was sending alerts to the regular ocm-agent instead of the
fleet-mode ocm-agent, causing service log count mismatches.

The root cause was that the fleet test used ocmAgentURL (overridden by
OCM_AGENT_URL to point at the regular agent) for PostAlert, while only
falling back to ocmAgentFleetURL when OCM_AGENT_URL was unset.

This fix:
- Adds OCM_AGENT_FLEET_URL env var support for explicit fleet URL override
- When OCM_AGENT_URL is set but OCM_AGENT_FLEET_URL is not, starts a
  kubectl port-forward to svc/ocm-agent-fleet on port 8082 and uses
  http://localhost:8082 as the fleet URL
- Cleans up the port-forward process via defer when the fleet test ends
- Uses ocmAgentFleetURL consistently for all fleet-mode operations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 4fa318d2-e6a6-42c8-bab3-7d2a96ac76b6


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

@openshift-ci
openshift-ci Bot requested review from bmeng and ravitri September 12, 2026 18:09
@openshift-ci

openshift-ci Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: redhat-chai-bot
Once this PR has been reviewed and has the lgtm label, please assign ajpantuso 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

@openshift-ci

openshift-ci Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

@redhat-chai-bot: 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.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.46%. Comparing base (b6bade8) to head (4a3c040).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #272   +/-   ##
=======================================
  Coverage   56.46%   56.46%           
=======================================
  Files          23       23           
  Lines        1934     1934           
=======================================
  Hits         1092     1092           
  Misses        786      786           
  Partials       56       56           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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