global_values_test.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. suite: test global values
  2. # This test suite validates the global values functionality for:
  3. # - global.podLabels: Global pod labels applied to all deployments
  4. # - global.podAnnotations: Global pod annotations applied to all deployments
  5. # - global.imagePullSecrets: Global image pull secrets applied to all deployments
  6. # - global.repository: Global image repository applied to all deployments
  7. #
  8. # Test coverage:
  9. # 1. Verify global values are used when local values are not set
  10. # 2. Verify local values take precedence over global values
  11. # 3. Verify all three deployments (controller, webhook, cert-controller) respect the logic
  12. # 4. Verify combined scenarios with multiple global values
  13. templates:
  14. - deployment.yaml
  15. - webhook-deployment.yaml
  16. - cert-controller-deployment.yaml
  17. tests:
  18. # Test global.podLabels
  19. - it: should use global podLabels when local podLabels not set (controller)
  20. template: deployment.yaml
  21. set:
  22. global.podLabels:
  23. globalLabel: "global-value"
  24. environment: "production"
  25. asserts:
  26. - equal:
  27. path: spec.template.metadata.labels.globalLabel
  28. value: "global-value"
  29. - equal:
  30. path: spec.template.metadata.labels.environment
  31. value: "production"
  32. - it: should use local podLabels over global podLabels (controller)
  33. template: deployment.yaml
  34. set:
  35. global.podLabels:
  36. globalLabel: "global-value"
  37. podLabels:
  38. localLabel: "local-value"
  39. asserts:
  40. - equal:
  41. path: spec.template.metadata.labels.localLabel
  42. value: "local-value"
  43. - notExists:
  44. path: spec.template.metadata.labels.globalLabel
  45. - it: should use global podLabels when local podLabels not set (webhook)
  46. template: webhook-deployment.yaml
  47. set:
  48. global.podLabels:
  49. globalLabel: "global-value"
  50. environment: "production"
  51. asserts:
  52. - equal:
  53. path: spec.template.metadata.labels.globalLabel
  54. value: "global-value"
  55. - equal:
  56. path: spec.template.metadata.labels.environment
  57. value: "production"
  58. - it: should use local podLabels over global podLabels (webhook)
  59. template: webhook-deployment.yaml
  60. set:
  61. global.podLabels:
  62. globalLabel: "global-value"
  63. webhook.podLabels:
  64. localLabel: "local-value"
  65. asserts:
  66. - equal:
  67. path: spec.template.metadata.labels.localLabel
  68. value: "local-value"
  69. - notExists:
  70. path: spec.template.metadata.labels.globalLabel
  71. - it: should use global podLabels when local podLabels not set (cert-controller)
  72. template: cert-controller-deployment.yaml
  73. set:
  74. global.podLabels:
  75. globalLabel: "global-value"
  76. environment: "production"
  77. asserts:
  78. - equal:
  79. path: spec.template.metadata.labels.globalLabel
  80. value: "global-value"
  81. - equal:
  82. path: spec.template.metadata.labels.environment
  83. value: "production"
  84. - it: should use local podLabels over global podLabels (cert-controller)
  85. template: cert-controller-deployment.yaml
  86. set:
  87. global.podLabels:
  88. globalLabel: "global-value"
  89. certController.podLabels:
  90. localLabel: "local-value"
  91. asserts:
  92. - equal:
  93. path: spec.template.metadata.labels.localLabel
  94. value: "local-value"
  95. - notExists:
  96. path: spec.template.metadata.labels.globalLabel
  97. # Test global.podAnnotations
  98. - it: should use global podAnnotations when local podAnnotations not set (controller)
  99. template: deployment.yaml
  100. set:
  101. global.podAnnotations:
  102. globalAnnotation: "global-value"
  103. environment: "production"
  104. asserts:
  105. - equal:
  106. path: spec.template.metadata.annotations.globalAnnotation
  107. value: "global-value"
  108. - equal:
  109. path: spec.template.metadata.annotations.environment
  110. value: "production"
  111. - it: should use local podAnnotations over global podAnnotations (controller)
  112. template: deployment.yaml
  113. set:
  114. global.podAnnotations:
  115. globalAnnotation: "global-value"
  116. podAnnotations:
  117. localAnnotation: "local-value"
  118. asserts:
  119. - equal:
  120. path: spec.template.metadata.annotations.localAnnotation
  121. value: "local-value"
  122. - notExists:
  123. path: spec.template.metadata.annotations.globalAnnotation
  124. - it: should use global podAnnotations when local podAnnotations not set (webhook)
  125. template: webhook-deployment.yaml
  126. set:
  127. global.podAnnotations:
  128. globalAnnotation: "global-value"
  129. environment: "production"
  130. asserts:
  131. - equal:
  132. path: spec.template.metadata.annotations.globalAnnotation
  133. value: "global-value"
  134. - equal:
  135. path: spec.template.metadata.annotations.environment
  136. value: "production"
  137. - it: should use local podAnnotations over global podAnnotations (webhook)
  138. template: webhook-deployment.yaml
  139. set:
  140. global.podAnnotations:
  141. globalAnnotation: "global-value"
  142. webhook.podAnnotations:
  143. localAnnotation: "local-value"
  144. asserts:
  145. - equal:
  146. path: spec.template.metadata.annotations.localAnnotation
  147. value: "local-value"
  148. - notExists:
  149. path: spec.template.metadata.annotations.globalAnnotation
  150. - it: should use global podAnnotations when local podAnnotations not set (cert-controller)
  151. template: cert-controller-deployment.yaml
  152. set:
  153. global.podAnnotations:
  154. globalAnnotation: "global-value"
  155. environment: "production"
  156. asserts:
  157. - equal:
  158. path: spec.template.metadata.annotations.globalAnnotation
  159. value: "global-value"
  160. - equal:
  161. path: spec.template.metadata.annotations.environment
  162. value: "production"
  163. - it: should use local podAnnotations over global podAnnotations (cert-controller)
  164. template: cert-controller-deployment.yaml
  165. set:
  166. global.podAnnotations:
  167. globalAnnotation: "global-value"
  168. certController.podAnnotations:
  169. localAnnotation: "local-value"
  170. asserts:
  171. - equal:
  172. path: spec.template.metadata.annotations.localAnnotation
  173. value: "local-value"
  174. - notExists:
  175. path: spec.template.metadata.annotations.globalAnnotation
  176. # Test global.imagePullSecrets
  177. - it: should use global imagePullSecrets when local imagePullSecrets not set (controller)
  178. template: deployment.yaml
  179. set:
  180. global.imagePullSecrets:
  181. - name: global-registry-secret
  182. - name: another-global-secret
  183. imagePullSecrets: []
  184. asserts:
  185. - equal:
  186. path: spec.template.spec.imagePullSecrets[0].name
  187. value: global-registry-secret
  188. - equal:
  189. path: spec.template.spec.imagePullSecrets[1].name
  190. value: another-global-secret
  191. - it: should use local imagePullSecrets over global imagePullSecrets (controller)
  192. template: deployment.yaml
  193. set:
  194. global.imagePullSecrets:
  195. - name: global-registry-secret
  196. imagePullSecrets:
  197. - name: local-registry-secret
  198. asserts:
  199. - equal:
  200. path: spec.template.spec.imagePullSecrets[0].name
  201. value: local-registry-secret
  202. - lengthEqual:
  203. path: spec.template.spec.imagePullSecrets
  204. count: 1
  205. - it: should use global imagePullSecrets when local imagePullSecrets not set (webhook)
  206. template: webhook-deployment.yaml
  207. set:
  208. global.imagePullSecrets:
  209. - name: global-registry-secret
  210. - name: another-global-secret
  211. webhook.imagePullSecrets: []
  212. asserts:
  213. - equal:
  214. path: spec.template.spec.imagePullSecrets[0].name
  215. value: global-registry-secret
  216. - equal:
  217. path: spec.template.spec.imagePullSecrets[1].name
  218. value: another-global-secret
  219. - it: should use local imagePullSecrets over global imagePullSecrets (webhook)
  220. template: webhook-deployment.yaml
  221. set:
  222. global.imagePullSecrets:
  223. - name: global-registry-secret
  224. webhook.imagePullSecrets:
  225. - name: local-registry-secret
  226. asserts:
  227. - equal:
  228. path: spec.template.spec.imagePullSecrets[0].name
  229. value: local-registry-secret
  230. - lengthEqual:
  231. path: spec.template.spec.imagePullSecrets
  232. count: 1
  233. - it: should use global imagePullSecrets when local imagePullSecrets not set (cert-controller)
  234. template: cert-controller-deployment.yaml
  235. set:
  236. global.imagePullSecrets:
  237. - name: global-registry-secret
  238. - name: another-global-secret
  239. certController.imagePullSecrets: []
  240. asserts:
  241. - equal:
  242. path: spec.template.spec.imagePullSecrets[0].name
  243. value: global-registry-secret
  244. - equal:
  245. path: spec.template.spec.imagePullSecrets[1].name
  246. value: another-global-secret
  247. - it: should use local imagePullSecrets over global imagePullSecrets (cert-controller)
  248. template: cert-controller-deployment.yaml
  249. set:
  250. global.imagePullSecrets:
  251. - name: global-registry-secret
  252. certController.imagePullSecrets:
  253. - name: local-registry-secret
  254. asserts:
  255. - equal:
  256. path: spec.template.spec.imagePullSecrets[0].name
  257. value: local-registry-secret
  258. - lengthEqual:
  259. path: spec.template.spec.imagePullSecrets
  260. count: 1
  261. # Test global.repository
  262. - it: should use global repository when set (controller)
  263. template: deployment.yaml
  264. set:
  265. global.repository: "my-registry.io/custom/external-secrets"
  266. asserts:
  267. - matchRegex:
  268. path: spec.template.spec.containers[0].image
  269. pattern: ^my-registry\.io/custom/external-secrets:.*
  270. - it: should use local repository when global repository not set (controller)
  271. template: deployment.yaml
  272. set:
  273. global.repository: ""
  274. image.repository: "ghcr.io/external-secrets/external-secrets"
  275. asserts:
  276. - matchRegex:
  277. path: spec.template.spec.containers[0].image
  278. pattern: ^ghcr\.io/external-secrets/external-secrets:.*
  279. - it: should use global repository when set (webhook)
  280. template: webhook-deployment.yaml
  281. set:
  282. global.repository: "my-registry.io/custom/external-secrets"
  283. asserts:
  284. - matchRegex:
  285. path: spec.template.spec.containers[0].image
  286. pattern: ^my-registry\.io/custom/external-secrets:.*
  287. - it: should use local repository when global repository not set (webhook)
  288. template: webhook-deployment.yaml
  289. set:
  290. global.repository: ""
  291. webhook.image.repository: "ghcr.io/external-secrets/external-secrets"
  292. asserts:
  293. - matchRegex:
  294. path: spec.template.spec.containers[0].image
  295. pattern: ^ghcr\.io/external-secrets/external-secrets:.*
  296. - it: should use global repository when set (cert-controller)
  297. template: cert-controller-deployment.yaml
  298. set:
  299. global.repository: "my-registry.io/custom/external-secrets"
  300. asserts:
  301. - matchRegex:
  302. path: spec.template.spec.containers[0].image
  303. pattern: ^my-registry\.io/custom/external-secrets:.*
  304. - it: should use local repository when global repository not set (cert-controller)
  305. template: cert-controller-deployment.yaml
  306. set:
  307. global.repository: ""
  308. certController.image.repository: "ghcr.io/external-secrets/external-secrets"
  309. asserts:
  310. - matchRegex:
  311. path: spec.template.spec.containers[0].image
  312. pattern: ^ghcr\.io/external-secrets/external-secrets:.*
  313. # Combined test - all global values set
  314. - it: should apply all global values when local values not set (controller)
  315. template: deployment.yaml
  316. set:
  317. global.repository: "my-registry.io/custom/external-secrets"
  318. global.imagePullSecrets:
  319. - name: global-secret
  320. global.podLabels:
  321. globalLabel: "global-value"
  322. global.podAnnotations:
  323. globalAnnotation: "global-value"
  324. asserts:
  325. - matchRegex:
  326. path: spec.template.spec.containers[0].image
  327. pattern: ^my-registry\.io/custom/external-secrets:.*
  328. - equal:
  329. path: spec.template.spec.imagePullSecrets[0].name
  330. value: global-secret
  331. - equal:
  332. path: spec.template.metadata.labels.globalLabel
  333. value: "global-value"
  334. - equal:
  335. path: spec.template.metadata.annotations.globalAnnotation
  336. value: "global-value"
  337. # No values set - should use only default helm labels
  338. - it: should have only default helm labels when no custom values are set (controller)
  339. template: deployment.yaml
  340. set:
  341. global.podLabels: {}
  342. global.podAnnotations: {}
  343. global.imagePullSecrets: []
  344. podLabels: {}
  345. podAnnotations: {}
  346. imagePullSecrets: []
  347. asserts:
  348. - exists:
  349. path: spec.template.metadata.labels
  350. - notExists:
  351. path: spec.template.spec.imagePullSecrets