image_test.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. suite: container image test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should generate correct image
  6. set:
  7. imageDictToUse: image
  8. image: &image
  9. repository: nginx
  10. tag: "1.19.0"
  11. pullPolicy: IfNotPresent
  12. imageGPU:
  13. repository: some-gpu-image
  14. tag: "5.20"
  15. pullPolicy: Always
  16. workload:
  17. workload-name:
  18. enabled: true
  19. primary: true
  20. type: Deployment
  21. podSpec:
  22. containers:
  23. container-name1:
  24. enabled: true
  25. primary: true
  26. imageSelector: "{{ .Values.imageDictToUse }}"
  27. probes: &probes
  28. liveness:
  29. enabled: false
  30. readiness:
  31. enabled: false
  32. startup:
  33. enabled: false
  34. container-name2:
  35. enabled: true
  36. primary: false
  37. imageSelector: imageGPU
  38. probes: *probes
  39. asserts:
  40. - documentIndex: &deploymentDoc 0
  41. isKind:
  42. of: Deployment
  43. - documentIndex: *deploymentDoc
  44. isAPIVersion:
  45. of: apps/v1
  46. - documentIndex: *deploymentDoc
  47. isSubset:
  48. path: spec.template.spec.containers[0]
  49. content:
  50. image: nginx:1.19.0
  51. imagePullPolicy: IfNotPresent
  52. - documentIndex: *deploymentDoc
  53. isSubset:
  54. path: spec.template.spec.containers[1]
  55. content:
  56. image: some-gpu-image:5.20
  57. imagePullPolicy: Always
  58. # Failures
  59. - it: should fail with imageSelector trying to access non-existent image
  60. set:
  61. image: *image
  62. workload:
  63. workload-name:
  64. enabled: true
  65. primary: true
  66. type: Deployment
  67. podSpec:
  68. containers:
  69. container-name1:
  70. enabled: true
  71. primary: true
  72. imageSelector: image-dict-that-does-not-exist
  73. asserts:
  74. - failedTemplate:
  75. errorMessage: Container - Expected <.Values.image-dict-that-does-not-exist> to exist
  76. - it: should fail with empty repository in selected image
  77. set:
  78. image:
  79. repository: ""
  80. tag: 1.19.0
  81. pullPolicy: IfNotPresent
  82. workload:
  83. workload-name:
  84. enabled: true
  85. primary: true
  86. type: Deployment
  87. podSpec:
  88. containers:
  89. container-name1:
  90. enabled: true
  91. primary: true
  92. imageSelector: image
  93. asserts:
  94. - failedTemplate:
  95. errorMessage: Container - Expected non-empty <.Values.image.repository>
  96. - it: should fail with empty tag in selected image
  97. set:
  98. image:
  99. repository: nginx
  100. tag: ""
  101. pullPolicy: IfNotPresent
  102. workload:
  103. workload-name:
  104. enabled: true
  105. primary: true
  106. type: Deployment
  107. podSpec:
  108. containers:
  109. container-name1:
  110. enabled: true
  111. primary: true
  112. imageSelector: image
  113. asserts:
  114. - failedTemplate:
  115. errorMessage: Container - Expected non-empty <.Values.image.tag>
  116. - it: should fail with invalid pullPolicy selected image
  117. set:
  118. image:
  119. repository: nginx
  120. tag: "1.19.0"
  121. pullPolicy: invalid
  122. workload:
  123. workload-name:
  124. enabled: true
  125. primary: true
  126. type: Deployment
  127. podSpec:
  128. containers:
  129. container-name1:
  130. enabled: true
  131. primary: true
  132. imageSelector: image
  133. asserts:
  134. - failedTemplate:
  135. errorMessage: Container - Expected <.Values.image.pullPolicy> to be one of [IfNotPresent, Always, Never], but got [invalid]
  136. - it: should fail with tag not string on selected image
  137. set:
  138. image:
  139. repository: nginx
  140. tag: 1.19
  141. pullPolicy: invalid
  142. workload:
  143. workload-name:
  144. enabled: true
  145. primary: true
  146. type: Deployment
  147. podSpec:
  148. containers:
  149. container-name1:
  150. enabled: true
  151. primary: true
  152. imageSelector: image
  153. asserts:
  154. - failedTemplate:
  155. errorMessage: Container - Expected <.Values.image.tag> to be string, but got [float64]