volumeMounts_test.yaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  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. nfs-vol-pvc:
  59. enabled: true
  60. type: nfs-pv-pvc
  61. server: my-server
  62. share: /my-path
  63. mountPath: /nfs-mount
  64. targetSelectAll: true
  65. smb-vol-pvc:
  66. enabled: true
  67. type: smb-pv-pvc
  68. server: my-server
  69. share: my-share
  70. username: my-user
  71. password: my-pass
  72. mountPath: /smb-mount
  73. targetSelectAll: true
  74. asserts:
  75. - documentIndex: &deploymentDoc 5
  76. isKind:
  77. of: Deployment
  78. - documentIndex: *deploymentDoc
  79. isAPIVersion:
  80. of: apps/v1
  81. - documentIndex: *deploymentDoc
  82. contains:
  83. path: spec.template.spec.containers[0].volumeMounts
  84. content:
  85. name: shared-vol
  86. mountPath: /some/path
  87. readOnly: false
  88. - documentIndex: *deploymentDoc
  89. contains:
  90. path: spec.template.spec.containers[0].volumeMounts
  91. content:
  92. name: nfs-vol-pvc
  93. mountPath: /nfs-mount
  94. readOnly: false
  95. - documentIndex: *deploymentDoc
  96. contains:
  97. path: spec.template.spec.containers[0].volumeMounts
  98. content:
  99. name: smb-vol-pvc
  100. mountPath: /smb-mount
  101. readOnly: false
  102. - documentIndex: *deploymentDoc
  103. contains:
  104. path: spec.template.spec.containers[1].volumeMounts
  105. content:
  106. name: shared-vol
  107. mountPath: /some/path
  108. readOnly: false
  109. - documentIndex: *deploymentDoc
  110. contains:
  111. path: spec.template.spec.containers[1].volumeMounts
  112. content:
  113. name: nfs-vol-pvc
  114. mountPath: /nfs-mount
  115. readOnly: false
  116. - documentIndex: *deploymentDoc
  117. contains:
  118. path: spec.template.spec.containers[1].volumeMounts
  119. content:
  120. name: smb-vol-pvc
  121. mountPath: /smb-mount
  122. readOnly: false
  123. - documentIndex: &jobDoc 6
  124. isKind:
  125. of: Job
  126. - documentIndex: *jobDoc
  127. isAPIVersion:
  128. of: batch/v1
  129. - documentIndex: *jobDoc
  130. contains:
  131. path: spec.template.spec.containers[0].volumeMounts
  132. content:
  133. name: shared-vol
  134. mountPath: /some/path
  135. readOnly: false
  136. - documentIndex: *jobDoc
  137. contains:
  138. path: spec.template.spec.containers[0].volumeMounts
  139. content:
  140. name: nfs-vol-pvc
  141. mountPath: /nfs-mount
  142. readOnly: false
  143. - documentIndex: *jobDoc
  144. contains:
  145. path: spec.template.spec.containers[0].volumeMounts
  146. content:
  147. name: smb-vol-pvc
  148. mountPath: /smb-mount
  149. readOnly: false
  150. - documentIndex: *jobDoc
  151. contains:
  152. path: spec.template.spec.containers[1].volumeMounts
  153. content:
  154. name: shared-vol
  155. mountPath: /some/path
  156. readOnly: false
  157. - documentIndex: *jobDoc
  158. contains:
  159. path: spec.template.spec.containers[1].volumeMounts
  160. content:
  161. name: nfs-vol-pvc
  162. mountPath: /nfs-mount
  163. readOnly: false
  164. - documentIndex: *jobDoc
  165. contains:
  166. path: spec.template.spec.containers[1].volumeMounts
  167. content:
  168. name: smb-vol-pvc
  169. mountPath: /smb-mount
  170. readOnly: false
  171. - it: should pass with volume on primary workload 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. asserts:
  215. - documentIndex: &deploymentDoc 0
  216. isKind:
  217. of: Deployment
  218. - documentIndex: *deploymentDoc
  219. isAPIVersion:
  220. of: apps/v1
  221. - documentIndex: *deploymentDoc
  222. contains:
  223. path: spec.template.spec.containers[0].volumeMounts
  224. content:
  225. name: some-vol
  226. mountPath: /some/path
  227. readOnly: true
  228. - documentIndex: *deploymentDoc
  229. isNull:
  230. path: spec.template.spec.containers[1].volumeMounts
  231. - documentIndex: &jobDoc 1
  232. isKind:
  233. of: Job
  234. - documentIndex: *jobDoc
  235. isAPIVersion:
  236. of: batch/v1
  237. - documentIndex: *jobDoc
  238. isNull:
  239. path: spec.template.spec.containers[0].volumeMounts
  240. - documentIndex: *jobDoc
  241. isNull:
  242. path: spec.template.spec.containers[1].volumeMounts
  243. - it: should pass with volume with selected pod and container
  244. set:
  245. image: *image
  246. workload:
  247. workload-name:
  248. enabled: true
  249. primary: true
  250. type: Deployment
  251. podSpec:
  252. containers:
  253. container-name1:
  254. enabled: true
  255. primary: true
  256. imageSelector: image
  257. probes: *probes
  258. container-name2:
  259. enabled: true
  260. primary: false
  261. imageSelector: image
  262. probes: *probes
  263. workload-name2:
  264. enabled: true
  265. primary: false
  266. type: Job
  267. podSpec:
  268. restartPolicy: Never
  269. containers:
  270. container-name1:
  271. enabled: true
  272. primary: true
  273. imageSelector: image
  274. probes: *probes
  275. container-name2:
  276. enabled: true
  277. primary: false
  278. imageSelector: image
  279. probes: *probes
  280. persistence:
  281. some-vol:
  282. enabled: true
  283. type: emptyDir
  284. mountPath: /some/path
  285. readOnly: true
  286. targetSelector:
  287. workload-name:
  288. container-name2: {}
  289. workload-name2:
  290. container-name1: {}
  291. asserts:
  292. - documentIndex: &deploymentDoc 0
  293. isKind:
  294. of: Deployment
  295. - documentIndex: *deploymentDoc
  296. isAPIVersion:
  297. of: apps/v1
  298. - documentIndex: *deploymentDoc
  299. isNull:
  300. path: spec.template.spec.containers[0].volumeMounts
  301. - documentIndex: *deploymentDoc
  302. contains:
  303. path: spec.template.spec.containers[1].volumeMounts
  304. content:
  305. name: some-vol
  306. mountPath: /some/path
  307. readOnly: true
  308. - documentIndex: &jobDoc 1
  309. isKind:
  310. of: Job
  311. - documentIndex: *jobDoc
  312. isAPIVersion:
  313. of: batch/v1
  314. - documentIndex: *jobDoc
  315. contains:
  316. path: spec.template.spec.containers[0].volumeMounts
  317. content:
  318. name: some-vol
  319. mountPath: /some/path
  320. readOnly: true
  321. - documentIndex: *jobDoc
  322. isNull:
  323. path: spec.template.spec.containers[1].volumeMounts
  324. - it: should pass with volume with selected pod and multiple containers
  325. set:
  326. image: *image
  327. workload:
  328. workload-name:
  329. enabled: true
  330. primary: true
  331. type: Deployment
  332. podSpec:
  333. containers:
  334. container-name1:
  335. enabled: true
  336. primary: true
  337. imageSelector: image
  338. probes: *probes
  339. container-name2:
  340. enabled: true
  341. primary: false
  342. imageSelector: image
  343. probes: *probes
  344. workload-name2:
  345. enabled: true
  346. primary: false
  347. type: Job
  348. podSpec:
  349. restartPolicy: Never
  350. containers:
  351. container-name1:
  352. enabled: true
  353. primary: true
  354. imageSelector: image
  355. probes: *probes
  356. container-name2:
  357. enabled: true
  358. primary: false
  359. imageSelector: image
  360. probes: *probes
  361. persistence:
  362. some-vol:
  363. enabled: true
  364. type: emptyDir
  365. mountPath: /some/path
  366. readOnly: true
  367. targetSelector:
  368. workload-name:
  369. container-name1: {}
  370. container-name2: {}
  371. asserts:
  372. - documentIndex: &deploymentDoc 0
  373. isKind:
  374. of: Deployment
  375. - documentIndex: *deploymentDoc
  376. isAPIVersion:
  377. of: apps/v1
  378. - documentIndex: *deploymentDoc
  379. contains:
  380. path: spec.template.spec.containers[0].volumeMounts
  381. content:
  382. name: some-vol
  383. mountPath: /some/path
  384. readOnly: true
  385. - documentIndex: *deploymentDoc
  386. contains:
  387. path: spec.template.spec.containers[1].volumeMounts
  388. content:
  389. name: some-vol
  390. mountPath: /some/path
  391. readOnly: true
  392. - documentIndex: &jobDoc 1
  393. isKind:
  394. of: Job
  395. - documentIndex: *jobDoc
  396. isAPIVersion:
  397. of: batch/v1
  398. - documentIndex: *jobDoc
  399. isNull:
  400. path: spec.template.spec.containers[0].volumeMounts
  401. - documentIndex: *jobDoc
  402. isNull:
  403. path: spec.template.spec.containers[1].volumeMounts
  404. - it: should pass with volume with selected pod and containers and specific values
  405. set:
  406. image: *image
  407. workload:
  408. workload-name:
  409. enabled: true
  410. primary: true
  411. type: Deployment
  412. podSpec:
  413. containers:
  414. container-name1:
  415. enabled: true
  416. primary: true
  417. imageSelector: image
  418. probes: *probes
  419. container-name2:
  420. enabled: true
  421. primary: false
  422. imageSelector: image
  423. probes: *probes
  424. workload-name2:
  425. enabled: true
  426. primary: false
  427. type: Job
  428. podSpec:
  429. restartPolicy: Never
  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: /some/other/path
  451. readOnly: false
  452. mountPropagation: None
  453. subPath: /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. - documentIndex: &jobDoc 1
  479. isKind:
  480. of: Job
  481. - documentIndex: *jobDoc
  482. isAPIVersion:
  483. of: batch/v1
  484. - documentIndex: *jobDoc
  485. isNull:
  486. path: spec.template.spec.containers[0].volumeMounts
  487. - documentIndex: *jobDoc
  488. isNull:
  489. path: spec.template.spec.containers[1].volumeMounts
  490. - it: should pass with volume with selected pod and containers and specific values from tpl
  491. set:
  492. some_path: /some/other/path
  493. some_propagation: None
  494. some_sub_path: /some/sub/path
  495. image: *image
  496. workload:
  497. workload-name:
  498. enabled: true
  499. primary: true
  500. type: Deployment
  501. podSpec:
  502. containers:
  503. container-name1:
  504. enabled: true
  505. primary: true
  506. imageSelector: image
  507. probes: *probes
  508. container-name2:
  509. enabled: true
  510. primary: false
  511. imageSelector: image
  512. probes: *probes
  513. persistence:
  514. some-vol:
  515. enabled: true
  516. type: emptyDir
  517. mountPath: /some/path
  518. readOnly: true
  519. targetSelector:
  520. workload-name:
  521. container-name1:
  522. mountPath: "{{ .Values.some_path }}"
  523. readOnly: false
  524. mountPropagation: "{{ .Values.some_propagation }}"
  525. subPath: "{{ .Values.some_sub_path }}"
  526. container-name2: {}
  527. asserts:
  528. - documentIndex: &deploymentDoc 0
  529. isKind:
  530. of: Deployment
  531. - documentIndex: *deploymentDoc
  532. isAPIVersion:
  533. of: apps/v1
  534. - documentIndex: *deploymentDoc
  535. contains:
  536. path: spec.template.spec.containers[0].volumeMounts
  537. content:
  538. name: some-vol
  539. mountPath: /some/other/path
  540. readOnly: false
  541. mountPropagation: None
  542. subPath: /some/sub/path
  543. - documentIndex: *deploymentDoc
  544. contains:
  545. path: spec.template.spec.containers[1].volumeMounts
  546. content:
  547. name: some-vol
  548. mountPath: /some/path
  549. readOnly: true
  550. - it: should pass with cert mounted as volume with subPath
  551. set:
  552. image: *image
  553. ixCertificates:
  554. "1":
  555. certificate: some_cert
  556. key: some_key
  557. scaleCertificate:
  558. cert-name:
  559. enabled: false
  560. id: 1
  561. workload:
  562. workload-name:
  563. enabled: true
  564. primary: true
  565. type: Deployment
  566. podSpec:
  567. containers:
  568. container-name1:
  569. enabled: true
  570. primary: true
  571. imageSelector: image
  572. probes: *probes
  573. persistence:
  574. cert-vol:
  575. enabled: true
  576. type: secret
  577. objectName: cert-name
  578. readOnly: true
  579. targetSelector:
  580. workload-name:
  581. container-name1:
  582. mountPath: /some/path/cert.crt
  583. readOnly: true
  584. subPath: cert.crt
  585. asserts:
  586. - documentIndex: &deploymentDoc 0
  587. isKind:
  588. of: Deployment
  589. - documentIndex: *deploymentDoc
  590. isAPIVersion:
  591. of: apps/v1
  592. - documentIndex: *deploymentDoc
  593. contains:
  594. path: spec.template.spec.containers[0].volumeMounts
  595. content:
  596. name: cert-vol
  597. mountPath: /some/path/cert.crt
  598. readOnly: true
  599. subPath: cert.crt
  600. - it: should pass with cert mounted as volume with subPath
  601. set:
  602. image: *image
  603. ixCertificates:
  604. "1":
  605. certificate: some_cert
  606. key: some_key
  607. scaleCertificate:
  608. cert-name:
  609. enabled: false
  610. id: 1
  611. workload:
  612. workload-name:
  613. enabled: true
  614. primary: true
  615. type: Deployment
  616. podSpec:
  617. containers:
  618. container-name1:
  619. enabled: true
  620. primary: true
  621. imageSelector: image
  622. probes: *probes
  623. persistence:
  624. cert-vol:
  625. enabled: true
  626. type: secret
  627. objectName: cert-name
  628. readOnly: true
  629. items:
  630. - key: tls.crt
  631. path: cert.crt
  632. targetSelector:
  633. workload-name:
  634. container-name1:
  635. mountPath: /some/path
  636. readOnly: true
  637. asserts:
  638. - documentIndex: &deploymentDoc 0
  639. isKind:
  640. of: Deployment
  641. - documentIndex: *deploymentDoc
  642. isAPIVersion:
  643. of: apps/v1
  644. - documentIndex: *deploymentDoc
  645. contains:
  646. path: spec.template.spec.containers[0].volumeMounts
  647. content:
  648. name: cert-vol
  649. mountPath: /some/path
  650. readOnly: true
  651. # Failures
  652. - it: should fail with invalid mountPropagation
  653. set:
  654. image: *image
  655. workload:
  656. workload-name: &workload
  657. enabled: true
  658. primary: true
  659. type: Deployment
  660. podSpec:
  661. containers:
  662. container-name1:
  663. enabled: true
  664. primary: true
  665. imageSelector: image
  666. persistence:
  667. vol-name:
  668. enabled: true
  669. type: emptyDir
  670. mountPath: /some/path
  671. mountPropagation: HostToContainer
  672. targetSelector:
  673. workload-name:
  674. container-name1:
  675. mountPropagation: invalid
  676. asserts:
  677. - failedTemplate:
  678. errorMessage: Persistence - Expected <mountPropagation> to be one of [None, HostToContainer, Bidirectional], but got [invalid]
  679. - it: should fail with non-boolean readOnly
  680. set:
  681. image: *image
  682. workload:
  683. workload-name: *workload
  684. persistence:
  685. vol-name:
  686. enabled: true
  687. type: emptyDir
  688. mountPath: /some/path
  689. targetSelector:
  690. workload-name:
  691. container-name1:
  692. readOnly: invalid
  693. asserts:
  694. - failedTemplate:
  695. errorMessage: Persistence - Expected <readOnly> to be [boolean], but got [string]
  696. - it: should fail with empty readOnly
  697. set:
  698. image: *image
  699. workload:
  700. workload-name: *workload
  701. persistence:
  702. vol-name:
  703. enabled: true
  704. type: emptyDir
  705. mountPath: /some/path
  706. targetSelector:
  707. workload-name:
  708. container-name1:
  709. readOnly:
  710. asserts:
  711. - failedTemplate:
  712. errorMessage: Persistence - Expected <readOnly> to be [boolean], but got [invalid]
  713. - it: should fail with empty mountPath
  714. set:
  715. image: *image
  716. workload:
  717. workload-name: *workload
  718. persistence:
  719. vol-name:
  720. enabled: true
  721. type: emptyDir
  722. mountPath: ""
  723. targetSelector:
  724. workload-name:
  725. container-name1: {}
  726. asserts:
  727. - failedTemplate:
  728. errorMessage: Persistence - Expected non-empty <mountPath>
  729. - it: should fail with mountPath not starting with /
  730. set:
  731. image: *image
  732. workload:
  733. workload-name: *workload
  734. persistence:
  735. vol-name:
  736. enabled: true
  737. type: emptyDir
  738. targetSelector:
  739. workload-name:
  740. container-name1:
  741. mountPath: some/path
  742. asserts:
  743. - failedTemplate:
  744. errorMessage: Persistence - Expected <mountPath> to start with a forward slash [/]
  745. - it: should fail with non-dict targetSelect.workloadName
  746. set:
  747. image: *image
  748. workload:
  749. workload-name: *workload
  750. persistence:
  751. vol-name:
  752. enabled: true
  753. type: emptyDir
  754. targetSelector:
  755. workload-name: string
  756. asserts:
  757. - failedTemplate:
  758. errorMessage: Persistence - Expected <targetSelector.workload-name> to be a [dict], but got [string]
  759. - it: should fail with empty targetSelect.workloadName
  760. set:
  761. image: *image
  762. workload:
  763. workload-name: *workload
  764. persistence:
  765. vol-name:
  766. enabled: true
  767. type: emptyDir
  768. targetSelector:
  769. workload-name: {}
  770. asserts:
  771. - failedTemplate:
  772. errorMessage: Persistence - Expected non-empty <targetSelector.workload-name>