volume_configmap_test.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. suite: pod configmap volume test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should pass with configmap volume
  6. set:
  7. some_object: some-object-name
  8. some_mode: "0777"
  9. workload:
  10. workload-name1:
  11. enabled: true
  12. primary: true
  13. type: Deployment
  14. podSpec: {}
  15. persistence:
  16. conf-vol:
  17. enabled: true
  18. type: configmap
  19. objectName: "{{ .Values.some_object }}"
  20. defaultMode: "{{ .Values.some_mode }}"
  21. asserts:
  22. - documentIndex: &deploymentDoc 0
  23. isKind:
  24. of: Deployment
  25. - documentIndex: *deploymentDoc
  26. contains:
  27. path: spec.template.spec.volumes
  28. content:
  29. name: conf-vol
  30. configMap:
  31. name: release-name-common-test-some-object-name
  32. defaultMode: 0777
  33. - it: should pass with configmap volume with items
  34. set:
  35. some_object: some-object-name
  36. some_mode: "0777"
  37. some_key: some-key
  38. some_path: some-path
  39. workload:
  40. workload-name1:
  41. enabled: true
  42. primary: true
  43. type: Deployment
  44. podSpec: {}
  45. persistence:
  46. conf-vol:
  47. enabled: true
  48. type: configmap
  49. objectName: "{{ .Values.some_object }}"
  50. defaultMode: "{{ .Values.some_mode }}"
  51. items:
  52. - key: "{{ .Values.some_key }}"
  53. path: "{{ .Values.some_path }}"
  54. - key: some-other-key
  55. path: some-other-path
  56. asserts:
  57. - documentIndex: *deploymentDoc
  58. isKind:
  59. of: Deployment
  60. - documentIndex: *deploymentDoc
  61. contains:
  62. path: spec.template.spec.volumes
  63. content:
  64. name: conf-vol
  65. configMap:
  66. name: release-name-common-test-some-object-name
  67. defaultMode: 0777
  68. items:
  69. - key: some-key
  70. path: some-path
  71. - key: some-other-key
  72. path: some-other-path
  73. - it: should pass with configmap volume without expanding object name
  74. set:
  75. some_object: some-object-name
  76. workload:
  77. workload-name1:
  78. enabled: true
  79. primary: true
  80. type: Deployment
  81. podSpec: {}
  82. persistence:
  83. conf-vol:
  84. enabled: true
  85. type: configmap
  86. objectName: "{{ .Values.some_object }}"
  87. expandObjectName: false
  88. asserts:
  89. - documentIndex: *deploymentDoc
  90. isKind:
  91. of: Deployment
  92. - documentIndex: *deploymentDoc
  93. contains:
  94. path: spec.template.spec.volumes
  95. content:
  96. name: conf-vol
  97. configMap:
  98. name: some-object-name
  99. # Failures
  100. - it: should fail without objectName in configmap
  101. set:
  102. workload:
  103. some-workload:
  104. enabled: true
  105. primary: true
  106. type: Deployment
  107. podSpec: {}
  108. persistence:
  109. volume1:
  110. enabled: true
  111. type: configmap
  112. asserts:
  113. - failedTemplate:
  114. errorMessage: Persistence - Expected non-empty <objectName> on <configmap> type
  115. - it: should fail with empty objectName in configmap
  116. set:
  117. workload:
  118. some-workload:
  119. enabled: true
  120. primary: true
  121. type: Deployment
  122. podSpec: {}
  123. persistence:
  124. volume1:
  125. enabled: true
  126. type: configmap
  127. objectName: ""
  128. asserts:
  129. - failedTemplate:
  130. errorMessage: Persistence - Expected non-empty <objectName> on <configmap> type
  131. - it: should fail with defaultMode not a string in configmap
  132. set:
  133. workload:
  134. some-workload:
  135. enabled: true
  136. primary: true
  137. type: Deployment
  138. podSpec: {}
  139. persistence:
  140. volume1:
  141. enabled: true
  142. type: configmap
  143. objectName: some-object-name
  144. defaultMode: 1234
  145. asserts:
  146. - failedTemplate:
  147. errorMessage: Persistence - Expected <defaultMode> to be [string], but got [float64]
  148. - it: should fail with defaultMode not in format of "0000"-"0777" in configmap
  149. set:
  150. workload:
  151. some-workload:
  152. enabled: true
  153. primary: true
  154. type: Deployment
  155. podSpec: {}
  156. persistence:
  157. volume1:
  158. enabled: true
  159. type: configmap
  160. objectName: some-object-name
  161. defaultMode: "123"
  162. asserts:
  163. - failedTemplate:
  164. errorMessage: Persistence - Expected <defaultMode> to have be in format of ["0777"], but got ["123"]
  165. - it: should fail without key in items in configmap
  166. set:
  167. workload:
  168. some-workload:
  169. enabled: true
  170. primary: true
  171. type: Deployment
  172. podSpec: {}
  173. persistence:
  174. volume1:
  175. enabled: true
  176. type: configmap
  177. objectName: some-object-name
  178. items:
  179. - key: ""
  180. path: some-path
  181. asserts:
  182. - failedTemplate:
  183. errorMessage: Persistence - Expected non-empty <items.key>
  184. - it: should fail without path in items in configmap
  185. set:
  186. workload:
  187. some-workload:
  188. enabled: true
  189. primary: true
  190. type: Deployment
  191. podSpec: {}
  192. persistence:
  193. volume1:
  194. enabled: true
  195. type: configmap
  196. objectName: some-object-name
  197. items:
  198. - key: some-key
  199. path: ""
  200. asserts:
  201. - failedTemplate:
  202. errorMessage: Persistence - Expected non-empty <items.path>