volumeMounts_test.yaml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. suite: container volumeMounts test
  2. templates:
  3. - common.yaml
  4. tests:
  5. - it: should pass with shared volume on multiple workloads and containers with targetSelectAll
  6. set:
  7. some_path: /some/path
  8. image: &image
  9. repository: nginx
  10. tag: 1.19.0
  11. pullPolicy: IfNotPresent
  12. workload:
  13. workload-name:
  14. enabled: true
  15. primary: true
  16. type: Deployment
  17. podSpec:
  18. containers:
  19. container-name1:
  20. enabled: true
  21. primary: true
  22. imageSelector: image
  23. probes: &probes
  24. liveness:
  25. enabled: false
  26. readiness:
  27. enabled: false
  28. startup:
  29. enabled: false
  30. container-name2:
  31. enabled: true
  32. primary: false
  33. imageSelector: image
  34. probes: *probes
  35. workload-name2:
  36. enabled: true
  37. primary: false
  38. type: Job
  39. podSpec:
  40. restartPolicy: Never
  41. containers:
  42. container-name1:
  43. enabled: true
  44. primary: true
  45. imageSelector: image
  46. probes: *probes
  47. container-name2:
  48. enabled: true
  49. primary: false
  50. imageSelector: image
  51. probes: *probes
  52. persistence:
  53. shared-vol:
  54. enabled: true
  55. type: emptyDir
  56. mountPath: "{{ .Values.some_path }}"
  57. targetSelectAll: true
  58. asserts:
  59. - documentIndex: &deploymentDoc 0
  60. isKind:
  61. of: Deployment
  62. - documentIndex: *deploymentDoc
  63. isAPIVersion:
  64. of: apps/v1
  65. - documentIndex: *deploymentDoc
  66. contains:
  67. path: spec.template.spec.containers[0].volumeMounts
  68. content:
  69. name: shared-vol
  70. mountPath: /some/path
  71. readOnly: false
  72. - documentIndex: *deploymentDoc
  73. contains:
  74. path: spec.template.spec.containers[1].volumeMounts
  75. content:
  76. name: shared-vol
  77. mountPath: /some/path
  78. readOnly: false
  79. - documentIndex: &jobDoc 1
  80. isKind:
  81. of: Job
  82. - documentIndex: *jobDoc
  83. isAPIVersion:
  84. of: batch/v1
  85. - documentIndex: *jobDoc
  86. contains:
  87. path: spec.template.spec.containers[0].volumeMounts
  88. content:
  89. name: shared-vol
  90. mountPath: /some/path
  91. readOnly: false
  92. - documentIndex: *jobDoc
  93. contains:
  94. path: spec.template.spec.containers[1].volumeMounts
  95. content:
  96. name: shared-vol
  97. mountPath: /some/path
  98. readOnly: false
  99. - it: should pass with volume on primary workload and container
  100. set:
  101. image: *image
  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. probes: *probes
  114. container-name2:
  115. enabled: true
  116. primary: false
  117. imageSelector: image
  118. probes: *probes
  119. workload-name2:
  120. enabled: true
  121. primary: false
  122. type: Job
  123. podSpec:
  124. restartPolicy: Never
  125. containers:
  126. container-name1:
  127. enabled: true
  128. primary: true
  129. imageSelector: image
  130. probes: *probes
  131. container-name2:
  132. enabled: true
  133. primary: false
  134. imageSelector: image
  135. probes: *probes
  136. persistence:
  137. some-vol:
  138. enabled: true
  139. type: emptyDir
  140. mountPath: /some/path
  141. readOnly: true
  142. asserts:
  143. - documentIndex: &deploymentDoc 0
  144. isKind:
  145. of: Deployment
  146. - documentIndex: *deploymentDoc
  147. isAPIVersion:
  148. of: apps/v1
  149. - documentIndex: *deploymentDoc
  150. contains:
  151. path: spec.template.spec.containers[0].volumeMounts
  152. content:
  153. name: some-vol
  154. mountPath: /some/path
  155. readOnly: true
  156. - documentIndex: *deploymentDoc
  157. isNull:
  158. path: spec.template.spec.containers[1].volumeMounts
  159. - documentIndex: &jobDoc 1
  160. isKind:
  161. of: Job
  162. - documentIndex: *jobDoc
  163. isAPIVersion:
  164. of: batch/v1
  165. - documentIndex: *jobDoc
  166. isNull:
  167. path: spec.template.spec.containers[0].volumeMounts
  168. - documentIndex: *jobDoc
  169. isNull:
  170. path: spec.template.spec.containers[1].volumeMounts
  171. - it: should pass with volume with selected pod and container
  172. set:
  173. image: *image
  174. workload:
  175. workload-name:
  176. enabled: true
  177. primary: true
  178. type: Deployment
  179. podSpec:
  180. containers:
  181. container-name1:
  182. enabled: true
  183. primary: true
  184. imageSelector: image
  185. probes: *probes
  186. container-name2:
  187. enabled: true
  188. primary: false
  189. imageSelector: image
  190. probes: *probes
  191. workload-name2:
  192. enabled: true
  193. primary: false
  194. type: Job
  195. podSpec:
  196. restartPolicy: Never
  197. containers:
  198. container-name1:
  199. enabled: true
  200. primary: true
  201. imageSelector: image
  202. probes: *probes
  203. container-name2:
  204. enabled: true
  205. primary: false
  206. imageSelector: image
  207. probes: *probes
  208. persistence:
  209. some-vol:
  210. enabled: true
  211. type: emptyDir
  212. mountPath: /some/path
  213. readOnly: true
  214. targetSelector:
  215. workload-name:
  216. container-name2: {}
  217. workload-name2:
  218. container-name1: {}
  219. asserts:
  220. - documentIndex: &deploymentDoc 0
  221. isKind:
  222. of: Deployment
  223. - documentIndex: *deploymentDoc
  224. isAPIVersion:
  225. of: apps/v1
  226. - documentIndex: *deploymentDoc
  227. isNull:
  228. path: spec.template.spec.containers[0].volumeMounts
  229. - documentIndex: *deploymentDoc
  230. contains:
  231. path: spec.template.spec.containers[1].volumeMounts
  232. content:
  233. name: some-vol
  234. mountPath: /some/path
  235. readOnly: true
  236. - documentIndex: &jobDoc 1
  237. isKind:
  238. of: Job
  239. - documentIndex: *jobDoc
  240. isAPIVersion:
  241. of: batch/v1
  242. - documentIndex: *jobDoc
  243. contains:
  244. path: spec.template.spec.containers[0].volumeMounts
  245. content:
  246. name: some-vol
  247. mountPath: /some/path
  248. readOnly: true
  249. - documentIndex: *jobDoc
  250. isNull:
  251. path: spec.template.spec.containers[1].volumeMounts
  252. - it: should pass with volume with selected pod and multiple containers
  253. set:
  254. image: *image
  255. workload:
  256. workload-name:
  257. enabled: true
  258. primary: true
  259. type: Deployment
  260. podSpec:
  261. containers:
  262. container-name1:
  263. enabled: true
  264. primary: true
  265. imageSelector: image
  266. probes: *probes
  267. container-name2:
  268. enabled: true
  269. primary: false
  270. imageSelector: image
  271. probes: *probes
  272. workload-name2:
  273. enabled: true
  274. primary: false
  275. type: Job
  276. podSpec:
  277. restartPolicy: Never
  278. containers:
  279. container-name1:
  280. enabled: true
  281. primary: true
  282. imageSelector: image
  283. probes: *probes
  284. container-name2:
  285. enabled: true
  286. primary: false
  287. imageSelector: image
  288. probes: *probes
  289. persistence:
  290. some-vol:
  291. enabled: true
  292. type: emptyDir
  293. mountPath: /some/path
  294. readOnly: true
  295. targetSelector:
  296. workload-name:
  297. container-name1: {}
  298. container-name2: {}
  299. asserts:
  300. - documentIndex: &deploymentDoc 0
  301. isKind:
  302. of: Deployment
  303. - documentIndex: *deploymentDoc
  304. isAPIVersion:
  305. of: apps/v1
  306. - documentIndex: *deploymentDoc
  307. contains:
  308. path: spec.template.spec.containers[0].volumeMounts
  309. content:
  310. name: some-vol
  311. mountPath: /some/path
  312. readOnly: true
  313. - documentIndex: *deploymentDoc
  314. contains:
  315. path: spec.template.spec.containers[1].volumeMounts
  316. content:
  317. name: some-vol
  318. mountPath: /some/path
  319. readOnly: true
  320. - documentIndex: &jobDoc 1
  321. isKind:
  322. of: Job
  323. - documentIndex: *jobDoc
  324. isAPIVersion:
  325. of: batch/v1
  326. - documentIndex: *jobDoc
  327. isNull:
  328. path: spec.template.spec.containers[0].volumeMounts
  329. - documentIndex: *jobDoc
  330. isNull:
  331. path: spec.template.spec.containers[1].volumeMounts
  332. - it: should pass with volume with selected pod and containers and specific values
  333. set:
  334. image: *image
  335. workload:
  336. workload-name:
  337. enabled: true
  338. primary: true
  339. type: Deployment
  340. podSpec:
  341. containers:
  342. container-name1:
  343. enabled: true
  344. primary: true
  345. imageSelector: image
  346. probes: *probes
  347. container-name2:
  348. enabled: true
  349. primary: false
  350. imageSelector: image
  351. probes: *probes
  352. workload-name2:
  353. enabled: true
  354. primary: false
  355. type: Job
  356. podSpec:
  357. restartPolicy: Never
  358. containers:
  359. container-name1:
  360. enabled: true
  361. primary: true
  362. imageSelector: image
  363. probes: *probes
  364. container-name2:
  365. enabled: true
  366. primary: false
  367. imageSelector: image
  368. probes: *probes
  369. persistence:
  370. some-vol:
  371. enabled: true
  372. type: emptyDir
  373. mountPath: /some/path
  374. readOnly: true
  375. targetSelector:
  376. workload-name:
  377. container-name1:
  378. mountPath: /some/other/path
  379. readOnly: false
  380. mountPropagation: None
  381. subPath: /some/sub/path
  382. container-name2: {}
  383. asserts:
  384. - documentIndex: &deploymentDoc 0
  385. isKind:
  386. of: Deployment
  387. - documentIndex: *deploymentDoc
  388. isAPIVersion:
  389. of: apps/v1
  390. - documentIndex: *deploymentDoc
  391. contains:
  392. path: spec.template.spec.containers[0].volumeMounts
  393. content:
  394. name: some-vol
  395. mountPath: /some/other/path
  396. readOnly: false
  397. mountPropagation: None
  398. subPath: /some/sub/path
  399. - documentIndex: *deploymentDoc
  400. contains:
  401. path: spec.template.spec.containers[1].volumeMounts
  402. content:
  403. name: some-vol
  404. mountPath: /some/path
  405. readOnly: true
  406. - documentIndex: &jobDoc 1
  407. isKind:
  408. of: Job
  409. - documentIndex: *jobDoc
  410. isAPIVersion:
  411. of: batch/v1
  412. - documentIndex: *jobDoc
  413. isNull:
  414. path: spec.template.spec.containers[0].volumeMounts
  415. - documentIndex: *jobDoc
  416. isNull:
  417. path: spec.template.spec.containers[1].volumeMounts
  418. - it: should pass with volume with selected pod and containers and specific values from tpl
  419. set:
  420. some_path: /some/other/path
  421. some_propagation: None
  422. some_sub_path: /some/sub/path
  423. image: *image
  424. workload:
  425. workload-name:
  426. enabled: true
  427. primary: true
  428. type: Deployment
  429. podSpec:
  430. containers:
  431. container-name1:
  432. enabled: true
  433. primary: true
  434. imageSelector: image
  435. probes: *probes
  436. container-name2:
  437. enabled: true
  438. primary: false
  439. imageSelector: image
  440. probes: *probes
  441. persistence:
  442. some-vol:
  443. enabled: true
  444. type: emptyDir
  445. mountPath: /some/path
  446. readOnly: true
  447. targetSelector:
  448. workload-name:
  449. container-name1:
  450. mountPath: "{{ .Values.some_path }}"
  451. readOnly: false
  452. mountPropagation: "{{ .Values.some_propagation }}"
  453. subPath: "{{ .Values.some_sub_path }}"
  454. container-name2: {}
  455. asserts:
  456. - documentIndex: &deploymentDoc 0
  457. isKind:
  458. of: Deployment
  459. - documentIndex: *deploymentDoc
  460. isAPIVersion:
  461. of: apps/v1
  462. - documentIndex: *deploymentDoc
  463. contains:
  464. path: spec.template.spec.containers[0].volumeMounts
  465. content:
  466. name: some-vol
  467. mountPath: /some/other/path
  468. readOnly: false
  469. mountPropagation: None
  470. subPath: /some/sub/path
  471. - documentIndex: *deploymentDoc
  472. contains:
  473. path: spec.template.spec.containers[1].volumeMounts
  474. content:
  475. name: some-vol
  476. mountPath: /some/path
  477. readOnly: true
  478. - it: should pass with cert mounted as volume with subPath
  479. set:
  480. image: *image
  481. ixCertificates:
  482. "1":
  483. certificate: some_cert
  484. key: some_key
  485. scaleCertificate:
  486. cert-name:
  487. enabled: false
  488. id: 1
  489. workload:
  490. workload-name:
  491. enabled: true
  492. primary: true
  493. type: Deployment
  494. podSpec:
  495. containers:
  496. container-name1:
  497. enabled: true
  498. primary: true
  499. imageSelector: image
  500. probes: *probes
  501. persistence:
  502. cert-vol:
  503. enabled: true
  504. type: secret
  505. objectName: cert-name
  506. readOnly: true
  507. targetSelector:
  508. workload-name:
  509. container-name1:
  510. mountPath: /some/path/cert.crt
  511. readOnly: true
  512. subPath: cert.crt
  513. asserts:
  514. - documentIndex: &deploymentDoc 0
  515. isKind:
  516. of: Deployment
  517. - documentIndex: *deploymentDoc
  518. isAPIVersion:
  519. of: apps/v1
  520. - documentIndex: *deploymentDoc
  521. contains:
  522. path: spec.template.spec.containers[0].volumeMounts
  523. content:
  524. name: cert-vol
  525. mountPath: /some/path/cert.crt
  526. readOnly: true
  527. subPath: cert.crt
  528. - it: should pass with cert mounted as volume with subPath
  529. set:
  530. image: *image
  531. ixCertificates:
  532. "1":
  533. certificate: some_cert
  534. key: some_key
  535. scaleCertificate:
  536. cert-name:
  537. enabled: false
  538. id: 1
  539. workload:
  540. workload-name:
  541. enabled: true
  542. primary: true
  543. type: Deployment
  544. podSpec:
  545. containers:
  546. container-name1:
  547. enabled: true
  548. primary: true
  549. imageSelector: image
  550. probes: *probes
  551. persistence:
  552. cert-vol:
  553. enabled: true
  554. type: secret
  555. objectName: cert-name
  556. readOnly: true
  557. items:
  558. - key: tls.crt
  559. path: cert.crt
  560. targetSelector:
  561. workload-name:
  562. container-name1:
  563. mountPath: /some/path
  564. readOnly: true
  565. asserts:
  566. - documentIndex: &deploymentDoc 0
  567. isKind:
  568. of: Deployment
  569. - documentIndex: *deploymentDoc
  570. isAPIVersion:
  571. of: apps/v1
  572. - documentIndex: *deploymentDoc
  573. contains:
  574. path: spec.template.spec.containers[0].volumeMounts
  575. content:
  576. name: cert-vol
  577. mountPath: /some/path
  578. readOnly: true
  579. # Failures
  580. - it: should fail with invalid mountPropagation
  581. set:
  582. image: *image
  583. workload:
  584. workload-name: &workload
  585. enabled: true
  586. primary: true
  587. type: Deployment
  588. podSpec:
  589. containers:
  590. container-name1:
  591. enabled: true
  592. primary: true
  593. imageSelector: image
  594. persistence:
  595. vol-name:
  596. enabled: true
  597. type: emptyDir
  598. mountPath: /some/path
  599. mountPropagation: HostToContainer
  600. targetSelector:
  601. workload-name:
  602. container-name1:
  603. mountPropagation: invalid
  604. asserts:
  605. - failedTemplate:
  606. errorMessage: Persistence - Expected <mountPropagation> to be one of [None, HostToContainer, Bidirectional], but got [invalid]
  607. - it: should fail with non-boolean readOnly
  608. set:
  609. image: *image
  610. workload:
  611. workload-name: *workload
  612. persistence:
  613. vol-name:
  614. enabled: true
  615. type: emptyDir
  616. mountPath: /some/path
  617. targetSelector:
  618. workload-name:
  619. container-name1:
  620. readOnly: invalid
  621. asserts:
  622. - failedTemplate:
  623. errorMessage: Persistence - Expected <readOnly> to be [boolean], but got [string]
  624. - it: should fail with empty readOnly
  625. set:
  626. image: *image
  627. workload:
  628. workload-name: *workload
  629. persistence:
  630. vol-name:
  631. enabled: true
  632. type: emptyDir
  633. mountPath: /some/path
  634. targetSelector:
  635. workload-name:
  636. container-name1:
  637. readOnly:
  638. asserts:
  639. - failedTemplate:
  640. errorMessage: Persistence - Expected <readOnly> to be [boolean], but got [invalid]
  641. - it: should fail with empty mountPath
  642. set:
  643. image: *image
  644. workload:
  645. workload-name: *workload
  646. persistence:
  647. vol-name:
  648. enabled: true
  649. type: emptyDir
  650. mountPath: ""
  651. targetSelector:
  652. workload-name:
  653. container-name1: {}
  654. asserts:
  655. - failedTemplate:
  656. errorMessage: Persistence - Expected non-empty <mountPath>
  657. - it: should fail with mountPath not starting with /
  658. set:
  659. image: *image
  660. workload:
  661. workload-name: *workload
  662. persistence:
  663. vol-name:
  664. enabled: true
  665. type: emptyDir
  666. targetSelector:
  667. workload-name:
  668. container-name1:
  669. mountPath: some/path
  670. asserts:
  671. - failedTemplate:
  672. errorMessage: Persistence - Expected <mountPath> to start with a forward slash [/]
  673. - it: should fail with non-dict targetSelect.workloadName
  674. set:
  675. image: *image
  676. workload:
  677. workload-name: *workload
  678. persistence:
  679. vol-name:
  680. enabled: true
  681. type: emptyDir
  682. targetSelector:
  683. workload-name: string
  684. asserts:
  685. - failedTemplate:
  686. errorMessage: Persistence - Expected <targetSelector.workload-name> to be a [dict], but got [string]
  687. - it: should fail with empty targetSelect.workloadName
  688. set:
  689. image: *image
  690. workload:
  691. workload-name: *workload
  692. persistence:
  693. vol-name:
  694. enabled: true
  695. type: emptyDir
  696. targetSelector:
  697. workload-name: {}
  698. asserts:
  699. - failedTemplate:
  700. errorMessage: Persistence - Expected non-empty <targetSelector.workload-name>