metadata_test.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. suite: job metadata test
  2. templates:
  3. - common.yaml
  4. chart:
  5. appVersion: &appVer v9.9.9
  6. tests:
  7. - it: should pass with job 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: Job
  25. labels:
  26. label1: "{{ .Values.label1 }}"
  27. label2: label2
  28. annotations:
  29. annotation1: "{{ .Values.annotation1 }}"
  30. annotation2: annotation2
  31. podSpec:
  32. restartPolicy: Never
  33. labels:
  34. pod-label1: pod-label1
  35. pod-label2: "{{ .Values.label2 }}"
  36. annotations:
  37. pod-annotation1: pod-annotation1
  38. pod-annotation2: "{{ .Values.annotation2 }}"
  39. asserts:
  40. - documentIndex: &jobDoc 0
  41. isKind:
  42. of: Job
  43. - documentIndex: *jobDoc
  44. equal:
  45. path: metadata.annotations
  46. value:
  47. annotation1: annotation1
  48. annotation2: annotation2
  49. g_annotation1: global_annotation1
  50. g_annotation2: global_annotation2
  51. - documentIndex: *jobDoc
  52. equal:
  53. path: metadata.labels
  54. value:
  55. app: common-test-1.0.0
  56. release: RELEASE-NAME
  57. helm-revision: "0"
  58. helm.sh/chart: common-test-1.0.0
  59. app.kubernetes.io/managed-by: Helm
  60. app.kubernetes.io/version: *appVer
  61. g_label1: global_label1
  62. g_label2: global_label2
  63. label1: label1
  64. label2: label2
  65. - documentIndex: *jobDoc
  66. equal:
  67. path: spec.template.metadata.labels
  68. value:
  69. pod.name: workload-name
  70. app: common-test-1.0.0
  71. release: RELEASE-NAME
  72. app.kubernetes.io/instance: RELEASE-NAME
  73. app.kubernetes.io/managed-by: Helm
  74. app.kubernetes.io/name: common-test
  75. app.kubernetes.io/version: v9.9.9
  76. helm-revision: "0"
  77. helm.sh/chart: common-test-1.0.0
  78. g_label1: global_label1
  79. g_label2: global_label2
  80. pod-label1: pod-label1
  81. pod-label2: global_label2
  82. - documentIndex: *jobDoc
  83. matchRegex:
  84. path: spec.template.metadata.annotations.rollme
  85. pattern: '^[0-9a-zA-Z]{5}$'