Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ WORKDIR /go/src/github.com/openshift/ovn-kubernetes
COPY . .
RUN cd go-controller; CGO_ENABLED=1 make
RUN cd go-controller; CGO_ENABLED=0 make windows
RUN cd openshift; CGO_ENABLED=0 ./hack/build-tests-ext.sh && \
gzip ./bin/ovn-kubernetes-tests-ext

# Build RHEL-8 binaries (for upgrades from 4.12 and earlier)
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.22 AS rhel8
Expand Down Expand Up @@ -58,6 +60,7 @@ COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_o
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovnkube-trace /usr/bin/
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/hybrid-overlay-node /usr/bin/
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovnkube-observ /usr/bin/
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/openshift/bin/ovn-kubernetes-tests-ext.gz /usr/bin/

# Copy RHEL-8 and RHEL-9 shim binaries where the CNO's ovnkube-node container startup script can find them
RUN mkdir -p /usr/libexec/cni/rhel9
Expand All @@ -73,7 +76,7 @@ RUN stat /usr/bin/oc
LABEL io.k8s.display-name="ovn kubernetes" \
io.k8s.description="This is a component of OpenShift Container Platform that provides an overlay network using ovn." \
summary="This is a component of OpenShift Container Platform that provides an overlay network using ovn." \
io.openshift.tags="openshift" \
io.openshift.tags="openshift,networking" \
Comment thread
martinkennelly marked this conversation as resolved.
maintainer="Tim Rozet <trozet@redhat.com>"

WORKDIR /root
Expand Down
9 changes: 9 additions & 0 deletions openshift/cmd/annotate/main.go
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 })
}
24 changes: 24 additions & 0 deletions openshift/cmd/ovn-kubernetes-tests-ext/labels.go
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
}
92 changes: 92 additions & 0 deletions openshift/cmd/ovn-kubernetes-tests-ext/main.go
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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:

  • Keep the new names, but try to create a rename mapping file for ci-test-mapping to link up the renames. And remove the existing tests in origin.
  • Make the names match somehow

origin:

[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:UserDefinedPrimaryNetworks] when using openshift ovn-kubernetes ClusterUserDefinedNetwork CRD Controller pod connected to ClusterUserDefinedNetwork CR & managed NADs cannot be deleted when being used [Suite:openshift/conformance/parallel]

ovnk-tests-ext:

[ovn-kubernetes][Feature:NetworkSegmentation] ClusterUserDefinedNetwork CRD Controller pod connected to ClusterUserDefinedNetwork CR & managed NADs cannot be deleted when being used [Suite:openshift/conformance/parallel]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the new names, but try to create a rename mapping file for ci-test-mapping to link up the renames. And remove the existing tests in origin.

Yea, I went with renaming in-order to be consistent. Thats still WIP upstream but i cherry-picked it here for test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on renaming PR tomorrow.

Comment thread
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")`},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about Parallelism and TestTimeout parameters ? are we fine with default values ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 annotate.go?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test labels from annotate.go is already applied on the tests and added to AppendedAnnotations map. This is retrieved below with specs.Walk and then suite configuration is applied on tests matching qualifier.


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)
}
}
118 changes: 118 additions & 0 deletions openshift/cmd/ovn-kubernetes-tests-ext/provider.go
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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using &providerInfohere doesn't look good, shouldn't it be just providerInfo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Comment thread
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{})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it have dryRun option ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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)
}
69 changes: 69 additions & 0 deletions openshift/cmd/ovn-kubernetes-tests-ext/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo; go back to origin folks to export this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some places we changes to use use "github.com/openshift-eng/openshift-tests-extension/pkg/util/sets", why would we use one vs the other

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using k8s.io/apimachinery/pkg/util/sets now. I updated it.


// 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:"-"`
}
Loading