metadata_test.yaml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. suite: cronjob metadata test
  2. templates:
  3. - common.yaml
  4. chart:
  5. appVersion: &appVer v9.9.9
  6. tests:
  7. - it: should pass with cronjob created with labels and annotations
  8. set:
  9. label1: label1
  10. label2: global_label2
  11. annotation1: annotation1
  12. annotation2: global_annotation2
  13. global:
  14. labels:
  15. g_label1: global_label1
  16. g_label2: "{{ .Values.label2 }}"
  17. annotations:
  18. g_annotation1: global_annotation1
  19. g_annotation2: "{{ .Values.annotation2 }}"
  20. workload:
  21. workload-name:
  22. enabled: true
  23. primary: true
  24. type: CronJob
  25. schedule: "*/1 * * * *"
  26. labels:
  27. label1: "{{ .Values.label1 }}"
  28. label2: label2
  29. annotations:
  30. annotation1: "{{ .Values.annotation1 }}"
  31. annotation2: annotation2
  32. podSpec:
  33. restartPolicy: Never
  34. labels:
  35. pod-label1: pod-label1
  36. pod-label2: "{{ .Values.label2 }}"
  37. annotations:
  38. pod-annotation1: pod-annotation1
  39. pod-annotation2: "{{ .Values.annotation2 }}"
  40. asserts:
  41. - documentIndex: &cronJobDoc 0
  42. isKind:
  43. of: CronJob
  44. - documentIndex: *cronJobDoc
  45. equal:
  46. path: metadata.annotations
  47. value:
  48. annotation1: annotation1
  49. annotation2: annotation2
  50. g_annotation1: global_annotation1
  51. g_annotation2: global_annotation2
  52. - documentIndex: *cronJobDoc
  53. equal:
  54. path: metadata.labels
  55. value:
  56. app: common-test-1.0.0
  57. release: RELEASE-NAME
  58. helm-revision: "0"
  59. helm.sh/chart: common-test-1.0.0
  60. app.kubernetes.io/managed-by: Helm
  61. app.kubernetes.io/version: *appVer
  62. g_label1: global_label1
  63. g_label2: global_label2
  64. label1: label1
  65. label2: label2
  66. - documentIndex: *cronJobDoc
  67. equal:
  68. path: spec.jobTemplate.spec.template.metadata.labels
  69. value:
  70. pod.name: workload-name
  71. app: common-test-1.0.0
  72. release: RELEASE-NAME
  73. app.kubernetes.io/instance: RELEASE-NAME
  74. app.kubernetes.io/managed-by: Helm
  75. app.kubernetes.io/name: common-test
  76. app.kubernetes.io/version: v9.9.9
  77. helm-revision: "0"
  78. helm.sh/chart: common-test-1.0.0
  79. g_label1: global_label1
  80. g_label2: global_label2
  81. pod-label1: pod-label1
  82. pod-label2: global_label2
  83. - documentIndex: *cronJobDoc
  84. matchRegex:
  85. path: spec.jobTemplate.spec.template.metadata.annotations.rollme
  86. pattern: '^[0-9a-zA-Z]{5}$'