Skip to content

Commit a636219

Browse files
committed
Updated feedback
1 parent 974d5a2 commit a636219

File tree

2 files changed

+22
-37
lines changed

2 files changed

+22
-37
lines changed

cmd/cluster-kube-apiserver-operator-tests-ext/main.go

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
1919
"github.com/spf13/cobra"
2020
"k8s.io/component-base/cli"
21+
"k8s.io/klog/v2"
2122

2223
"github.com/openshift/cluster-kube-apiserver-operator/pkg/version"
2324

@@ -26,15 +27,28 @@ import (
2627
)
2728

2829
func main() {
29-
registry := prepareOperatorTestsRegistry()
30+
cmd, err := newOperatorTestCommand()
31+
if err != nil {
32+
klog.Fatal(err)
33+
}
34+
35+
code := cli.Run(cmd)
36+
os.Exit(code)
37+
}
38+
39+
func newOperatorTestCommand() (*cobra.Command, error) {
40+
registry, err := prepareOperatorTestsRegistry()
41+
if err != nil {
42+
return nil, fmt.Errorf("failed to prepare test registry: %w", err)
43+
}
44+
3045
cmd := &cobra.Command{
3146
Use: "cluster-kube-apiserver-operator-tests",
3247
Short: "A binary used to run cluster-kube-apiserver-operator tests as part of OTE.",
3348
Run: func(cmd *cobra.Command, args []string) {
3449
// no-op, logic is provided by the OTE framework
3550
if err := cmd.Help(); err != nil {
36-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
37-
os.Exit(1)
51+
klog.Fatal(err)
3852
}
3953
},
4054
}
@@ -47,16 +61,15 @@ func main() {
4761

4862
cmd.AddCommand(otecmd.DefaultExtensionCommands(registry)...)
4963

50-
code := cli.Run(cmd)
51-
os.Exit(code)
64+
return cmd, nil
5265
}
5366

5467
// prepareOperatorTestsRegistry creates the OTE registry for this operator.
5568
//
5669
// Note:
5770
//
5871
// This method must be called before adding the registry to the OTE framework.
59-
func prepareOperatorTestsRegistry() *oteextension.Registry {
72+
func prepareOperatorTestsRegistry() (*oteextension.Registry, error) {
6073
registry := oteextension.NewRegistry()
6174
extension := oteextension.NewExtension("openshift", "payload", "cluster-kube-apiserver-operator")
6275

@@ -105,32 +118,9 @@ func prepareOperatorTestsRegistry() *oteextension.Registry {
105118
// Build ginkgo test specs from the test/e2e package
106119
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
107120
if err != nil {
108-
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
121+
return nil, fmt.Errorf("couldn't build extension test specs from ginkgo: %w", err)
109122
}
110123

111-
// Ensure [Disruptive] tests are also [Serial]
112-
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
113-
if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") {
114-
spec.Name = strings.ReplaceAll(
115-
spec.Name,
116-
"[Disruptive]",
117-
"[Serial][Disruptive]",
118-
)
119-
}
120-
})
121-
122-
// Preserve original-name labels for renamed tests
123-
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
124-
for label := range spec.Labels {
125-
if strings.HasPrefix(label, "original-name:") {
126-
parts := strings.SplitN(label, "original-name:", 2)
127-
if len(parts) > 1 {
128-
spec.OriginalName = parts[1]
129-
}
130-
}
131-
}
132-
})
133-
134124
// Extract timeout from test name if present (e.g., [Timeout:50m])
135125
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
136126
// Look for [Timeout:XXm] or [Timeout:XXh] pattern in test name
@@ -155,14 +145,9 @@ func prepareOperatorTestsRegistry() *oteextension.Registry {
155145
// "[sig-api-machinery] <test name here>",
156146
)
157147

158-
// Initialize environment before running any tests
159-
specs.AddBeforeAll(func() {
160-
// do stuff
161-
})
162-
163148
// Add the discovered test specs to the extension
164149
extension.AddSpecs(specs)
165150

166151
registry.Register(extension)
167-
return registry
152+
return registry, nil
168153
}

test/e2e/event-ttl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ var _ = g.Describe("[Jira:kube-apiserver][sig-api-machinery][FeatureGate:EventTT
215215
for _, ttlMinutes := range testValues {
216216
ttl := ttlMinutes
217217

218-
g.It(fmt.Sprintf("should configure and validate eventTTLMinutes=%dm [Timeout:60m][Disruptive][Slow][Serial][OTP]", ttl), ote.Informing(), func() {
218+
g.It(fmt.Sprintf("should configure and validate eventTTLMinutes=%dm [Timeout:60m][Slow][Serial][OTP]", ttl), ote.Informing(), func() {
219219
startTime := time.Now()
220220
g.By(fmt.Sprintf("=== Starting test for eventTTLMinutes=%d at %s ===", ttl, startTime.Format(time.RFC3339)))
221221

0 commit comments

Comments
 (0)