Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
32 changes: 32 additions & 0 deletions test/extended/pods/priorityclasses.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

. "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
e2e "k8s.io/kubernetes/test/e2e/framework"
Expand Down Expand Up @@ -88,6 +89,37 @@ var _ = Describe("[sig-arch] Managed cluster should", func() {
})
})

var _ = Describe("[sig-node] Pod priority should match the default priorityClassName values", func() {
defer GinkgoRecover()
var (
oc = exutil.NewCLI("priority-class-name")
systemNodeCriticalPodFile = exutil.FixturePath("testdata", "priority-class-name", "system-node-critical.yaml")
systemClusterCriticalPodFile = exutil.FixturePath("testdata", "priority-class-name", "system-cluster-critical.yaml")
)

It("system-node-critical=2000001000", func() {
By("creating the pods")
err := oc.Run("create").Args("-f", systemNodeCriticalPodFile).Execute()

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.

Each pod needs to be cleaned/deleted after it's used. Also, better to create both pods in a temporary namespace.

o.Expect(err).NotTo(o.HaveOccurred())

By("checking the pod priority")
out, err := oc.Run("get").Args("pods/pod-with-system-node-critical-priority-class").Template("{{.spec.priority}}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.Equal("2000001000"))
})

It("system-cluster-critical=2000000000", func() {
By("creating the pods")
err := oc.Run("create").Args("-f", systemClusterCriticalPodFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

By("checking the pod priority")
out, err := oc.Run("get").Args("pods/pod-with-system-cluster-critical-priority-class").Template("{{.spec.priority}}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(out).To(o.Equal("2000000000"))
})
})

func hasPrefixSet(name string, set sets.String) bool {
for _, prefix := range set.List() {
if strings.HasPrefix(name, prefix) {
Expand Down
66 changes: 66 additions & 0 deletions test/extended/testdata/bindata.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-system-cluster-critical-priority-class
spec:
containers:
- name: busybox
image: busybox

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.

busybox image has not been used in the tests before. Would you please try image-registry.openshift-image-registry.svc:5000/openshift/tools:latest instead? To reduce the number of pulled images. E.g. https://github.com/openshift/origin/blob/main/test/extended/testdata/cmd/test/cmd/testdata/rollingupdate-daemonset.yaml#L30-L31 runs sleep command through tools:latest as well.

command:
- sleep
- "3600"
priorityClassName: system-cluster-critical
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-with-system-node-critical-priority-class
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3600"
priorityClassName: system-node-critical

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