Skip to content

Commit e9b1fca

Browse files
Merge pull request #29888 from stbenjam/suites
TRT-2098, TRT-2097: Migrate origin to use OTE, and implement extension-derived suites
2 parents f380d1e + c4895d7 commit e9b1fca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+5578
-4455
lines changed

cmd/openshift-tests/openshift-tests.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,39 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
"math/rand"
76
"os"
87
"os/exec"
98
"syscall"
10-
"time"
119

10+
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd/cmdinfo"
11+
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd/cmdrun"
1212
"github.com/openshift/library-go/pkg/serviceability"
13+
"github.com/sirupsen/logrus"
14+
"github.com/spf13/cobra"
15+
"github.com/spf13/pflag"
16+
"k8s.io/cli-runtime/pkg/genericclioptions"
17+
utilflag "k8s.io/component-base/cli/flag"
18+
"k8s.io/component-base/logs"
19+
"k8s.io/kubectl/pkg/util/templates"
20+
1321
"github.com/openshift/origin/pkg/cmd"
1422
collectdiskcertificates "github.com/openshift/origin/pkg/cmd/openshift-tests/collect-disk-certificates"
1523
"github.com/openshift/origin/pkg/cmd/openshift-tests/dev"
1624
"github.com/openshift/origin/pkg/cmd/openshift-tests/disruption"
1725
"github.com/openshift/origin/pkg/cmd/openshift-tests/images"
26+
"github.com/openshift/origin/pkg/cmd/openshift-tests/list"
1827
"github.com/openshift/origin/pkg/cmd/openshift-tests/monitor"
1928
run_monitor "github.com/openshift/origin/pkg/cmd/openshift-tests/monitor/run"
2029
"github.com/openshift/origin/pkg/cmd/openshift-tests/monitor/timeline"
2130
"github.com/openshift/origin/pkg/cmd/openshift-tests/render"
2231
risk_analysis "github.com/openshift/origin/pkg/cmd/openshift-tests/risk-analysis"
2332
"github.com/openshift/origin/pkg/cmd/openshift-tests/run"
2433
run_disruption "github.com/openshift/origin/pkg/cmd/openshift-tests/run-disruption"
25-
run_test "github.com/openshift/origin/pkg/cmd/openshift-tests/run-test"
2634
run_upgrade "github.com/openshift/origin/pkg/cmd/openshift-tests/run-upgrade"
2735
"github.com/openshift/origin/pkg/cmd/openshift-tests/run_resource_watch"
2836
versioncmd "github.com/openshift/origin/pkg/cmd/openshift-tests/version"
29-
testginkgo "github.com/openshift/origin/pkg/test/ginkgo"
37+
"github.com/openshift/origin/pkg/test/extensions"
3038
exutil "github.com/openshift/origin/test/extended/util"
31-
"github.com/sirupsen/logrus"
32-
"github.com/spf13/cobra"
33-
"github.com/spf13/pflag"
34-
"k8s.io/cli-runtime/pkg/genericclioptions"
35-
utilflag "k8s.io/component-base/cli/flag"
36-
"k8s.io/component-base/logs"
37-
"k8s.io/kubectl/pkg/util/templates"
3839
)
3940

