tolerations_test.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. suite: pod tolerations test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should pass with empty tolerations
  6. set:
  7. podOptions:
  8. tolerations: []
  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. isNull:
  21. path: spec.template.spec.tolerations
  22. - it: should pass with tolerations from "global"
  23. set:
  24. podOptions:
  25. tolerations:
  26. - operator: Exists
  27. effect: NoExecute
  28. tolerationSeconds: 3600
  29. workload:
  30. workload-name1:
  31. enabled: true
  32. primary: true
  33. type: Deployment
  34. podSpec: {}
  35. asserts:
  36. - documentIndex: *deploymentDoc
  37. equal:
  38. path: spec.template.spec.tolerations
  39. value:
  40. - operator: Exists
  41. effect: NoExecute
  42. tolerationSeconds: 3600
  43. - it: should pass with tolerations from "pod"
  44. set:
  45. podOptions:
  46. tolerations:
  47. - operator: Exists
  48. effect: NoExecute
  49. tolerationSeconds: 3600
  50. workload:
  51. workload-name1:
  52. enabled: true
  53. primary: true
  54. type: Deployment
  55. podSpec:
  56. tolerations:
  57. - operator: Exists
  58. effect: NoSchedule
  59. tolerationSeconds: 1800
  60. asserts:
  61. - documentIndex: *deploymentDoc
  62. equal:
  63. path: spec.template.spec.tolerations
  64. value:
  65. - operator: Exists
  66. effect: NoSchedule
  67. tolerationSeconds: 1800
  68. - it: should pass with tolerations from "pod" with tpl
  69. set:
  70. op: Exists
  71. effect: NoSchedule
  72. op1: Equal
  73. effect1: PreferNoSchedule
  74. key: key
  75. value: value
  76. podOptions:
  77. tolerations:
  78. - operator: Exists
  79. effect: NoExecute
  80. tolerationSeconds: 3600
  81. workload:
  82. workload-name1:
  83. enabled: true
  84. primary: true
  85. type: Deployment
  86. podSpec:
  87. tolerations:
  88. - operator: "{{ .Values.op }}"
  89. effect: "{{ .Values.effect }}"
  90. tolerationSeconds: 1800
  91. - operator: "{{ .Values.op1 }}"
  92. effect: "{{ .Values.effect1 }}"
  93. tolerationSeconds: 1800
  94. key: "{{ .Values.key }}"
  95. value: "{{ .Values.value }}"
  96. asserts:
  97. - documentIndex: *deploymentDoc
  98. equal:
  99. path: spec.template.spec.tolerations
  100. value:
  101. - operator: Exists
  102. effect: NoSchedule
  103. tolerationSeconds: 1800
  104. - operator: Equal
  105. effect: PreferNoSchedule
  106. tolerationSeconds: 1800
  107. key: key
  108. value: value
  109. # Failures
  110. - it: should fail with invalid operator
  111. set:
  112. workload:
  113. workload-name1:
  114. enabled: true
  115. primary: true
  116. type: Deployment
  117. podSpec:
  118. tolerations:
  119. - operator: Invalid
  120. asserts:
  121. - failedTemplate:
  122. errorMessage: Expected <tolerations.operator> to be one of [Exists, Equal] but got [Invalid]
  123. - it: should fail with empty key and operator set to Equal
  124. set:
  125. workload:
  126. workload-name1:
  127. enabled: true
  128. primary: true
  129. type: Deployment
  130. podSpec:
  131. tolerations:
  132. - operator: Equal
  133. value: value
  134. asserts:
  135. - failedTemplate:
  136. errorMessage: Expected non-empty <tolerations.key> and <tolerations.value> with <tolerations.operator> set to [Equal]
  137. - it: should fail with empty value and operator set to Equal
  138. set:
  139. workload:
  140. workload-name1:
  141. enabled: true
  142. primary: true
  143. type: Deployment
  144. podSpec:
  145. tolerations:
  146. - operator: Equal
  147. key: key
  148. asserts:
  149. - failedTemplate:
  150. errorMessage: Expected non-empty <tolerations.key> and <tolerations.value> with <tolerations.operator> set to [Equal]
  151. - it: should fail with value set and operator set to Exists
  152. set:
  153. workload:
  154. workload-name1:
  155. enabled: true
  156. primary: true
  157. type: Deployment
  158. podSpec:
  159. tolerations:
  160. - operator: Exists
  161. value: value
  162. asserts:
  163. - failedTemplate:
  164. errorMessage: Expected empty <tolerations.value> with <tolerations.operator> set to [Exists], but got [value]
  165. - it: should fail with effect set to Invalid
  166. set:
  167. workload:
  168. workload-name1:
  169. enabled: true
  170. primary: true
  171. type: Deployment
  172. podSpec:
  173. tolerations:
  174. - operator: Exists
  175. effect: Invalid
  176. asserts:
  177. - failedTemplate:
  178. errorMessage: Expected <tolerations.effect> to be one of [NoExecute, NoSchedule, PreferNoSchedule], but got [Invalid]
  179. - it: should fail with tolerationSeconds not a number
  180. set:
  181. workload:
  182. workload-name1:
  183. enabled: true
  184. primary: true
  185. type: Deployment
  186. podSpec:
  187. tolerations:
  188. - operator: Exists
  189. tolerationSeconds: not-a-number
  190. asserts:
  191. - failedTemplate:
  192. errorMessage: Expected <tolerations.tolerationSeconds> to be a number, but got [not-a-number]