volumeMounts_test.yaml 20 KB

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