envFrom_test.yaml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. suite: container envFrom test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should create the correct envFrom
  6. set:
  7. image: &image
  8. repository: nginx
  9. tag: 1.19.0
  10. pullPolicy: IfNotPresent
  11. configmap:
  12. configmap-name:
  13. enabled: true
  14. data:
  15. key1: value1
  16. key2: value2
  17. secret:
  18. secret-name:
  19. enabled: true
  20. data:
  21. key3: value3
  22. key4: value4
  23. workload:
  24. workload-name:
  25. enabled: true
  26. primary: true
  27. type: Deployment
  28. podSpec:
  29. containers:
  30. container-name1:
  31. enabled: true
  32. primary: true
  33. imageSelector: image
  34. probes: &probes
  35. liveness:
  36. enabled: false
  37. readiness:
  38. enabled: false
  39. startup:
  40. enabled: false
  41. envFrom:
  42. - configMapRef:
  43. name: configmap-name
  44. - secretRef:
  45. name: secret-name
  46. asserts:
  47. - documentIndex: &deploymentDoc 2
  48. isKind:
  49. of: Deployment
  50. - documentIndex: *deploymentDoc
  51. isAPIVersion:
  52. of: apps/v1
  53. - documentIndex: *deploymentDoc
  54. isSubset:
  55. path: spec.template.spec.containers[0]
  56. content:
  57. envFrom:
  58. - configMapRef:
  59. name: release-name-common-test-configmap-name
  60. - secretRef:
  61. name: release-name-common-test-secret-name
  62. - it: should create the correct envFrom without expanding the name
  63. set:
  64. image: &image
  65. repository: nginx
  66. tag: 1.19.0
  67. pullPolicy: IfNotPresent
  68. some_config_name: configmap-name
  69. some_secret_name: secret-name
  70. workload:
  71. workload-name:
  72. enabled: true
  73. primary: true
  74. type: Deployment
  75. podSpec:
  76. containers:
  77. container-name1:
  78. enabled: true
  79. primary: true
  80. imageSelector: image
  81. probes: &probes
  82. liveness:
  83. enabled: false
  84. readiness:
  85. enabled: false
  86. startup:
  87. enabled: false
  88. envFrom:
  89. - configMapRef:
  90. name: "{{ .Values.some_config_name }}"
  91. expandObjectName: false
  92. - secretRef:
  93. name: "{{ .Values.some_secret_name }}"
  94. expandObjectName: false
  95. asserts:
  96. - documentIndex: &deploymentDoc 0
  97. isKind:
  98. of: Deployment
  99. - documentIndex: *deploymentDoc
  100. isAPIVersion:
  101. of: apps/v1
  102. - documentIndex: *deploymentDoc
  103. isSubset:
  104. path: spec.template.spec.containers[0]
  105. content:
  106. envFrom:
  107. - configMapRef:
  108. name: configmap-name
  109. - secretRef:
  110. name: secret-name
  111. # Failures
  112. - it: it should fail without a valid ref
  113. set:
  114. image: *image
  115. workload:
  116. workload-name:
  117. enabled: true
  118. primary: true
  119. type: Deployment
  120. podSpec:
  121. containers:
  122. container-name1:
  123. enabled: true
  124. primary: true
  125. imageSelector: image
  126. probes: *probes
  127. envFrom:
  128. - invalidRef:
  129. name: invalid-name
  130. asserts:
  131. - failedTemplate:
  132. errorMessage: Container - Expected <envFrom> entry to have one of [configMapRef, secretRef]
  133. - it: it should fail with both refs in the same entry
  134. set:
  135. image: *image
  136. workload:
  137. workload-name:
  138. enabled: true
  139. primary: true
  140. type: Deployment
  141. podSpec:
  142. containers:
  143. container-name1:
  144. enabled: true
  145. primary: true
  146. imageSelector: image
  147. probes: *probes
  148. envFrom:
  149. - configMapRef:
  150. name: configmap-name
  151. secretRef:
  152. name: secret-name
  153. asserts:
  154. - failedTemplate:
  155. errorMessage: Container - Expected <envFrom> entry to have only one of [configMapRef, secretRef], but got both
  156. - it: it should fail with empty name in configMapRef
  157. set:
  158. image: *image
  159. workload:
  160. workload-name:
  161. enabled: true
  162. primary: true
  163. type: Deployment
  164. podSpec:
  165. containers:
  166. container-name1:
  167. enabled: true
  168. primary: true
  169. imageSelector: image
  170. probes: *probes
  171. envFrom:
  172. - configMapRef:
  173. name: ""
  174. asserts:
  175. - failedTemplate:
  176. errorMessage: Container - Expected non-empty <envFrom.configMapRef.name>
  177. - it: it should fail with empty name in secretRef
  178. set:
  179. image: *image
  180. workload:
  181. workload-name:
  182. enabled: true
  183. primary: true
  184. type: Deployment
  185. podSpec:
  186. containers:
  187. container-name1:
  188. enabled: true
  189. primary: true
  190. imageSelector: image
  191. probes: *probes
  192. envFrom:
  193. - secretRef:
  194. name: ""
  195. asserts:
  196. - failedTemplate:
  197. errorMessage: Container - Expected non-empty <envFrom.secretRef.name>
  198. - it: it should fail without defined configmap
  199. set:
  200. image: *image
  201. configmap:
  202. configmap-name:
  203. enabled: true
  204. data:
  205. key1: value1
  206. key2: value2
  207. workload:
  208. workload-name:
  209. enabled: true
  210. primary: true
  211. type: Deployment
  212. podSpec:
  213. containers:
  214. container-name1:
  215. enabled: true
  216. primary: true
  217. imageSelector: image
  218. probes: *probes
  219. envFrom:
  220. - configMapRef:
  221. name: configmap-other-name
  222. asserts:
  223. - failedTemplate:
  224. errorMessage: Container - Expected ConfigMap [configmap-other-name] defined in <envFrom> to exist
  225. - it: it should fail without defined secret
  226. set:
  227. image: *image
  228. secret:
  229. secret-name:
  230. enabled: true
  231. data:
  232. key1: value1
  233. key2: value2
  234. workload:
  235. workload-name:
  236. enabled: true
  237. primary: true
  238. type: Deployment
  239. podSpec:
  240. containers:
  241. container-name1:
  242. enabled: true
  243. primary: true
  244. imageSelector: image
  245. probes: *probes
  246. envFrom:
  247. - secretRef:
  248. name: secret-other-name
  249. asserts:
  250. - failedTemplate:
  251. errorMessage: Container - Expected Secret [secret-other-name] defined in <envFrom> to exist