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

NO-JIRA: Introduce version annotation test for Windows nodes #29190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions test/extended/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ import (
_ "github.com/openshift/origin/test/extended/tbr_health"
_ "github.com/openshift/origin/test/extended/templates"
_ "github.com/openshift/origin/test/extended/user"
_ "github.com/openshift/origin/test/extended/windows"
)

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

9 changes: 9 additions & 0 deletions test/extended/windows/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See the OWNERS docs at https://go.k8s.io/owners
# Follows https://github.com/openshift/windows-machine-config-operator root OWNERS

reviewers:
- sebsoto
- mansikulkarni96
approvers:
- sebsoto
- mansikulkarni96
55 changes: 55 additions & 0 deletions test/extended/windows/nodes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package windows

import (
"context"
"strings"

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
exutil "github.com/openshift/origin/test/extended/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
e2e "k8s.io/kubernetes/test/e2e/framework"
)

const (
// NodeLabelSelector is a label selector that can be used to filter Windows nodes
NodeLabelSelector = corev1.LabelOSStable + "=windows"
// VersionAnnotation indicates the version of WMCO that configured the node
VersionAnnotation = "windowsmachineconfig.openshift.io/version"
)

var _ = g.Describe("[sig-windows] Nodes", func() {
defer g.GinkgoRecover()

var windowsNodes []corev1.Node

oc := exutil.NewCLIWithoutNamespace("windows")

g.BeforeEach(func() {
// fetch the list of Windows nodes
nodes, err := oc.AdminKubeClient().CoreV1().Nodes().List(context.Background(),
metav1.ListOptions{LabelSelector: NodeLabelSelector})
o.Expect(err).ToNot(o.HaveOccurred())
// update the windowsNodes variable to the list of Windows nodes
windowsNodes = nodes.Items
// skip if no Windows nodes
if len(windowsNodes) < 1 {
g.Skip("Skip. No Windows node found on the test cluster.")
}
})

g.It("should fail with invalid version annotation", func() {
g.By("process version annotation")
for _, node := range windowsNodes {
annotations := node.GetAnnotations()
v, ok := annotations[VersionAnnotation]
if !ok {
e2e.Failf("missing version annotation on node %s", node.Name)
}
if strings.TrimSpace(v) == "" {
e2e.Failf("emtpy version annotation on node %s", node.Name)
}
}
})
})