Skip to content
Closed
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
36 changes: 36 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,41 @@ 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", func() {
By("creating the pods")
err := oc.Run("create").Args("-n", oc.Namespace(), "-f", systemNodeCriticalPodFile).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

By("checking the pod priority")
pod, err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).Get(context.Background(), "pod-with-system-node-critical-priority-class", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect((int)(*pod.Spec.Priority)).To(o.Equal(2000001000))
err = oc.KubeClient().CoreV1().Pods(oc.Namespace()).Delete(context.Background(), "pod-with-system-node-critical-priority-class", metav1.DeleteOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
})

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

By("checking the pod priority")
pod, err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).Get(context.Background(), "pod-with-system-cluster-critical-priority-class", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect((int)(*pod.Spec.Priority)).To(o.Equal(2000000000))
err = oc.KubeClient().CoreV1().Pods(oc.Namespace()).Delete(context.Background(), "pod-with-system-cluster-critical-priority-class", metav1.DeleteOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
})
})

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: tools
image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
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: tools
image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
command:
- sleep
- "3600"
priorityClassName: system-node-critical