Skip to content
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

test: extended: add test checking for mismatch between Machines and Nodes #25419

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions test/extended/machines/cluster.go
@@ -0,0 +1,49 @@
package operators

import (
"context"

g "github.com/onsi/ginkgo"
o "github.com/onsi/gomega"
"github.com/stretchr/objx"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
e2e "k8s.io/kubernetes/test/e2e/framework"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"

"github.com/openshift/origin/test/extended/util/ibmcloud"
)

var _ = g.Describe("[sig-cluster-lifecycle][Feature:Machines][Early] Managed cluster should", func() {
defer g.GinkgoRecover()

g.It("have same number of Machines and Nodes", func() {
if e2e.TestContext.Provider == ibmcloud.ProviderName {
Copy link
Member

Choose a reason for hiding this comment

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

This is just a special case of the "UPI/no-machineAPI" scenario that also applies in e.g. AWS UPI, so should be replaced by whatever check we use for that.

e2eskipper.Skipf("IBM Cloud clusters do not contain machineset resources")
}

cfg, err := e2e.LoadConfig()
o.Expect(err).NotTo(o.HaveOccurred())
c, err := e2e.LoadClientset()
o.Expect(err).NotTo(o.HaveOccurred())
dc, err := dynamic.NewForConfig(cfg)
o.Expect(err).NotTo(o.HaveOccurred())

g.By("getting Node list")
nodeList, err := c.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
nodeItems := nodeList.Items

g.By("getting Machine list")
machineClient := dc.Resource(schema.GroupVersionResource{Group: "machine.openshift.io", Resource: "machines", Version: "v1beta1"})
obj, err := machineClient.List(context.Background(), metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
machineList := objx.Map(obj.UnstructuredContent())
machineItems := objects(machineList.Get("items"))

g.By("ensure number of Machines and Nodes are equal")
o.Expect(len(nodeItems)).To(o.Equal(len(machineItems)))
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.