-
Notifications
You must be signed in to change notification settings - Fork 182
CNTRLPLANE-1579: E2E test: Add support for event-ttl in Kube API Server Operator #1967
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
gangwgr
wants to merge
12
commits into
openshift:main
Choose a base branch
from
gangwgr:test-infrastructure-setup-v2
base: main
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.
+199,784
−1,487
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
13f23bc
Adding test cases for "Add support for event-ttl in Kube API Server O…
gangwgr 7692fe6
Vendor update
gangwgr 974d5a2
fixing coderabbit feedback
gangwgr d5d7299
Updated feedback
gangwgr ec9b1bc
making old go standard cases compatible with ote binary
gangwgr d78185e
to run go standard cases in ci
gangwgr efc1891
auto generate metadata
gangwgr 238dd21
convert standard go test to ExtensionTestSpec
gangwgr dfa6378
Improve logging
gangwgr 0e1d7b3
Improve tags
gangwgr 84996b7
updating go test adapter
gangwgr afd88ee
fixing compilation
gangwgr 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
136 changes: 136 additions & 0 deletions
136
cmd/cluster-kube-apiserver-operator-tests-ext/adapter/generate_metadata.go
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,136 @@ | ||
| //go:build ignore | ||
| // +build ignore | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| "github.com/openshift/cluster-kube-apiserver-operator/cmd/cluster-kube-apiserver-operator-tests-ext/adapter" | ||
| ) | ||
|
|
||
| // findRepoRoot walks up directories to find go.mod | ||
| func findRepoRoot() (string, error) { | ||
| dir, err := os.Getwd() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| for { | ||
| if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil { | ||
| return dir, nil | ||
| } | ||
|
|
||
| parent := filepath.Dir(dir) | ||
| if parent == dir { | ||
| return "", fmt.Errorf("could not find go.mod in any parent directory") | ||
| } | ||
| dir = parent | ||
| } | ||
| } | ||
|
|
||
| func main() { | ||
| // Find repository root by looking for go.mod | ||
| repoRoot, err := findRepoRoot() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "Failed to find repository root: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Set TEST_ROOT_DIR to repository root for discovery | ||
| os.Setenv("TEST_ROOT_DIR", repoRoot) | ||
|
|
||
| // Auto-discover all tests from test/e2e* directories | ||
| // Default: Serial tag, Informing lifecycle (can be overridden per-test via comments) | ||
| configs, err := adapter.AutoDiscoverAllGoTests([]string{"Serial"}, "Informing") | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "Failed to discover tests: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| if len(configs) == 0 { | ||
| fmt.Fprintf(os.Stderr, "Warning: No tests discovered\n") | ||
| } | ||
|
|
||
| // Generate standard_go_tests.go file in the same directory as this script | ||
| // This script is always in the adapter package directory | ||
| scriptDir, err := filepath.Abs(filepath.Dir(os.Args[0])) | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "Failed to get script directory: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // If running with "go run", find the actual source directory | ||
| cwd, _ := os.Getwd() | ||
| if filepath.Base(scriptDir) != "adapter" { | ||
| scriptDir = cwd | ||
| } | ||
|
|
||
| outputPath := filepath.Join(scriptDir, "standard_go_tests.go") | ||
|
|
||
| var sb strings.Builder | ||
| sb.WriteString(`// Code generated by generate-test-metadata. DO NOT EDIT. | ||
| // To regenerate: make update | ||
|
|
||
| package adapter | ||
|
|
||
| import ( | ||
| extensiontests "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests" | ||
| ) | ||
|
|
||
| // Pre-discovered test metadata - embedded in binary at build time. | ||
| // To regenerate: developers run discovery locally and update this list. | ||
| var standardGoTestMetadata = []GoTestConfig{ | ||
| `) | ||
|
|
||
| for _, config := range configs { | ||
| sb.WriteString(fmt.Sprintf("\t// %s\n", config.TestFile)) | ||
|
|
||
| // Format tags array | ||
| var tagsStr string | ||
| if len(config.Tags) == 0 { | ||
| tagsStr = "[]string{}" | ||
| } else { | ||
| tagList := make([]string, len(config.Tags)) | ||
| for i, tag := range config.Tags { | ||
| tagList[i] = fmt.Sprintf("%q", tag) | ||
| } | ||
| tagsStr = fmt.Sprintf("[]string{%s}", strings.Join(tagList, ", ")) | ||
| } | ||
|
|
||
| // Build config line with all fields | ||
| sb.WriteString(fmt.Sprintf("\t{TestFile: %q, TestPattern: %q, Tags: %s", | ||
| config.TestFile, config.TestPattern, tagsStr)) | ||
|
|
||
| if config.Timeout != "" { | ||
| sb.WriteString(fmt.Sprintf(", Timeout: %q", config.Timeout)) | ||
| } | ||
|
|
||
| if config.Lifecycle != "" { | ||
| sb.WriteString(fmt.Sprintf(", Lifecycle: %q", config.Lifecycle)) | ||
| } | ||
|
|
||
| sb.WriteString("},\n") | ||
| } | ||
|
|
||
| sb.WriteString(`} | ||
|
|
||
| // BuildExtensionTestSpecsFromGoTestMetadata returns ExtensionTestSpecs for standard Go tests | ||
| // This function is called by main.go to register the tests with OTE | ||
| // It uses the embedded standardGoTestMetadata and returns specs that can be filtered and executed | ||
| // Following the Cypress pattern: tests are registered as ExtensionTestSpec for OTE filtering and execution | ||
| func BuildExtensionTestSpecsFromGoTestMetadata() (extensiontests.ExtensionTestSpecs, error) { | ||
| return buildExtensionTestSpecsFromMetadata(standardGoTestMetadata), nil | ||
| } | ||
| `) | ||
|
|
||
| if err := os.WriteFile(outputPath, []byte(sb.String()), 0644); err != nil { | ||
| fmt.Fprintf(os.Stderr, "Failed to write file: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| fmt.Printf("Generated %s with %d tests\n", outputPath, len(configs)) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach won't work; we don't ship source code in the images in the payload, and origin only extracts the test binary anyway.
Go supports compiled tests, and I would suggest seeing if you can write an OTE adapter like we have for Ginkgo and Cypress: https://github.com/openshift-eng/openshift-tests-extension/tree/main/pkg/cypress
Or just convert the go tests to ginkgo, not wrapped
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this for test case name generation generate_metadata.go and gotest_wrapper.go is similar to cypress