metadata_test.yaml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/name: common-test
  61. app.kubernetes.io/instance: RELEASE-NAME
  62. app.kubernetes.io/managed-by: Helm
  63. app.kubernetes.io/version: *appVer
  64. g_label1: global_label1
  65. g_label2: global_label2
  66. label1: label1
  67. label2: label2
  68. - documentIndex: *cronJobDoc
  69. equal:
  70. path: spec.jobTemplate.spec.template.metadata.labels
  71. value:
  72. pod.name: workload-name
  73. app: common-test-1.0.0
  74. release: RELEASE-NAME
  75. app.kubernetes.io/instance: RELEASE-NAME
  76. app.kubernetes.io/managed-by: Helm
  77. app.kubernetes.io/name: common-test
  78. app.kubernetes.io/version: v9.9.9
  79. helm-revision: "0"
  80. helm.sh/chart: common-test-1.0.0
  81. g_label1: global_label1
  82. g_label2: global_label2
  83. pod-label1: pod-label1
  84. pod-label2: global_label2
  85. - documentIndex: *cronJobDoc
  86. matchRegex:
  87. path: spec.jobTemplate.spec.template.metadata.annotations.rollme
  88. pattern: '^[0-9a-zA-Z]{5}$'