Skip to content

[WIP] CORENET-7073: Run OTE tests against KIND cluster#3254

Open
pperiyasamy wants to merge 2 commits into
openshift:mainfrom
pperiyasamy:ote_kind_testing
Open

[WIP] CORENET-7073: Run OTE tests against KIND cluster#3254
pperiyasamy wants to merge 2 commits into
openshift:mainfrom
pperiyasamy:ote_kind_testing

Conversation

@pperiyasamy

@pperiyasamy pperiyasamy commented Jun 17, 2026

Copy link
Copy Markdown
Member

This PR enables the OTE binary to run E2E tests against kind cluster using SSH-based remote execution. It parameterizes the kind infrastructure provider to accept a Runner interface, allowing commands to be executed either locally (DirectRunner) or remotely via SSH (SSHRunner).

TODO: Run a test container that includes the OTE binary, SSH configuration, and necessary environment variables set, E2E tests against a remote kind cluster.

Summary by CodeRabbit

  • Refactor

    • Centralized cluster infrastructure initialization logic into a dedicated helper function for improved maintainability.
    • Refactored kind provider construction to use dependency injection for better testability and flexibility.
    • Updated container runtime type exports for improved accessibility across test infrastructure modules.
  • New Features

    • Added SSH-based support for remote kind cluster operations, including validation of connectivity and configuration.

Enables both local and SSH based command execution by accepting
Runner as a parameter instead of creating it internally.

TODO: Consume this change from an upstream commit.

Signed-off-by: Periyasamy Palanisamy <pepalani@redhat.com>
Enables OTE binary to run E2E tests against kind cluster via SSH.
Uses KIND_HOST, KIND_HOST_SSH_KEY and CONTAINER_RUNTIME environment
variables for remote host connectivity.

Signed-off-by: Periyasamy Palanisamy <pepalani@redhat.com>
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 17, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@pperiyasamy: This pull request references CORENET-7073 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

This PR enables the OTE binary to run E2E tests against kind cluster using SSH-based remote execution. It parameterizes the kind infrastructure provider to accept a Runner interface, allowing commands to be executed either locally (DirectRunner) or remotely via SSH (SSHRunner).

TODO: Run a test container that includes the OTE binary, SSH configuration, and necessary environment variables set, E2E tests against a remote kind cluster.

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 openshift-eng/jira-lifecycle-plugin repository.

@pperiyasamy

Copy link
Copy Markdown
Member Author

cc @jluhrsen

@openshift-ci openshift-ci Bot requested a review from jcaamano June 17, 2026 08:05
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Walkthrough

ContainerRuntime and GetContainerRuntime are exported from the kind provider package. kind.New is refactored to accept an explicit ContainerRuntime and api.Runner via dependency injection, with PreloadImages migrated to use the injected runner. A new InitializeKindInfra function is added for OpenShift test binaries, connecting over SSH using env-var-configured credentials. Both call sites (main.go and e2e_suite_test.go) are updated accordingly.

Changes

Kind Provider DI and OpenShift SSH Init

Layer / File(s) Summary
Export ContainerRuntime and GetContainerRuntime
test/e2e/infraprovider/providers/kind/runtime.go
containerRuntime type and getContainerRuntime() are renamed/exported as ContainerRuntime and GetContainerRuntime(), enabling external consumers to retrieve and pass the runtime as a typed dependency.
Refactor kind.New to accept injected ContainerRuntime and Runner
test/e2e/infraprovider/providers/kind/kind.go
kind struct gains ce and cmdRunner fields; New signature changes to accept both; PreloadImages pull/save/load commands migrate from exec.Command to cmdRunner.Run.
SSH-based InitializeKindInfra for OpenShift
openshift/test/infraprovider/kind.go
Adds InitializeKindInfra, hostSshCmdRunner, findKindHostSSHKeyPath, and validateSSHConnection to read KIND_HOST/KIND_HOST_SSH_KEY env vars, build an SSH runner, validate connectivity, and return a configured kind Provider.
Wire initializeInfraProvider in main.go and e2e suite
openshift/cmd/ovn-kubernetes-tests-ext/main.go, test/e2e/e2e_suite_test.go
main.go introduces initializeInfraProvider helper selecting kind vs OCP path (sets ocpInfra only for OCP) and delegates to it from main(); e2e_suite_test.go passes GetContainerRuntime() and NewDirectRunner() into kind.New.

