helpers_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Copyright 2018 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 scheduling
  14. import (
  15. "testing"
  16. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  17. )
  18. func TestIsKnownSystemPriorityClass(t *testing.T) {
  19. tests := []struct {
  20. name string
  21. pc *PriorityClass
  22. expected bool
  23. }{
  24. {
  25. name: "system priority class",
  26. pc: SystemPriorityClasses()[0],
  27. expected: true,
  28. },
  29. {
  30. name: "non-system priority class",
  31. pc: &PriorityClass{
  32. ObjectMeta: metav1.ObjectMeta{
  33. Name: SystemNodeCritical,
  34. },
  35. Value: SystemCriticalPriority, // This is the value of system cluster critical
  36. Description: "Used for system critical pods that must not be moved from their current node.",
  37. },
  38. expected: false,
  39. },
  40. }
  41. for _, test := range tests {
  42. if is, err := IsKnownSystemPriorityClass(test.pc); test.expected != is {
  43. t.Errorf("Test [%v]: Expected %v, but got %v. Error: %v", test.name, test.expected, is, err)
  44. }
  45. }
  46. }