helpers_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v1
  14. import (
  15. "testing"
  16. v1 "k8s.io/api/scheduling/v1"
  17. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  18. "k8s.io/kubernetes/pkg/apis/scheduling"
  19. )
  20. func TestIsKnownSystemPriorityClass(t *testing.T) {
  21. tests := []struct {
  22. name string
  23. pc *v1.PriorityClass
  24. expected bool
  25. }{
  26. {
  27. name: "system priority class",
  28. pc: SystemPriorityClasses()[0],
  29. expected: true,
  30. },
  31. {
  32. name: "non-system priority class",
  33. pc: &v1.PriorityClass{
  34. ObjectMeta: metav1.ObjectMeta{
  35. Name: scheduling.SystemNodeCritical,
  36. },
  37. Value: scheduling.SystemCriticalPriority, // This is the value of system cluster critical
  38. Description: "Used for system critical pods that must not be moved from their current node.",
  39. },
  40. expected: false,
  41. },
  42. }
  43. for _, test := range tests {
  44. if is, err := IsKnownSystemPriorityClass(test.pc.Name, test.pc.Value, test.pc.GlobalDefault); test.expected != is {
  45. t.Errorf("Test [%v]: Expected %v, but got %v. Error: %v", test.name, test.expected, is, err)
  46. }
  47. }
  48. }