-
Notifications
You must be signed in to change notification settings - Fork 185
CORENET-6170: Add OCP tests extension #2461
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
Changes from all commits
40cf2ff
9770e11
d196391
cb301f7
118948b
80db3f2
622a3f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/ovn-org/ovn-kubernetes/openshift/test/annotate" | ||
| ) | ||
|
|
||
| func main() { | ||
| annotate.Run(annotate.LabelToTestNameMatchMaps, annotate.LabelToLabelMaps, func(name string) bool { return false }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "sort" | ||
|
|
||
| "github.com/openshift-eng/openshift-tests-extension/pkg/util/sets" | ||
| ) | ||
|
|
||
| // getTestExtensionLabels returns labels that should be applied to all tests in this extension | ||
| func getTestExtensionLabels() []string { | ||
| return []string{"sig-network", "ovn-kubernetes-ote"} | ||
| } | ||
|
|
||
| // generatePrependedLabelsStr generates labels that are prepended to a test name | ||
| func generatePrependedLabelsStr(labels sets.Set[string]) string { | ||
| labelList := labels.UnsortedList() | ||
| sort.Strings(labelList) | ||
|
|
||
| var labelsStr = "" | ||
| for _, label := range labelList { | ||
| labelsStr += "[" + label + "]" | ||
| } | ||
| return labelsStr | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test names don't match up which cause some problems -- we won't be able to compare across releases for regressions. Because these tests also exist in origin, origin won't know to override the internal test with the external one. I see it two options:
origin: ovnk-tests-ext:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yea, I went with renaming in-order to be consistent. Thats still WIP upstream but i cherry-picked it here for test.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Working on renaming PR tomorrow.
martinkennelly marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
|
|
||
| "github.com/ovn-org/ovn-kubernetes/openshift/test/generated" | ||
| // import ovn-kubernetes tests | ||
| _ "github.com/ovn-org/ovn-kubernetes/test/e2e" | ||
|
|
||
| "github.com/openshift-eng/openshift-tests-extension/pkg/cmd" | ||
| "github.com/openshift-eng/openshift-tests-extension/pkg/extension" | ||
| "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests" | ||
| "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo" | ||
| "github.com/spf13/cobra" | ||
|
|
||
| // ensure providers are initialised for configuring infra | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/aws" | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/azure" | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/gce" | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/kubemark" | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/openstack" | ||
| _ "k8s.io/kubernetes/test/e2e/framework/providers/vsphere" | ||
|
|
||
| // ensure that logging flags are part of the command line. | ||
| _ "k8s.io/component-base/logs/testinit" | ||
| ) | ||
|
|
||
| func main() { | ||
| // Create our registry of openshift-tests extensions | ||
| extensionRegistry := extension.NewRegistry() | ||
| ovnTestsExtension := extension.NewExtension("openshift", "payload", "ovn-kubernetes") | ||
| // TODO: register test images using tests extension | ||
| // add ovn-kubernetes test suites into openshift suites | ||
| // by default, we treat all tests as parallel and only expose tests as Serial if the appropriate label is added - "Serial" | ||
| ovnTestsExtension.AddSuite(extension.Suite{ | ||
| Name: "ovn-kubernetes/conformance/serial", | ||
| Parents: []string{ | ||
| "openshift/conformance/serial", | ||
| }, | ||
| Qualifiers: []string{`labels.exists(l, l == "Serial")`}, | ||
| }) | ||
|
|
||
| ovnTestsExtension.AddSuite(extension.Suite{ | ||
| Name: "ovn-kubernetes/conformance/parallel", | ||
| Parents: []string{ | ||
| "openshift/conformance/parallel", | ||
| }, | ||
| Qualifiers: []string{`!labels.exists(l, l == "Serial")`}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this one right ? while I don't know its purpose, I see that it has the same value as the serial lane qualifier.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically, i want to treat all tests as not serial by default to reduce the test cycle and increase test cluster utilisation. If folks find theres a problem, they can add the Serial label. |
||
| }) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it's ok to use default values now.
Comment on lines
+36
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this suite configuration relate to the suite labes we are adding in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the test labels from |
||
|
|
||
| specs, err := ginkgo.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite(extensiontests.AllTestsIncludingVendored()) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| // Initialization for kube ginkgo test framework needs to run before all tests execute | ||
| specs.AddBeforeAll(func() { | ||
| if err := initializeTestFramework(os.Getenv("TEST_PROVIDER")); err != nil { | ||
| panic(err) | ||
| } | ||
| }) | ||
|
|
||
| specs.Walk(func(spec *extensiontests.ExtensionTestSpec) { | ||
| for _, label := range getTestExtensionLabels() { | ||
| spec.Labels.Insert(label) | ||
| } | ||
|
|
||
| if annotations, ok := generated.AppendedAnnotations[spec.Name]; ok { | ||
| spec.Name += " " + annotations | ||
| } | ||
| spec.Name = generatePrependedLabelsStr(spec.Labels) + " " + spec.Name // prepend ginkgo labels to test name | ||
| }) | ||
|
|
||
| specs = specs.Select(func(spec *extensiontests.ExtensionTestSpec) bool { | ||
| return !strings.Contains(spec.Name, "[Disabled:") | ||
| }) | ||
|
|
||
| ovnTestsExtension.AddSpecs(specs) | ||
| extensionRegistry.Register(ovnTestsExtension) | ||
| root := &cobra.Command{ | ||
| Long: "OVN-Kubernetes tests extension for OpenShift", | ||
| } | ||
| root.AddCommand( | ||
| cmd.DefaultExtensionCommands(extensionRegistry)..., | ||
| ) | ||
| if err := func() error { | ||
| return root.Execute() | ||
| }(); err != nil { | ||
| os.Exit(1) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
||
| ocphacke2e "github.com/ovn-org/ovn-kubernetes/openshift/test" | ||
| ocpdeploymentconfig "github.com/ovn-org/ovn-kubernetes/openshift/test/deploymentconfig" | ||
| ocpinfraprovider "github.com/ovn-org/ovn-kubernetes/openshift/test/infraprovider" | ||
| "github.com/ovn-org/ovn-kubernetes/test/e2e/deploymentconfig" | ||
| "github.com/ovn-org/ovn-kubernetes/test/e2e/infraprovider" | ||
|
|
||
| "github.com/onsi/ginkgo/v2" | ||
| "github.com/onsi/ginkgo/v2/reporters" | ||
| "github.com/onsi/ginkgo/v2/types" | ||
| "github.com/onsi/gomega" | ||
| corev1 "k8s.io/api/core/v1" | ||
| kclientset "k8s.io/client-go/kubernetes" | ||
| "k8s.io/client-go/tools/clientcmd" | ||
| "k8s.io/kubernetes/test/e2e/framework" | ||
| ) | ||
|
|
||
| // partially copied from https://github.com/openshift/origin/blob/17371a2c6a91e0426045fdd0ab3455c5b457622a/pkg/test/extensions/binary.go | ||
| // and https://github.com/openshift/origin/blob/e0a2fbc82ac1f97dc4fa84a00ed5739c94366926/pkg/clioptions/clusterdiscovery/provider.go | ||
| func initializeTestFramework(provider string) error { | ||
| if len(provider) == 0 { | ||
| provider = "{\"type\":\"skeleton\"}" | ||
| } | ||
| providerInfo := &ClusterConfiguration{} | ||
| if err := json.Unmarshal([]byte(provider), &providerInfo); err != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like it's ok to pass pointer here, for reference https://github.com/openshift/origin/blob/main/pkg/clioptions/clusterdiscovery/provider.go#L207. |
||
| return fmt.Errorf("provider must be a JSON object with the 'type' key at a minimum: %v", err) | ||
| } | ||
| if len(providerInfo.ProviderName) == 0 { | ||
| return fmt.Errorf("provider must be a JSON object with the 'type' key") | ||
| } | ||
| config := &ClusterConfiguration{} | ||
| if err := json.Unmarshal([]byte(provider), config); err != nil { | ||
| return fmt.Errorf("provider must decode into the ClusterConfig object: %v", err) | ||
| } | ||
|
|
||
| // update testContext with loaded config | ||
| testContext := &framework.TestContext | ||
| testContext.Provider = config.ProviderName | ||
| testContext.CloudConfig = framework.CloudConfig{ | ||
| ProjectID: config.ProjectID, | ||
| Region: config.Region, | ||
| Zone: config.Zone, | ||
| Zones: config.Zones, | ||
| NumNodes: config.NumNodes, | ||
| MultiMaster: config.MultiMaster, | ||
| MultiZone: config.MultiZone, | ||
| ConfigFile: config.ConfigFile, | ||
| Provider: framework.NullProvider{}, | ||
| } | ||
| testContext.AllowedNotReadyNodes = 0 | ||
| testContext.MinStartupPods = -1 | ||
| testContext.MaxNodesToGather = 0 | ||
| testContext.KubeConfig = os.Getenv("KUBECONFIG") | ||
|
martinkennelly marked this conversation as resolved.
|
||
| gomega.Expect(testContext.KubeConfig).NotTo(gomega.BeEmpty()) | ||
| testContext.DeleteNamespace = os.Getenv("DELETE_NAMESPACE") != "false" | ||
| testContext.VerifyServiceAccount = false | ||
| //TODO: do we really need the file systems? | ||
| testContext.KubectlPath = "oc" | ||
| if ad := os.Getenv("ARTIFACT_DIR"); len(strings.TrimSpace(ad)) == 0 { | ||
| os.Setenv("ARTIFACT_DIR", filepath.Join(os.TempDir(), "artifacts")) | ||
| } | ||
| // "debian" is used when not set. At least GlusterFS tests need "custom". | ||
| // (There is no option for "rhel" or "centos".) | ||
| testContext.NodeOSDistro = "custom" | ||
| testContext.MasterOSDistro = "custom" | ||
| // load and set the host variable for kubectl | ||
| clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(&clientcmd.ClientConfigLoadingRules{ExplicitPath: testContext.KubeConfig}, &clientcmd.ConfigOverrides{}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should it have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this option is not available for OTE binary, can't be used. |
||
| cfg, err := clientConfig.ClientConfig() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get client config: %v", err) | ||
| } | ||
| testContext.Host = cfg.Host | ||
| testContext.CreateTestingNS = func(ctx context.Context, baseName string, c kclientset.Interface, labels map[string]string) (*corev1.Namespace, error) { | ||
| return ocphacke2e.CreateTestingNS(ctx, baseName, c, labels, true) | ||
| } | ||
| testContext.DumpLogsOnFailure = true | ||
| testContext.ReportDir = os.Getenv("TEST_JUNIT_DIR") | ||
| ocpInfra, err := ocpinfraprovider.New(cfg) | ||
| gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
| gomega.Expect(ocpInfra).NotTo(gomega.BeNil()) | ||
| infraprovider.Set(ocpInfra) | ||
| ocpDeployment := ocpdeploymentconfig.New() | ||
| gomega.Expect(ocpDeployment).NotTo(gomega.BeNil()) | ||
| deploymentconfig.Set(ocpDeployment) | ||
| return nil | ||
| } | ||
|
|
||
| // WriteJUnitReport generates a JUnit file that is shorter than the one | ||
| // normally written by `ginkgo --junit-report`. This is needed because the full | ||
| // report can become too large for tools like Spyglass | ||
| // (https://github.com/kubernetes/kubernetes/issues/111510). | ||
| func writeJUnitReport(report ginkgo.Report, filename string) error { | ||
| config := reporters.JunitReportConfig{ | ||
| // Remove details for specs where we don't care. | ||
| OmitTimelinesForSpecState: types.SpecStatePassed | types.SpecStateSkipped, | ||
|
|
||
| // Don't write <failure message="summary">. The same text is | ||
| // also in the full text for the failure. If we were to write | ||
| // both, then tools like kettle and spyglass would concatenate | ||
| // the two strings and thus show duplicated information. | ||
| OmitFailureMessageAttr: true, | ||
|
|
||
| // All labels are also part of the spec texts in inline [] tags, | ||
| // so we don't need to write them separately. | ||
| OmitSpecLabels: true, | ||
| } | ||
|
|
||
| return reporters.GenerateJUnitReportWithConfig(report, filename, config) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package main | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo; go back to origin folks to export this
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, is this a PITA to do now? seems like a good idea. |
||
| import "k8s.io/apimachinery/pkg/util/sets" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some places we changes to use use
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are using |
||
|
|
||
| // copied directly from https://github.com/openshift/origin/blob/64d4f0e016da7540cca0f27ba2e4eedc79e26d1a/pkg/clioptions/clusterdiscovery/cluster.go | ||
|
|
||
| // HypervisorConfig contains configuration for hypervisor-based recovery operations | ||
| type HypervisorConfig struct { | ||
| HypervisorIP string `json:"hypervisorIP"` | ||
| SSHUser string `json:"sshUser"` | ||
| PrivateKeyPath string `json:"privateKeyPath"` | ||
| } | ||
|
|
||
| type ClusterConfiguration struct { | ||
| ProviderName string `json:"type"` | ||
|
|
||
| // These fields (and the "type" tag for ProviderName) chosen to match | ||
| // upstream's e2e.CloudConfig. | ||
| ProjectID string | ||
| Region string | ||
| Zone string | ||
| NumNodes int | ||
| MultiMaster bool | ||
| MultiZone bool | ||
| Zones []string | ||
| ConfigFile string | ||
|
|
||
| // Disconnected is set for test jobs without external internet connectivity | ||
| Disconnected bool | ||
|
|
||
| // SingleReplicaTopology is set for disabling disruptive tests or tests | ||
| // that require high availability | ||
| SingleReplicaTopology bool | ||
|
|
||
| // NetworkPlugin is the "official" plugin name | ||
| NetworkPlugin string | ||
| // NetworkPluginMode is an optional sub-identifier for the NetworkPlugin. | ||
| // (Currently it is only used for OpenShiftSDN.) | ||
| NetworkPluginMode string `json:",omitempty"` | ||
|
|
||
| // HasIPv4 and HasIPv6 determine whether IPv4-specific, IPv6-specific, | ||
| // and dual-stack-specific tests are run | ||
| HasIPv4 bool | ||
| HasIPv6 bool | ||
| // IPFamily defines default IP stack of the cluster, replaces upstream getDefaultClusterIPFamily | ||
| IPFamily string | ||
|
|
||
| // HasSCTP determines whether SCTP connectivity tests can be run in the cluster | ||
| HasSCTP bool | ||
|
|
||
| // IsProxied determines whether we are accessing the cluster through an HTTP proxy | ||
| IsProxied bool | ||
|
|
||
| // IsIBMROKS determines whether the cluster is Managed IBM Cloud (ROKS) | ||
| IsIBMROKS bool | ||
|
|
||
| // IsNoOptionalCapabilities indicates the cluster has no optional capabilities enabled | ||
| HasNoOptionalCapabilities bool | ||
|
|
||
| // HypervisorConfig contains SSH configuration for hypervisor-based recovery operations | ||
| HypervisorConfig *HypervisorConfig | ||
|
|
||
| // APIGroups contains the set of API groups available in the cluster | ||
| APIGroups sets.Set[string] `json:"-"` | ||
| // EnabledFeatureGates contains the set of enabled feature gates in the cluster | ||
| EnabledFeatureGates sets.Set[string] `json:"-"` | ||
| // DisabledFeatureGates contains the set of disabled feature gates in the cluster | ||
| DisabledFeatureGates sets.Set[string] `json:"-"` | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.