4041
func main() {
@@ -53,14 +54,23 @@ func main() {
5354

5455
logs.InitLogs()
5556
defer logs.FlushLogs()
56-
5757
logrus.SetLevel(logrus.InfoLevel)
5858

59-
rand.Seed(time.Now().UTC().UnixNano())
59+
// The GCE PD drivers were removed in kube 1.31, so we can ignore the env var that
60+
// some automation sets.
61+
if os.Getenv("ENABLE_STORAGE_GCE_PD_DRIVER") != "" {
62+
logrus.Warn("ENABLE_STORAGE_GCE_PD_DRIVER is set, but is not supported")
63+
os.Unsetenv("ENABLE_STORAGE_GCE_PD_DRIVER")
64+
}
6065

6166
pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
6267
//pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
6368

69+
extensionRegistry, originExtension, err := extensions.InitializeOpenShiftTestsExtensionFramework()
70+
if err != nil {
71+
panic(err)
72+
}
73+
6474
root := &cobra.Command{
6575
Long: templates.LongDesc(`This command verifies behavior of an OpenShift cluster by running remote tests against
6676
the cluster API that exercise functionality. In general these tests may be disruptive
@@ -79,10 +89,12 @@ func main() {
7989
}
8090

8191
root.AddCommand(
82-
run.NewRunCommand(ioStreams),
92+
run.NewRunCommand(ioStreams, originExtension),
93+
list.NewListCommand(ioStreams, extensionRegistry),
94+
cmdinfo.NewInfoCommand(extensionRegistry),
8395
run_upgrade.NewRunUpgradeCommand(ioStreams),
8496
images.NewImagesCommand(),
85-
run_test.NewRunTestCommand(ioStreams),
97+
cmdrun.NewRunTestCommand(extensionRegistry),
8698
dev.NewDevCommand(),
8799
run_monitor.NewRunMonitorCommand(ioStreams),
88100
monitor.NewMonitorCommand(ioStreams),
@@ -106,10 +118,6 @@ func main() {
106118
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()
107119
return root.Execute()
108120
}(); err != nil {
109-
if ex, ok := err.(testginkgo.ExitError); ok {
110-
fmt.Fprintf(os.Stderr, "Ginkgo exit error %d: %v\n", ex.Code, err)
111-
os.Exit(ex.Code)
112-
}
113121
fmt.Fprintf(os.Stderr, "error: %v\n", err)
114122
os.Exit(1)
115123
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ require (
3535
github.com/onsi/ginkgo/v2 v2.21.0
3636
github.com/onsi/gomega v1.35.1
3737
github.com/opencontainers/go-digest v1.0.0
38+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250522124649-4ffcd156ec7c
3839
github.com/openshift-kni/commatrix v0.0.4-0.20250604173218-064b4004e9fb
3940
github.com/openshift/api v0.0.0-20250513132935-9052dea86694
4041
github.com/openshift/apiserver-library-go v0.0.0-20250127121756-dc9a973f14ce

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
609609
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
610610
github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jDMcgULaH8=
611611
github.com/opencontainers/selinux v1.11.1/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
612-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250220212757-b9c4d98a0c45 h1:hXpbYtP3iTh8oy/RKwKkcMziwchY3fIk95ciczf7cOA=
613-
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250220212757-b9c4d98a0c45/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
612+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250522124649-4ffcd156ec7c h1:R5dI2oOF2RtS1sKtLrhW9KMg0ydzF0XM2Q//ma55nWI=
613+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250522124649-4ffcd156ec7c/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
614614
github.com/openshift-kni/commatrix v0.0.4-0.20250604173218-064b4004e9fb h1:+owPvmRBKN5dYuVQ7/CROW0h6wL6Hk8MJlf2vnZQfSM=
615615
github.com/openshift-kni/commatrix v0.0.4-0.20250604173218-064b4004e9fb/go.mod h1:R8JhlXqlLwe3N6nQheK2KpMEESIlDVCUw5TOLKiZ08s=
616616
github.com/openshift/api v0.0.0-20250513132935-9052dea86694 h1:kPnk1+m89LJHexYsTP+MVM9OgJLxcpUR3vRdMQNF66s=

pkg/clioptions/clusterdiscovery/cluster.go

Lines changed: 108 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import (
77
"io/ioutil"
88
"net/http"
99
"net/url"
10+
"slices"
1011
"strings"
1112

13+
"github.com/pkg/errors"
14+
"github.com/sirupsen/logrus"
1215
"k8s.io/apimachinery/pkg/runtime/schema"
1316

1417
corev1 "k8s.io/api/core/v1"
@@ -22,6 +25,7 @@ import (
2225
operatorv1 "github.com/openshift/api/operator/v1"
2326
configclient "github.com/openshift/client-go/config/clientset/versioned"
2427
operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
28+
2529
"github.com/openshift/origin/test/extended/util/azure"
2630
)
2731

@@ -70,6 +74,13 @@ type ClusterConfiguration struct {
7074

7175
// IsNoOptionalCapabilities indicates the cluster has no optional capabilities enabled
7276
HasNoOptionalCapabilities bool
77+
78+
// APIGroups contains the set of API groups available in the cluster
79+
APIGroups sets.Set[string] `json:"-"`
80+
// EnabledFeatureGates contains the set of enabled feature gates in the cluster
81+
EnabledFeatureGates sets.Set[string] `json:"-"`
82+
// DisabledFeatureGates contains the set of disabled feature gates in the cluster
83+
DisabledFeatureGates sets.Set[string] `json:"-"`
7384
}
7485

7586
func (c *ClusterConfiguration) ToJSONString() string {
@@ -91,6 +102,80 @@ type ClusterState struct {
91102
ControlPlaneTopology *configv1.TopologyMode
92103
OptionalCapabilities []configv1.ClusterVersionCapability
93104
Version *configv1.ClusterVersion
105+
APIGroups sets.Set[string]
106+
EnabledFeatureGates sets.Set[string]
107+
DisabledFeatureGates sets.Set[string]
108+
}
109+
110+
// discoverAPIGroups discovers available API groups in the cluster
111+
func discoverAPIGroups(coreClient clientset.Interface) (sets.Set[string], error) {
112+
logrus.Debugf("Discovering API Groups...")
113+
discoveryClient := coreClient.Discovery()
114+
groups, err := discoveryClient.ServerGroups()
115+
if err != nil {
116+
return nil, err
117+
}
118+
119+
apiGroups := sets.New[string]()
120+
for _, apiGroup := range groups.Groups {
121+
// ignore the empty group
122+
if apiGroup.Name == "" {
123+
continue
124+
}
125+
apiGroups.Insert(apiGroup.Name)
126+
}
127+
128+
sortedAPIGroups := apiGroups.UnsortedList()
129+
slices.Sort(sortedAPIGroups)
130+
131+
logrus.WithField("apiGroups", strings.Join(sortedAPIGroups, ", ")).
132+
Debugf("Discovered %d API Groups", apiGroups.Len())
133+
134+
return apiGroups, nil
135+
}
136+
137+
// discoverFeatureGates discovers feature gates in the cluster
138+
func discoverFeatureGates(configClient configclient.Interface, clusterVersion *configv1.ClusterVersion) (enabled, disabled sets.Set[string], err error) {
139+
logrus.Debugf("Discovering feature gates...")
140+
featureGate, err := configClient.ConfigV1().FeatureGates().Get(context.Background(), "cluster", metav1.GetOptions{})
141+
if err != nil {
142+
return nil, nil, errors.WithMessage(err, "encountered an error while discovering feature gates")
143+
}
144+
145+
desiredVersion := clusterVersion.Status.Desired.Version
146+
if len(desiredVersion) == 0 && len(clusterVersion.Status.History) > 0 {
147+
desiredVersion = clusterVersion.Status.History[0].Version
148+
}
149+
150+
enabled = sets.New[string]()
151+
disabled = sets.New[string]()
152+
for _, featureGateValues := range featureGate.Status.FeatureGates {
153+
if featureGateValues.Version != desiredVersion {
154+
logrus.Warningf("Feature gates for version %s not found, skipping", desiredVersion)
155+
continue
156+
}
157+
for _, enabledGate := range featureGateValues.Enabled {
158+
enabled.Insert(string(enabledGate.Name))
159+
}
160+
for _, disabledGate := range featureGateValues.Disabled {
161+
disabled.Insert(string(disabledGate.Name))
162+
}
163+
break
164+
}
165+
166+
sortedEnabledGates := enabled.UnsortedList()
167+
slices.Sort(sortedEnabledGates)
168+
169+
logrus.WithField("featureGates", strings.Join(sortedEnabledGates, ", ")).
170+
Debugf("Discovered %d enabled feature gates", len(sortedEnabledGates))
171+
172+
sortedDisabledGates := disabled.UnsortedList()
173+
slices.Sort(sortedDisabledGates)
174+
175+
logrus.WithField("featureGates", strings.Join(sortedDisabledGates, ", ")).
176+
Debugf("Discovered %d disabled feature gates", len(sortedDisabledGates))
177+
178+
return enabled, disabled, nil
94179
}
95180

96181
// DiscoverClusterState creates a ClusterState based on a live cluster
@@ -156,6 +241,24 @@ func DiscoverClusterState(clientConfig *rest.Config) (*ClusterState, error) {
156241
state.Version = clusterVersion
157242
state.OptionalCapabilities = clusterVersion.Status.Capabilities.EnabledCapabilities
158243

244+
// Discover available API groups
245+
state.APIGroups, err = discoverAPIGroups(coreClient)
246+
if err != nil {
247+
return nil, errors.WithMessage(err, "encountered an error while discovering API groups")
248+
}
249+
250+
// Discover feature gates
251+
if state.APIGroups.Has("config.openshift.io") {
252+
state.EnabledFeatureGates, state.DisabledFeatureGates, err = discoverFeatureGates(configClient, clusterVersion)
253+
if err != nil {
254+
logrus.WithError(err).Warn("ignoring error from discoverFeatureGates")
255+
}
256+
} else {
257+
state.EnabledFeatureGates = sets.New[string]()
258+
state.DisabledFeatureGates = sets.New[string]()
259+
logrus.Infof("config.openshift.io API group not found, skipping feature gate discovery")
260+
}
261+
159262
return state, nil
160263
}
161264

@@ -271,63 +374,10 @@ func LoadConfig(state *ClusterState) (*ClusterConfiguration, error) {
271374
// have to scan MachineConfig objects to figure this out? For now, callers can
272375
// can just manually override with --provider...
273376

274-
return config, nil
275-
}
276-
277-
// MatchFn returns a function that tests if a named function should be run based on
278-
// the cluster configuration
279-
func (c *ClusterConfiguration) MatchFn() func(string) bool {
280-
var skips []string
281-
skips = append(skips, fmt.Sprintf("[Skipped:%s]", c.ProviderName))
282-
283-
if c.IsIBMROKS {
284-
skips = append(skips, "[Skipped:ibmroks]")
285-
}
286-
if c.NetworkPlugin != "" {
287-
skips = append(skips, fmt.Sprintf("[Skipped:Network/%s]", c.NetworkPlugin))
288-
if c.NetworkPluginMode != "" {
289-
skips = append(skips, fmt.Sprintf("[Skipped:Network/%s/%s]", c.NetworkPlugin, c.NetworkPluginMode))
290-
}
291-
}
292-
293-
if c.Disconnected {
294-
skips = append(skips, "[Skipped:Disconnected]")
295-
}
377+
// Copy API groups and feature gates from cluster state
378+
config.APIGroups = state.APIGroups
379+
config.EnabledFeatureGates = state.EnabledFeatureGates
380+
config.DisabledFeatureGates = state.DisabledFeatureGates
296381

297-
if c.IsProxied {
298-
skips = append(skips, "[Skipped:Proxy]")
299-
}
300-
301-
if c.SingleReplicaTopology {
302-
skips = append(skips, "[Skipped:SingleReplicaTopology]")
303-
}
304-
305-
if !c.HasIPv4 {
306-
skips = append(skips, "[Feature:Networking-IPv4]")
307-
}
308-
if !c.HasIPv6 {
309-
skips = append(skips, "[Feature:Networking-IPv6]")
310-
}
311-
if !c.HasIPv4 || !c.HasIPv6 {
312-
// lack of "]" is intentional; this matches multiple tags
313-
skips = append(skips, "[Feature:IPv6DualStack")
314-
}
315-
316-
if !c.HasSCTP {
317-
skips = append(skips, "[Feature:SCTPConnectivity]")
318-
}
319-
320-
if c.HasNoOptionalCapabilities {
321-
skips = append(skips, "[Skipped:NoOptionalCapabilities]")
322-
}
323-
324-
matchFn := func(name string) bool {
325-
for _, skip := range skips {
326-
if strings.Contains(name, skip) {
327-
return false
328-
}
329-
}
330-
return true
331-
}
332-
return matchFn
382+
return config, nil
333383
}

pkg/clioptions/clusterdiscovery/provider.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"github.com/onsi/gomega"
1010
"github.com/sirupsen/logrus"
1111

12-
"github.com/openshift/origin/test/extended/util/image"
1312
e2e "k8s.io/kubernetes/test/e2e/framework"
1413

14+
"github.com/openshift/origin/test/extended/util/image"
15+
1516
exutil "github.com/openshift/origin/test/extended/util"
1617
// Initialize baremetal as a provider
1718
_ "github.com/openshift/origin/test/extended/util/baremetal"
@@ -104,7 +105,7 @@ func DecodeProvider(providerTypeOrJSON string, dryRun, discover bool, clusterSta
104105
"dryRun": dryRun,
105106
"discover": discover,
106107
"clusterState": clusterState,
107-
}).Info("Decoding provider")
108+
}).Debug("Decoding provider")
108109
switch providerTypeOrJSON {
109110
case "none":
110111
config := &ClusterConfiguration{
@@ -193,7 +194,9 @@ func DecodeProvider(providerTypeOrJSON string, dryRun, discover bool, clusterSta
193194
if clusterState != nil {
194195
var err error
195196
config, err = LoadConfig(clusterState)
196-
log.WithError(err).Warn("ignoring error from LoadConfig for discovery")
197+
if err != nil {
198+
log.WithError(err).Warn("ignoring error from LoadConfig for discovery")
199+
}
197200
}
198201
}
199202
if config == nil {

0 commit comments

Comments
 (0)