metadata_test.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. suite: service metadata test
  2. templates:
  3. - common.yaml
  4. chart:
  5. appVersion: &appVer v9.9.9
  6. tests:
  7. - it: should pass with service 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. service:
  21. my-service1:
  22. enabled: true
  23. primary: true
  24. labels:
  25. label1: "{{ .Values.label1 }}"
  26. label2: label2
  27. annotations:
  28. annotation1: "{{ .Values.annotation1 }}"
  29. annotation2: annotation2
  30. ports:
  31. port-name:
  32. enabled: true
  33. primary: true
  34. port: 12345
  35. my-service2:
  36. enabled: true
  37. primary: false
  38. ports:
  39. port-name:
  40. enabled: true
  41. primary: true
  42. port: 1234
  43. workload:
  44. my-workload:
  45. enabled: true
  46. primary: true
  47. type: Deployment
  48. podSpec: {}
  49. asserts:
  50. - documentIndex: &serviceDoc 1
  51. isKind:
  52. of: Service
  53. - documentIndex: *serviceDoc
  54. equal:
  55. path: metadata.annotations
  56. value:
  57. annotation1: annotation1
  58. annotation2: annotation2
  59. g_annotation1: global_annotation1
  60. g_annotation2: global_annotation2
  61. - documentIndex: *serviceDoc
  62. equal:
  63. path: metadata.labels
  64. value:
  65. app: common-test-1.0.0
  66. release: RELEASE-NAME
  67. helm-revision: "0"
  68. helm.sh/chart: common-test-1.0.0
  69. app.kubernetes.io/managed-by: Helm
  70. app.kubernetes.io/version: *appVer
  71. app.kubernetes.io/instance: RELEASE-NAME
  72. app.kubernetes.io/name: common-test
  73. service.name: my-service1
  74. g_label1: global_label1
  75. g_label2: global_label2
  76. label1: label1
  77. label2: label2
  78. - documentIndex: &otherServiceDoc 2
  79. isKind:
  80. of: Service
  81. - documentIndex: *otherServiceDoc
  82. equal:
  83. path: metadata.labels
  84. value:
  85. service.name: my-service2
  86. app: common-test-1.0.0
  87. app.kubernetes.io/instance: RELEASE-NAME
  88. app.kubernetes.io/managed-by: Helm
  89. app.kubernetes.io/name: common-test
  90. app.kubernetes.io/version: *appVer
  91. g_label1: global_label1
  92. g_label2: global_label2
  93. helm-revision: "0"
  94. helm.sh/chart: common-test-1.0.0
  95. release: RELEASE-NAME
  96. - it: should pass with correct selector with targetSelector
  97. set:
  98. service:
  99. my-service1:
  100. enabled: true
  101. primary: true
  102. targetSelector: my-workload
  103. ports:
  104. port-name:
  105. enabled: true
  106. primary: true
  107. port: 12345
  108. workload:
  109. my-workload:
  110. enabled: true
  111. primary: true
  112. type: Deployment
  113. podSpec: {}
  114. asserts:
  115. - documentIndex: *serviceDoc
  116. isKind:
  117. of: Service
  118. - documentIndex: *serviceDoc
  119. equal:
  120. path: spec.selector
  121. value:
  122. pod.name: my-workload
  123. app.kubernetes.io/name: common-test
  124. app.kubernetes.io/instance: RELEASE-NAME
  125. - it: should pass with correct selector without targetSelector
  126. set:
  127. service:
  128. my-service1:
  129. enabled: true
  130. primary: true
  131. ports:
  132. port-name:
  133. enabled: true
  134. primary: true
  135. port: 12345
  136. workload:
  137. my-workload:
  138. enabled: true
  139. primary: true
  140. type: Deployment
  141. podSpec: {}
  142. my-workload2:
  143. enabled: true
  144. type: Deployment
  145. podSpec: {}
  146. asserts:
  147. - documentIndex: &serviceDoc 2
  148. isKind:
  149. of: Service
  150. - documentIndex: *serviceDoc
  151. equal:
  152. path: spec.selector
  153. value:
  154. pod.name: my-workload
  155. app.kubernetes.io/name: common-test
  156. app.kubernetes.io/instance: RELEASE-NAME