probes_test.yaml 19 KB

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