-
Notifications
You must be signed in to change notification settings - Fork 66
OCPCLOUD-3009: Bootstrap OTE framework #597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ use ( | |
| ./e2e | ||
| ./hack/tools | ||
| ./manifests-gen | ||
| ./openshift-tests-extension | ||
| ) | ||
|
|
||
| replace ( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # OpenShift Tests Extension (OTE) | ||
|
|
||
| This directory contains a separate Go module that builds the OTE binary | ||
| (`cluster-capi-operator-tests-ext`). The binary is embedded gzipped in the | ||
| operator image at `/usr/bin/cluster-capi-operator-tests-ext.gz` and used by | ||
| `openshift-tests` to discover and run e2e tests as part of the OpenShift test | ||
| infrastructure. | ||
|
|
||
| ## Adding a test to OTE | ||
|
|
||
| Whether a test file is visible to OTE depends entirely on its file suffix: | ||
|
|
||
| | File | `make e2e` | OTE (`list tests`) | | ||
| |---|---|---| | ||
| | `e2e/my_test.go` | ✅ | ❌ | | ||
| | `e2e/my.go` | ✅ | ✅ | | ||
| | `e2e/my.go` + `//go:build !e2e` | ❌ | ✅ | | ||
|
|
||
| **To make a test discoverable by OTE:** write it in a regular `.go` file (not | ||
| `_test.go`). No changes to the extension binary are needed — ginkgo | ||
| auto-discovery picks it up on the next build. | ||
|
|
||
| **To keep a test out of OTE:** use the standard `_test.go` suffix. It still | ||
| runs via `make e2e`. | ||
|
|
||
| **To make a test run via OTE only (not `make e2e`):** use a regular `.go` file | ||
| with `//go:build !e2e`. `make e2e` passes `--tags=e2e` internally which causes | ||
| `!e2e` files to be excluded from compilation. The OTE binary is built without | ||
| that tag, so the file is included. | ||
|
|
||
| ## Test labels and suite routing | ||
|
|
||
| Labels on a test control which OTE suite it lands in, and therefore which | ||
| nightly conformance job picks it up via the `Parents` field: | ||
|
|
||
| | Label on test | OTE suite | Parent suite | | ||
| |---|---|---| | ||
| | none (default) | `capio/parallel` | `openshift/conformance/parallel` | | ||
| | `Label("Serial")` | `capio/serial` | `openshift/conformance/serial` | | ||
| | `Label("Disruptive")` | `capio/disruptive` | `openshift/disruptive-longrunning` | | ||
|
|
||
| A test is included in a periodic run when **both** of these are true: | ||
| 1. The cluster has the feature set that enables the test's feature gate (e.g. `TechPreviewNoUpgrade`) | ||
| 2. The job runs the matching parent suite (e.g. `openshift/conformance/serial`) | ||
|
|
||
| Example — a serial test that lands in `capio/serial → openshift/conformance/serial`: | ||
|
|
||
| ```go | ||
| // e2e/aws_machineset.go (regular .go, not _test.go — visible to OTE) | ||
| var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:ClusterAPIMachineManagementAWS] Cluster API AWS", func() { | ||
| It("should scale a MachineSet", Label("Serial"), func() { | ||
| // test body | ||
| }) | ||
| }) | ||
| ``` | ||
|
|
||
| Example — a parallel test (no label) that lands in `capio/parallel → openshift/conformance/parallel`: | ||
|
|
||
| ```go | ||
| var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:ClusterAPIMachineManagementAWS] Cluster API AWS", func() { | ||
| It("should have a running cluster", func() { | ||
| // test body | ||
| }) | ||
| }) | ||
| ``` | ||
|
|
||
| ## Feature gate labeling | ||
|
|
||
| Every e2e test must carry the appropriate `[OCPFeatureGate:FeatureName]` tag in | ||
| its `Describe` block name. This tells `openshift-tests` to skip the test | ||
| automatically on clusters where the feature gate is not enabled: | ||
|
|
||
| ```go | ||
| var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:ClusterAPIMachineManagementAWS] Cluster API AWS", func() { | ||
| It("should run a machine", func() { ... }) | ||
| }) | ||
| ``` | ||
|
|
||
| Without this tag, a test runs on every cluster regardless of feature gate | ||
| status, which will cause failures on clusters where the feature is not active. | ||
|
|
||
| ## Blocking vs informing lifecycle | ||
|
|
||
| By default every test is `blocking` — a failure causes the suite exit code to | ||
| be non-zero. To mark a test as `informing` (failure recorded but non-blocking): | ||
|
|
||
| ```go | ||
| import g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo" | ||
|
|
||
| It("should be stable but not yet required", g.Informing(), func() { ... }) | ||
| ``` | ||
|
|
||
| Informing failures appear in the JSON output and Sippy dashboards but do not | ||
| gate merges or promotions. Use this temporarily to gather stability data before | ||
| promoting a test to blocking. Tests must not remain informing indefinitely. | ||
|
|
||
| **Important:** `g.Informing()` is only honored when the test runs through the | ||
| OTE binary (`run-suite`, `run-test`). When running via `make e2e`, ginkgo has | ||
| no concept of informing lifecycle — a failing informing test will still cause | ||
| the `make e2e` run to exit with a non-zero code. | ||
|
|
||
|
|
||
| ## Running locally | ||
|
|
||
| `list tests` and `list suites` work without a cluster. `run-suite` and | ||
| `run-test` require a reachable OCP cluster because `InitCommonVariables()` | ||
| fetches the `cluster` Infrastructure object. | ||
|
|
||
| ```bash | ||
| # Build the binary | ||
| make bin/cluster-capi-operator-tests-ext | ||
|
|
||
| # List all discovered tests (no cluster needed) | ||
| ./bin/cluster-capi-operator-tests-ext list tests | ||
|
|
||
| # Run a specific suite against a cluster | ||
| ./bin/cluster-capi-operator-tests-ext run-suite capio/serial | ||
|
|
||
| # Run a single test by exact name | ||
| ./bin/cluster-capi-operator-tests-ext run-test "[sig-cluster-lifecycle]... test name" | ||
| ``` | ||
|
|
||
| The `KUBECONFIG` env var is read directly by `config.GetConfig()` — it must | ||
| point to a reachable OCP cluster, not just whatever `kubectl` has as | ||
| current-context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| Copyright 2025 Red Hat, Inc. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "time" | ||
|
|
||
| "github.com/openshift-eng/openshift-tests-extension/pkg/cmd" | ||
| e "github.com/openshift-eng/openshift-tests-extension/pkg/extension" | ||
| g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| e2e "github.com/openshift/cluster-capi-operator/e2e" | ||
| ) | ||
|
|
||
| func main() { | ||
| extensionRegistry := e.NewRegistry() | ||
|
|
||
| ext := e.NewExtension("openshift", "payload", "cluster-capi-operator") | ||
|
|
||
| defaultTimeout := 30 * time.Minute | ||
| disruptiveTimeout := 90 * time.Minute | ||
|
|
||
| ext.AddSuite(e.Suite{ | ||
| Name: "capio/parallel", | ||
| Qualifiers: []string{`!labels.exists(l, l == "Serial") && !labels.exists(l, l == "Disruptive")`}, | ||
| Parents: []string{"openshift/conformance/parallel"}, | ||
| TestTimeout: &defaultTimeout, | ||
| }) | ||
|
|
||
| ext.AddSuite(e.Suite{ | ||
| Name: "capio/serial", | ||
| Qualifiers: []string{`labels.exists(l, l == "Serial") && !labels.exists(l, l == "Disruptive")`}, | ||
| Parents: []string{"openshift/conformance/serial"}, | ||
| Parallelism: 1, | ||
| TestTimeout: &defaultTimeout, | ||
| }) | ||
|
|
||
| ext.AddSuite(e.Suite{ | ||
| Name: "capio/disruptive", | ||
| Qualifiers: []string{`labels.exists(l, l == "Disruptive")`}, | ||
| Parents: []string{"openshift/disruptive-longrunning"}, | ||
| Parallelism: 1, | ||
| ClusterStability: e.ClusterStabilityDisruptive, | ||
| TestTimeout: &disruptiveTimeout, | ||
| }) | ||
|
|
||
| specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite() | ||
| if err != nil { | ||
| panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %v", err)) | ||
| } | ||
|
|
||
| specs.AddBeforeAll(func() { | ||
| e2e.InitCommonVariables() | ||
| }) | ||
|
|
||
| ext.AddSpecs(specs) | ||
|
|
||
| extensionRegistry.Register(ext) | ||
|
|
||
| root := &cobra.Command{ | ||
| Long: "Cluster CAPI Operator tests extension for OpenShift", | ||
| } | ||
| root.AddCommand(cmd.DefaultExtensionCommands(extensionRegistry)...) | ||
|
|
||
| if err := root.Execute(); err != nil { | ||
| os.Exit(1) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.