Sequence Diagram(s)

sequenceDiagram
  participant main as main() / BeforeSuite
  participant initInfra as initializeInfraProvider
  participant InitializeKindInfra
  participant hostSshCmdRunner
  participant kindNew as kind.New(ce, runner)

  rect rgba(100, 150, 255, 0.5)
    Note over main,kindNew: OpenShift test binary (kind cluster)
    main->>initInfra: initializeInfraProvider(cfg)
    initInfra->>InitializeKindInfra: InitializeKindInfra()
    InitializeKindInfra->>hostSshCmdRunner: build SSH runner from KIND_HOST + KIND_HOST_SSH_KEY
    hostSshCmdRunner-->>InitializeKindInfra: ssh.Runner
    InitializeKindInfra->>kindNew: New(containerRuntimeExec, sshRunner)
    kindNew-->>InitializeKindInfra: api.Provider
    InitializeKindInfra-->>initInfra: api.Provider
    initInfra-->>main: nil (infraprovider set)
  end

  rect rgba(100, 200, 100, 0.5)
    Note over main,kindNew: e2e suite (direct/local kind cluster)
    main->>kindNew: New(GetContainerRuntime(), NewDirectRunner())
    kindNew-->>main: api.Provider
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hopping through SSH keys and kind,
A runner injected — no exec left behind!
The infra provider now knows its host,
With echo test pings from coast to coast.
ContainerRuntime exported with pride,
The rabbit has wired each call inside! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title references CORENET-7073 and describes enabling OTE tests against KIND clusters, which aligns with the main objectives of parameterizing the kind infrastructure provider and adding SSH-based remote execution support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot requested a review from martinkennelly June 17, 2026 08:05
@openshift-ci

openshift-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pperiyasamy
Once this PR has been reviewed and has the lgtm label, please assign abhat 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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/e2e/infraprovider/providers/kind/kind.go (1)

99-103: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use runner-based context lookup for cluster name in remote mode.

Line 100 calls kindClusterName(), but Line 142 resolves context via local exec.Command. In SSH mode, preload/load commands run on the remote host while cluster name is discovered locally, which can produce an empty or wrong name and break image preload targeting.

