restart_policy_test.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. suite: pod restart policy test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should pass with restartPolicy empty
  6. set:
  7. podOptions:
  8. restartPolicy: ""
  9. workload:
  10. workload-name1:
  11. enabled: true
  12. primary: true
  13. type: Deployment
  14. podSpec: {}
  15. asserts:
  16. - documentIndex: &deploymentDoc 0
  17. isKind:
  18. of: Deployment
  19. - documentIndex: *deploymentDoc
  20. equal:
  21. path: spec.template.spec.restartPolicy
  22. value: Always
  23. - it: should pass with restartPolicy set from "global"
  24. set:
  25. podOptions:
  26. restartPolicy: Always
  27. workload:
  28. workload-name1:
  29. enabled: true
  30. primary: true
  31. type: Deployment
  32. podSpec: {}
  33. asserts:
  34. - documentIndex: *deploymentDoc
  35. equal:
  36. path: spec.template.spec.restartPolicy
  37. value: Always
  38. - it: should pass with restartPolicy set from "pod"
  39. set:
  40. podOptions:
  41. restartPolicy: Never
  42. workload:
  43. workload-name1:
  44. enabled: true
  45. primary: true
  46. type: Deployment
  47. podSpec:
  48. restartPolicy: Always
  49. asserts:
  50. - documentIndex: *deploymentDoc
  51. equal:
  52. path: spec.template.spec.restartPolicy
  53. value: Always
  54. - it: should pass with restartPolicy set from "pod" on Jobs
  55. set:
  56. podOptions:
  57. restartPolicy: Never
  58. workload:
  59. workload-name1:
  60. enabled: true
  61. primary: true
  62. type: Job
  63. podSpec:
  64. restartPolicy: OnFailure
  65. asserts:
  66. - documentIndex: &jobDoc 0
  67. isKind:
  68. of: Job
  69. - documentIndex: *jobDoc
  70. equal:
  71. path: spec.template.spec.restartPolicy
  72. value: OnFailure
  73. - it: should pass with restartPolicy set from "pod" on Jobs from tpl
  74. set:
  75. policy: OnFailure
  76. podOptions:
  77. restartPolicy: Never
  78. workload:
  79. workload-name1:
  80. enabled: true
  81. primary: true
  82. type: Job
  83. podSpec:
  84. restartPolicy: "{{ .Values.policy }}"
  85. asserts:
  86. - documentIndex: *jobDoc
  87. equal:
  88. path: spec.template.spec.restartPolicy
  89. value: OnFailure
  90. # Failures
  91. - it: should fail with restartPolicy to Never on Deployment
  92. set:
  93. podOptions:
  94. restartPolicy: Never
  95. workload:
  96. workload-name1:
  97. enabled: true
  98. primary: true
  99. type: Deployment
  100. podSpec: {}
  101. asserts:
  102. - failedTemplate:
  103. errorMessage: Expected <restartPolicy to be [Always] for [Deployment] but got [Never]
  104. - it: should fail with restartPolicy to invalid on global
  105. set:
  106. podOptions:
  107. restartPolicy: invalid
  108. workload:
  109. workload-name1:
  110. enabled: true
  111. primary: true
  112. type: Deployment
  113. podSpec: {}
  114. asserts:
  115. - failedTemplate:
  116. errorMessage: Expected <restartPolicy to be one of [Never, Always, OnFailure] but got [invalid]
  117. - it: should fail with restartPolicy to invalid-policy on pod
  118. set:
  119. podOptions:
  120. restartPolicy: invalid
  121. workload:
  122. workload-name1:
  123. enabled: true
  124. primary: true
  125. type: Deployment
  126. podSpec:
  127. restartPolicy: invalid-policy
  128. asserts:
  129. - failedTemplate:
  130. errorMessage: Expected <restartPolicy to be one of [Never, Always, OnFailure] but got [invalid-policy]