-
Notifications
You must be signed in to change notification settings - Fork 40
CNTRLPLANE-1259: Simplified test infrastructure to single-module architecture #154
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
Open
wangke19
wants to merge
2
commits into
openshift:master
Choose a base branch
from
wangke19:ote-single-module-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,4 +12,5 @@ | |
| *.out | ||
|
|
||
| /oauth-apiserver | ||
| /oauth-apiserver-tests-ext | ||
| /oauth-apiserver-tests-ext | ||
| /oauth-apiserver-tests-ext.gz | ||
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 |
|---|---|---|
| @@ -1,15 +1,9 @@ | ||
| reviewers: | ||
| - deads2k | ||
| - tkashem | ||
| - p0lyn0mial | ||
| - benluddy | ||
| - sanchezl | ||
| - dgrisonnet | ||
| approvers: | ||
| - deads2k | ||
| - tkashem | ||
| - p0lyn0mial | ||
| - benluddy | ||
| - sanchezl | ||
| - dgrisonnet | ||
| component: oauth-apiserver |
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,32 @@ | ||
| ## Tests | ||
|
|
||
| This repository is compatible with the [OpenShift Tests Extension (OTE)](https://github.com/openshift-eng/openshift-tests-extension) framework. | ||
|
|
||
| ### Building the test binary | ||
|
|
||
| ```bash | ||
| make build | ||
| ``` | ||
|
|
||
| ### Running test suites and tests | ||
|
|
||
| ```bash | ||
| # Run a specific test suite or test | ||
| ./oauth-apiserver-tests-ext run-suite "openshift/oauth-apiserver/all" | ||
| ./oauth-apiserver-tests-ext run-test "test-name" | ||
|
|
||
| # Run with JUnit output | ||
| ./oauth-apiserver-tests-ext run-suite openshift/oauth-apiserver/all --junit-path /tmp/junit.xml | ||
| ``` | ||
|
|
||
| ### Listing available tests and suites | ||
|
|
||
| ```bash | ||
| # List all test suites | ||
| ./oauth-apiserver-tests-ext list suites | ||
|
|
||
| # List tests in a suite | ||
| ./oauth-apiserver-tests-ext list tests --suite=openshift/oauth-apiserver/all | ||
| ``` | ||
|
|
||
| For more information about the OTE framework, see the [openshift-tests-extension documentation](https://github.com/openshift-eng/openshift-tests-extension). | ||
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 |
|---|---|---|
| @@ -1,112 +1,54 @@ | ||
| /* | ||
| This command is used to run the OpenShift OAuth API Server tests extension for OpenShift. | ||
| It registers the OpenShift OAuth API Server tests with the OpenShift Tests Extension framework | ||
| and provides a command-line interface to execute them. | ||
| For further information, please refer to the documentation at: | ||
| https://github.com/openshift-eng/openshift-tests-extension/blob/main/cmd/example-tests/main.go | ||
| */ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "context" | ||
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/openshift-eng/openshift-tests-extension/pkg/cmd" | ||
| e "github.com/openshift-eng/openshift-tests-extension/pkg/extension" | ||
| et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests" | ||
| g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| "k8s.io/component-base/cli" | ||
|
|
||
| otecmd "github.com/openshift-eng/openshift-tests-extension/pkg/cmd" | ||
| oteextension "github.com/openshift-eng/openshift-tests-extension/pkg/extension" | ||
| "github.com/openshift/oauth-apiserver/pkg/version" | ||
|
|
||
| // The import below is necessary to ensure that the Oauth APIServer tests are registered with the extension. | ||
| _ "github.com/openshift/oauth-apiserver/test/extended" | ||
| "k8s.io/klog/v2" | ||
| ) | ||
|
|
||
| func main() { | ||
| registry := e.NewRegistry() | ||
| ext := e.NewExtension("openshift", "payload", "oauth-apiserver") | ||
| command := newOperatorTestCommand(context.Background()) | ||
| code := cli.Run(command) | ||
| os.Exit(code) | ||
| } | ||
|
|
||
| // Suite: conformance/parallel (fast, parallel-safe) | ||
| ext.AddSuite(e.Suite{ | ||
| Name: "openshift/oauth-apiserver/conformance/parallel", | ||
| Parents: []string{"openshift/conformance/parallel"}, | ||
| Qualifiers: []string{ | ||
| `!(name.contains("[Serial]") || name.contains("[Slow]"))`, | ||
| }, | ||
| }) | ||
| func newOperatorTestCommand(ctx context.Context) *cobra.Command { | ||
| registry := prepareOperatorTestsRegistry() | ||
|
|
||
| // Suite: conformance/serial (explicitly serial tests) | ||
| ext.AddSuite(e.Suite{ | ||
| Name: "openshift/oauth-apiserver/conformance/serial", | ||
| Parents: []string{"openshift/conformance/serial"}, | ||
| Qualifiers: []string{ | ||
| `name.contains("[Serial]")`, | ||
| }, | ||
| }) | ||
|
|
||
| // Suite: optional/slow (long-running tests) | ||
| ext.AddSuite(e.Suite{ | ||
| Name: "openshift/oauth-apiserver/optional/slow", | ||
| Parents: []string{"openshift/optional/slow"}, | ||
| Qualifiers: []string{ | ||
| `name.contains("[Slow]")`, | ||
| cmd := &cobra.Command{ | ||
| Use: "oauth-apiserver-tests-ext", | ||
| Short: "A binary used to run oauth-apiserver tests as part of OTE.", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| // no-op, logic is provided by the OTE framework | ||
| if err := cmd.Help(); err != nil { | ||
| klog.Fatal(err) | ||
| } | ||
| }, | ||
| }) | ||
|
|
||
| // Suite: all (includes everything) | ||
| ext.AddSuite(e.Suite{ | ||
| Name: "openshift/oauth-apiserver/all", | ||
| }) | ||
|
|
||
| specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite() | ||
| if err != nil { | ||
| panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error())) | ||
| } | ||
|
|
||
| // Ensure [Disruptive] tests are also [Serial] | ||
| specs = specs.Walk(func(spec *et.ExtensionTestSpec) { | ||
| if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") { | ||
| spec.Name = strings.ReplaceAll( | ||
| spec.Name, | ||
| "[Disruptive]", | ||
| "[Serial][Disruptive]", | ||
| ) | ||
| } | ||
| }) | ||
|
|
||
| // Preserve original-name labels for renamed tests | ||
| specs = specs.Walk(func(spec *et.ExtensionTestSpec) { | ||
| for label := range spec.Labels { | ||
| if strings.HasPrefix(label, "original-name:") { | ||
| parts := strings.SplitN(label, "original-name:", 2) | ||
| if len(parts) > 1 { | ||
| spec.OriginalName = parts[1] | ||
| } | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| // Ignore obsolete tests | ||
| ext.IgnoreObsoleteTests( | ||
| // "[sig-openshift-apiserver] <test name here>", | ||
| ) | ||
|
|
||
| // Initialize environment before running any tests | ||
| specs.AddBeforeAll(func() { | ||
| // do stuff | ||
| }) | ||
| if v := version.Get().String(); len(v) == 0 { | ||
| cmd.Version = "<unknown>" | ||
| } else { | ||
| cmd.Version = v | ||
| } | ||
|
|
||
| ext.AddSpecs(specs) | ||
| registry.Register(ext) | ||
| cmd.AddCommand(otecmd.DefaultExtensionCommands(registry)...) | ||
|
|
||
| root := &cobra.Command{ | ||
| Long: "OpenShift OAuth API Server Tests Extension", | ||
| } | ||
| return cmd | ||
| } | ||
|
|
||
| root.AddCommand(cmd.DefaultExtensionCommands(registry)...) | ||
| func prepareOperatorTestsRegistry() *oteextension.Registry { | ||
| registry := oteextension.NewRegistry() | ||
| extension := oteextension.NewExtension("openshift", "payload", "oauth-apiserver") | ||
|
|
||
| if err := root.Execute(); err != nil { | ||
| os.Exit(1) | ||
| } | ||
| registry.Register(extension) | ||
| return registry | ||
| } |
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
12 changes: 0 additions & 12 deletions
12
test/.openshift-tests-extension/openshift_payload_oauth-apiserver.json
This file was deleted.
Oops, something went wrong.
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.