volume_configmap_test.yaml 5.8 KB

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