💡 Proposed fix
@@
-import (
+import (
 	"context"
 	"fmt"
 	"os"
-	"os/exec"
 	"strings"
 	"time"
@@
-	clusterName := kindClusterName()
+	clusterName := k.kindClusterName()
@@
-func kindClusterName() string {
-	currentCtx, err := exec.Command("kubectl", "config", "current-context").CombinedOutput()
+func (k *kind) kindClusterName() string {
+	currentCtx, err := k.cmdRunner.Run("kubectl", "config", "current-context")
 	if err != nil {
 		return ""
 	}
-	ctx := strings.TrimSpace(string(currentCtx))
+	ctx := strings.TrimSpace(currentCtx)
 	// KIND contexts are named "kind-<cluster-name>"
 	if strings.HasPrefix(ctx, "kind-") {
 		return strings.TrimPrefix(ctx, "kind-")
 	}
 	return ""
 }

Also applies to: 141-149

🤖 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 `@test/e2e/infraprovider/providers/kind/kind.go` around lines 99 - 103, The
`PreloadImages` method calls `kindClusterName()` locally to determine the
cluster name on line 100, but the image preload commands around lines 141-149
execute on the remote host via exec.Command. In SSH/remote mode, this causes the
cluster name to be resolved locally while commands run remotely, producing an
empty or incorrect name. Replace the local `kindClusterName()` call with a
runner-based context lookup that resolves the cluster name in the same execution
context (remote or local) where the preload commands will actually be executed,
ensuring consistency between cluster name discovery and command execution.
🤖 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 `@openshift/cmd/ovn-kubernetes-tests-ext/main.go`:
- Around line 83-99: The deploymentconfig.Set() call using
ocpdeploymentconfig.New() is currently unconditional and applies to both kind
and OpenShift infrastructure types, but it should be provider-specific. Move the
deployment config initialization inside the conditional blocks: for the kind
provider branch (within the if infraprovider.IsKind() block), call
deploymentconfig.Set() with deploymentkind.New(), and for the OpenShift provider
branch (in the else block after ocpinfraprovider.New()), call
deploymentconfig.Set() with ocpdeploymentconfig.New(). This ensures kind
clusters use kind-specific deployment configuration while OpenShift clusters use
OpenShift-specific deployment configuration.

---

Outside diff comments:
In `@test/e2e/infraprovider/providers/kind/kind.go`:
- Around line 99-103: The `PreloadImages` method calls `kindClusterName()`
locally to determine the cluster name on line 100, but the image preload
commands around lines 141-149 execute on the remote host via exec.Command. In
SSH/remote mode, this causes the cluster name to be resolved locally while
commands run remotely, producing an empty or incorrect name. Replace the local
`kindClusterName()` call with a runner-based context lookup that resolves the
cluster name in the same execution context (remote or local) where the preload
commands will actually be executed, ensuring consistency between cluster name
discovery and command execution.
🪄 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.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 3731e960-79d9-4097-b35d-e41e8795fbce

📥 Commits

Reviewing files that changed from the base of the PR and between 1061de7 and d5f1796.

📒 Files selected for processing (5)
  • openshift/cmd/ovn-kubernetes-tests-ext/main.go
  • openshift/test/infraprovider/kind.go
  • test/e2e/e2e_suite_test.go
  • test/e2e/infraprovider/providers/kind/kind.go
  • test/e2e/infraprovider/providers/kind/runtime.go

Comment on lines +83 to +99
if infraprovider.IsKind() {
infra, err := ocpinfraprovider.InitializeKindInfra()
if err != nil {
return fmt.Errorf("failed to initialize kind infrastructure: %w", err)
}
infraprovider.Set(infra)
} else {
infra, err := ocpinfraprovider.New(cfg)
if err != nil {
return fmt.Errorf("failed to initialize OpenShift infrastructure: %w", err)
}
infraprovider.Set(infra)
// Set ocpInfra only for OpenShift clusters (not for kind)
ocpInfra = infra
}
deploymentconfig.Set(ocpdeploymentconfig.New())
return nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Set deployment config per provider type (kind vs OpenShift).

Line 98 unconditionally applies ocpdeploymentconfig.New(), including the kind branch. That conflicts with the kind test path (see test/e2e/e2e_suite_test.go, Line 74 using deploymentkind.New()), and can route kind runs through OpenShift-specific deployment assumptions.

💡 Proposed fix
@@
 import (
 	"fmt"
 	"os"
 	"strings"
@@
 	"github.com/ovn-kubernetes/ovn-kubernetes/test/e2e/deploymentconfig"
+	deploymentkind "github.com/ovn-kubernetes/ovn-kubernetes/test/e2e/deploymentconfig/configs/kind"
 	"github.com/ovn-kubernetes/ovn-kubernetes/test/e2e/infraprovider"
@@
 func initializeInfraProvider(cfg *rest.Config) error {
 	if infraprovider.IsKind() {
 		infra, err := ocpinfraprovider.InitializeKindInfra()
 		if err != nil {
 			return fmt.Errorf("failed to initialize kind infrastructure: %w", err)
 		}
 		infraprovider.Set(infra)
+		deploymentconfig.Set(deploymentkind.New())
 	} else {
 		infra, err := ocpinfraprovider.New(cfg)
 		if err != nil {
 			return fmt.Errorf("failed to initialize OpenShift infrastructure: %w", err)
 		}
 		infraprovider.Set(infra)
 		// Set ocpInfra only for OpenShift clusters (not for kind)
 		ocpInfra = infra
+		deploymentconfig.Set(ocpdeploymentconfig.New())
 	}
-	deploymentconfig.Set(ocpdeploymentconfig.New())
 	return nil
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if infraprovider.IsKind() {
infra, err := ocpinfraprovider.InitializeKindInfra()
if err != nil {
return fmt.Errorf("failed to initialize kind infrastructure: %w", err)
}
infraprovider.Set(infra)
} else {
infra, err := ocpinfraprovider.New(cfg)
if err != nil {
return fmt.Errorf("failed to initialize OpenShift infrastructure: %w", err)
}
infraprovider.Set(infra)
// Set ocpInfra only for OpenShift clusters (not for kind)
ocpInfra = infra
}
deploymentconfig.Set(ocpdeploymentconfig.New())
return nil
if infraprovider.IsKind() {
infra, err := ocpinfraprovider.InitializeKindInfra()
if err != nil {
return fmt.Errorf("failed to initialize kind infrastructure: %w", err)
}
infraprovider.Set(infra)
deploymentconfig.Set(deploymentkind.New())
} else {
infra, err := ocpinfraprovider.New(cfg)
if err != nil {
return fmt.Errorf("failed to initialize OpenShift infrastructure: %w", err)
}
infraprovider.Set(infra)
// Set ocpInfra only for OpenShift clusters (not for kind)
ocpInfra = infra
deploymentconfig.Set(ocpdeploymentconfig.New())
}
return nil
🤖 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 `@openshift/cmd/ovn-kubernetes-tests-ext/main.go` around lines 83 - 99, The
deploymentconfig.Set() call using ocpdeploymentconfig.New() is currently
unconditional and applies to both kind and OpenShift infrastructure types, but
it should be provider-specific. Move the deployment config initialization inside
the conditional blocks: for the kind provider branch (within the if
infraprovider.IsKind() block), call deploymentconfig.Set() with
deploymentkind.New(), and for the OpenShift provider branch (in the else block
after ocpinfraprovider.New()), call deploymentconfig.Set() with
ocpdeploymentconfig.New(). This ensures kind clusters use kind-specific
deployment configuration while OpenShift clusters use OpenShift-specific
deployment configuration.

@openshift-ci

openshift-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

@pperiyasamy: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-metal-ipi-ovn-ipv6 d5f1796 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-aws-ovn-edge-zones d5f1796 link true /test e2e-aws-ovn-edge-zones
ci/prow/e2e-metal-ipi-ovn-dualstack-bgp-local-gw d5f1796 link true /test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
ci/prow/unit d5f1796 link true /test unit
ci/prow/5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-rt-upgrade d5f1796 link true /test 5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-rt-upgrade
ci/prow/e2e-metal-ipi-ovn-dualstack d5f1796 link true /test e2e-metal-ipi-ovn-dualstack
ci/prow/e2e-aws-ovn-upgrade d5f1796 link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn d5f1796 link true /test e2e-aws-ovn
ci/prow/e2e-aws-ovn-serial d5f1796 link true /test e2e-aws-ovn-serial
ci/prow/e2e-metal-ipi-ovn-dualstack-bgp d5f1796 link true /test e2e-metal-ipi-ovn-dualstack-bgp
ci/prow/e2e-aws-ovn-hypershift d5f1796 link true /test e2e-aws-ovn-hypershift
ci/prow/e2e-gcp-ovn-techpreview d5f1796 link true /test e2e-gcp-ovn-techpreview

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

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants