-
Notifications
You must be signed in to change notification settings - Fork 72
NO-ISSUE: Add OpenShift Tests Extension (OTE) for baremetal E2E tests #607
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
jadhaj
wants to merge
7
commits into
openshift:main
Choose a base branch
from
jadhaj:add-ote-baremetal-tests
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.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
40c3876
Add OpenShift Tests Extension (OTE) for baremetal E2E tests
jadhaj 7df581c
Clean up Makefile: use vendor for tools and remove -mod=mod
jadhaj 1c53525
Vendor golangci-lint and kustomize to fix -mod=vendor issue
jadhaj ba49f1f
Add vendor cleanup to remove upstream temporary files
jadhaj ad596dd
Fix vendor consistency and regenerate manifests
jadhaj c69f054
Fix OOM build failure by not vendoring golangci-lint
jadhaj 6ae8a48
Fix sed command for cross-platform compatibility
jadhaj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
The diff you're trying to view is too large. We only load the first 3000 changed files.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,63 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| extcmd "github.com/openshift-eng/openshift-tests-extension/pkg/cmd" | ||
| e "github.com/openshift-eng/openshift-tests-extension/pkg/extension" | ||
| et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests" | ||
| g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo" | ||
|
|
||
| // Import test packages to register Ginkgo specs | ||
| _ "github.com/openshift/cluster-baremetal-tests-ext/test/e2e/openshift/baremetal" | ||
| ) | ||
|
|
||
| func main() { | ||
| // Extension registry | ||
| registry := e.NewRegistry() | ||
|
|
||
| // Create extension | ||
| ext := e.NewExtension( | ||
| "openshift", // product | ||
| "payload", // type | ||
| "cluster-baremetal", // component name | ||
|
jadhaj marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| // Add suites to the extension | ||
| ext.AddSuite(e.Suite{ | ||
| Name: "cluster-baremetal/all", | ||
| Parents: []string{"openshift/conformance/parallel"}, | ||
| }) | ||
|
|
||
| // Build test specs from Ginkgo tests automatically | ||
| specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite() | ||
| if err != nil { | ||
| fmt.Fprintf(os.Stderr, "couldn't build extension test specs from ginkgo: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Apply environment selectors - baremetal platform only | ||
| // All tests should only run on baremetal platform | ||
| specs.Select(et.NameContains("")). | ||
| Include(et.PlatformEquals("baremetal")) | ||
|
|
||
| // Add specs to extension | ||
| ext.AddSpecs(specs) | ||
| registry.Register(ext) | ||
|
|
||
| // Create root command | ||
| rootCmd := &cobra.Command{ | ||
| Use: "cluster-baremetal-tests-ext", | ||
| Short: "Cluster BareMetal Operator Test Extension", | ||
| Long: "OpenShift Tests Extension for Cluster BareMetal Operator E2E Tests", | ||
| } | ||
|
|
||
| // Register OTE subcommands (info, list, run-test, run-suite, etc.) | ||
| rootCmd.AddCommand(extcmd.DefaultExtensionCommands(registry)...) | ||
|
|
||
| if err := rootCmd.Execute(); err != nil { | ||
| os.Exit(1) | ||
| } | ||
| } | ||
172 changes: 172 additions & 0 deletions
172
cmd/cluster-baremetal-tests-ext/test/e2e/openshift/baremetal/deployment_sanity.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,172 @@ | ||
| package baremetal | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| g "github.com/onsi/ginkgo/v2" | ||
| o "github.com/onsi/gomega" | ||
| compat_otp "github.com/openshift/origin/test/extended/util/compat_otp" | ||
| e2e "k8s.io/kubernetes/test/e2e/framework" | ||
| ) | ||
|
|
||
| var _ = g.Describe("[sig-baremetal] INSTALLER IPI for INSTALLER_GENERAL job on BareMetal", func() { | ||
| defer g.GinkgoRecover() | ||
| var ( | ||
| oc = compat_otp.NewCLI("baremetal-deployment-sanity", compat_otp.KubeConfigPath()) | ||
| iaasPlatform string | ||
| ) | ||
| g.BeforeEach(func() { | ||
| compat_otp.SkipForSNOCluster(oc) | ||
| iaasPlatform = compat_otp.CheckPlatform(oc) | ||
| if !(iaasPlatform == "baremetal") { | ||
|
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. nit: let's change it to |
||
| e2e.Logf("Cluster is: %s", iaasPlatform) | ||
| g.Skip("For Non-baremetal cluster , this is not supported!") | ||
| } | ||
| }) | ||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 99.7% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-29146-Verify that all clusteroperators are Available", func() { | ||
| g.By("Running oc get clusteroperators") | ||
| res, err := checkOperatorsRunning(oc) | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| o.Expect(res).To(o.BeTrue()) | ||
| }) | ||
|
|
||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 100.0% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-29719-Verify that all nodes are up and running", func() { | ||
| g.By("Running oc get nodes") | ||
| res, err := checkNodesRunning(oc) | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| o.Expect(res).To(o.BeTrue()) | ||
|
|
||
| }) | ||
|
|
||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 99.7% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-32361-Verify that deployment exists and is not empty", func() { | ||
| g.By("Create new namespace") | ||
| oc.SetupProject() | ||
| ns32361 := oc.Namespace() | ||
|
|
||
| g.By("Create deployment") | ||
| deployCreationErr := oc.Run("create").Args("deployment", "deploy32361", "-n", ns32361, "--image", "quay.io/openshifttest/hello-openshift@sha256:4200f438cf2e9446f6bcff9d67ceea1f69ed07a2f83363b7fb52529f7ddd8a83").Execute() | ||
| o.Expect(deployCreationErr).NotTo(o.HaveOccurred()) | ||
|
|
||
| g.By("Check deployment status is available") | ||
| waitForDeployStatus(oc, "deploy32361", ns32361, "True") | ||
| status, err := oc.AsAdmin().Run("get").Args("deployment", "-n", ns32361, "deploy32361", "-o=jsonpath={.status.conditions[?(@.type=='Available')].status}").Output() | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| e2e.Logf("\nDeployment %s Status is %s\n", "deploy32361", status) | ||
| o.Expect(status).To(o.Equal("True")) | ||
|
|
||
| g.By("Check pod is in Running state") | ||
| podName := getPodName(oc, ns32361) | ||
| podStatus := getPodStatus(oc, ns32361, podName) | ||
| o.Expect(podStatus).To(o.Equal("Running")) | ||
| }) | ||
|
|
||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 99.9% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-34195-Verify all pods replicas are running on workers only", func() { | ||
| g.By("Create new namespace") | ||
| oc.SetupProject() | ||
| ns34195 := oc.Namespace() | ||
|
|
||
| g.By("Determine appropriate replica count based on cluster topology") | ||
| // Query control plane topology to handle SNO, compact, and standard clusters | ||
| topologyOutput, err := oc.AsAdmin().Run("get").Args("infrastructure", "cluster", "-o=jsonpath={.status.controlPlaneTopology}").Output() | ||
| replicasNum := 3 // safe default for standard clusters | ||
|
|
||
| if err == nil && topologyOutput != "" { | ||
| switch topologyOutput { | ||
| case "SingleReplica": | ||
| // SNO cluster - single node, limited capacity | ||
| replicasNum = 1 | ||
| case "HighlyAvailable": | ||
| // Standard cluster - use schedulable nodes count | ||
| schedulableNodes, nodeErr := oc.AsAdmin().Run("get").Args("nodes", "-o=jsonpath={.items[?(@.spec.taints[*].effect!='NoSchedule')].metadata.name}").Output() | ||
| if nodeErr == nil && schedulableNodes != "" { | ||
| nodeList := strings.Fields(schedulableNodes) | ||
| if len(nodeList) > 0 { | ||
| replicasNum = len(nodeList) + 1 | ||
| } | ||
| } else { | ||
| // Fallback to worker nodes count if schedulable query fails | ||
| workerNodes, workerErr := compat_otp.GetClusterNodesBy(oc, "worker") | ||
| if workerErr == nil && len(workerNodes) > 0 { | ||
| replicasNum = len(workerNodes) + 1 | ||
| } | ||
| } | ||
| default: | ||
| // External or unknown topology - use safe default | ||
| e2e.Logf("Unknown topology %s, using default replica count: %d", topologyOutput, replicasNum) | ||
| } | ||
| } else { | ||
| e2e.Logf("Unable to query control plane topology, using default replica count: %d", replicasNum) | ||
| } | ||
|
|
||
| g.By(fmt.Sprintf("Create deployment with %d replicas", replicasNum)) | ||
| deployCreationErr := oc.Run("create").Args("deployment", "deploy34195", "-n", ns34195, fmt.Sprintf("--replicas=%d", replicasNum), "--image", "quay.io/openshifttest/hello-openshift@sha256:4200f438cf2e9446f6bcff9d67ceea1f69ed07a2f83363b7fb52529f7ddd8a83").Execute() | ||
| o.Expect(deployCreationErr).NotTo(o.HaveOccurred()) | ||
| waitForDeployStatus(oc, "deploy34195", ns34195, "True") | ||
|
|
||
| g.By("Check deployed pods number is as expected") | ||
| pods, err := oc.AsAdmin().Run("get").Args("pods", "-n", ns34195, "--field-selector=status.phase=Running", "-o=jsonpath={.items[*].metadata.name}").Output() | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| podList := strings.Fields(pods) | ||
| o.Expect(len(podList)).To(o.Equal(replicasNum)) | ||
|
|
||
| g.By("Check pods are deployed on worker nodes only") | ||
| for _, pod := range podList { | ||
| podNodeName, err := compat_otp.GetPodNodeName(oc, ns34195, pod) | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| res := compat_otp.IsWorkerNode(oc, podNodeName) | ||
| if !res { | ||
| e2e.Logf("\nPod %s was deployed on non worker node %s\n", pod, podNodeName) | ||
| } | ||
| o.Expect(res).To(o.BeTrue()) | ||
| } | ||
| }) | ||
|
|
||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 99.7% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-39126-Verify maximum CPU usage limit hasn't reached on each of the nodes", func() { | ||
| g.By("Running oc get nodes") | ||
| cpuExceededNodes := []string{} | ||
| sampling_time, err := getClusterUptime(oc) | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| nodeNames, nodeErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "-o=jsonpath={.items[*].metadata.name}").Output() | ||
| o.Expect(nodeErr).NotTo(o.HaveOccurred(), "Failed to execute oc get nodes") | ||
| nodes := strings.Fields(nodeNames) | ||
| for _, node := range nodes { | ||
| cpuUsage := getNodeCpuUsage(oc, node, sampling_time) | ||
| if cpuUsage > maxCpuUsageAllowed { | ||
| cpuExceededNodes = append(cpuExceededNodes, node) | ||
| e2e.Logf("\ncpu usage of exceeded node: %s is %.2f%%", node, cpuUsage) | ||
| } | ||
| } | ||
| o.Expect(cpuExceededNodes).Should(o.BeEmpty(), "These nodes exceed max CPU usage allowed: %s", cpuExceededNodes) | ||
| }) | ||
|
|
||
| // author: jhajyahy@redhat.com | ||
| // port=yes - 99.6% pass rate (724 runs last 60 days) | ||
| g.It("Author:jhajyahy-Medium-39125-Verify that every node memory is sufficient", func() { | ||
| g.By("Running oc get nodes") | ||
| outOfMemoryNodes := []string{} | ||
| nodeNames, nodeErr := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "-o=jsonpath={.items[*].metadata.name}").Output() | ||
| o.Expect(nodeErr).NotTo(o.HaveOccurred(), "Failed to execute oc get nodes") | ||
| nodes := strings.Fields(nodeNames) | ||
| for _, node := range nodes { | ||
| availMem := getNodeavailMem(oc, node) | ||
| e2e.Logf("\nAvailable mem of Node %s is %d", node, availMem) | ||
| if availMem < minRequiredMemoryInBytes { | ||
| outOfMemoryNodes = append(outOfMemoryNodes, node) | ||
| e2e.Logf("\nNode %s does not meet minimum required memory %d Bytes ", node, minRequiredMemoryInBytes) | ||
|
|
||
| } | ||
| } | ||
| o.Expect(outOfMemoryNodes).Should(o.BeEmpty(), "These nodes does not meet minimum required memory: %s", outOfMemoryNodes) | ||
| }) | ||
| }) | ||
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.