termination_test.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. suite: container termination test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should pass with termination set
  6. set:
  7. some_path: /dev/termination-log
  8. some_policy: File
  9. image: &image
  10. repository: nginx
  11. tag: 1.19.0
  12. pullPolicy: IfNotPresent
  13. workload:
  14. workload-name:
  15. enabled: true
  16. primary: true
  17. type: Deployment
  18. podSpec:
  19. containers:
  20. container-name1:
  21. enabled: true
  22. primary: true
  23. imageSelector: image
  24. probes: &probes
  25. liveness:
  26. enabled: false
  27. readiness:
  28. enabled: false
  29. startup:
  30. enabled: false
  31. termination:
  32. messagePath: "{{ .Values.some_path }}"
  33. messagePolicy: "{{ .Values.some_policy }}"
  34. asserts:
  35. - documentIndex: &deploymentDoc 0
  36. isKind:
  37. of: Deployment
  38. - documentIndex: *deploymentDoc
  39. isAPIVersion:
  40. of: apps/v1
  41. - documentIndex: *deploymentDoc
  42. isSubset:
  43. path: spec.template.spec.containers[0]
  44. content:
  45. terminationMessagePath: /dev/termination-log
  46. terminationMessagePolicy: File
  47. - it: should pass with termination path only
  48. set:
  49. image: &image
  50. repository: nginx
  51. tag: 1.19.0
  52. pullPolicy: IfNotPresent
  53. workload:
  54. workload-name:
  55. enabled: true
  56. primary: true
  57. type: Deployment
  58. podSpec:
  59. containers:
  60. container-name1:
  61. enabled: true
  62. primary: true
  63. imageSelector: image
  64. probes: *probes
  65. termination:
  66. messagePath: /some/path
  67. asserts:
  68. - documentIndex: &deploymentDoc 0
  69. isKind:
  70. of: Deployment
  71. - documentIndex: *deploymentDoc
  72. isAPIVersion:
  73. of: apps/v1
  74. - documentIndex: *deploymentDoc
  75. isSubset:
  76. path: spec.template.spec.containers[0]
  77. content:
  78. terminationMessagePath: /some/path
  79. - documentIndex: *deploymentDoc
  80. isNull:
  81. path: spec.template.spec.containers[0].terminationMessagePolicy
  82. - it: should pass with termination policy only
  83. set:
  84. image: &image
  85. repository: nginx
  86. tag: 1.19.0
  87. pullPolicy: IfNotPresent
  88. workload:
  89. workload-name:
  90. enabled: true
  91. primary: true
  92. type: Deployment
  93. podSpec:
  94. containers:
  95. container-name1:
  96. enabled: true
  97. primary: true
  98. imageSelector: image
  99. probes: *probes
  100. termination:
  101. messagePolicy: File
  102. asserts:
  103. - documentIndex: &deploymentDoc 0
  104. isKind:
  105. of: Deployment
  106. - documentIndex: *deploymentDoc
  107. isAPIVersion:
  108. of: apps/v1
  109. - documentIndex: *deploymentDoc
  110. isSubset:
  111. path: spec.template.spec.containers[0]
  112. content:
  113. terminationMessagePolicy: File
  114. - documentIndex: *deploymentDoc
  115. isNull:
  116. path: spec.template.spec.containers[0].terminationMessagePath
  117. # Failures
  118. - it: should fail with invalid policy
  119. set:
  120. image: &image
  121. repository: nginx
  122. tag: 1.19.0
  123. pullPolicy: IfNotPresent
  124. workload:
  125. workload-name:
  126. enabled: true
  127. primary: true
  128. type: Deployment
  129. podSpec:
  130. containers:
  131. container-name1:
  132. enabled: true
  133. primary: true
  134. imageSelector: image
  135. probes: *probes
  136. termination:
  137. messagePolicy: SomeInvalidPolicy
  138. asserts:
  139. - failedTemplate:
  140. errorMessage: Container - Expected <termination.messagePolicy> to be one of [File, FallbackToLogsOnError], but got [SomeInvalidPolicy]