--- # yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json suite: container probes templates: - common.yaml values: - ../_values/controllers_main_default_container.yaml - ../_values/service_main_default.yaml set: controllers.main.containers.main.probes.liveness.enabled: true controllers.main.containers.main.probes.readiness.enabled: true controllers.main.containers.main.probes.startup.enabled: true tests: - it: default probes documentSelector: &DeploymentSelector path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8081 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].readinessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8081 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].startupProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8081 timeoutSeconds: 1 - it: custom primary port gets picked up by probes set: service.main.ports.test: enabled: true primary: true port: 8080 documentSelector: *DeploymentSelector asserts: - documentIndex: 0 isKind: of: Deployment - equal: path: spec.template.spec.containers[0].livenessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8080 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].readinessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8080 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].startupProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 8080 timeoutSeconds: 1 - it: probes with string Service port set: service.main.ports.http.port: "80" documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 80 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].readinessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 80 timeoutSeconds: 1 - equal: path: spec.template.spec.containers[0].startupProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: 80 timeoutSeconds: 1 - it: multiple services are handled correctly set: controllers: other: containers: main: image: repository: ghcr.io/mendhak/http-https-echo tag: 31 pullPolicy: IfNotPresent probes: liveness: enabled: true readiness: enabled: true startup: enabled: true service: other: controller: other ports: http: enabled: true port: 8080 asserts: - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-main equal: path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port value: 8081 - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-main equal: path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port value: 8081 - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-main equal: path: spec.template.spec.containers[0].startupProbe.tcpSocket.port value: 8081 - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-other equal: path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port value: 8080 - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-other equal: path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port value: 8080 - documentSelector: path: $[?(@.kind == "Deployment")].metadata.name value: RELEASE-NAME-other equal: path: spec.template.spec.containers[0].startupProbe.tcpSocket.port value: 8080 - it: no probes are defined when services are disabled set: service: main: enabled: false controller: main documentSelector: *DeploymentSelector asserts: - notExists: path: spec.template.spec.containers[0].livenessProbe - notExists: path: spec.template.spec.containers[0].readinessProbe - notExists: path: spec.template.spec.containers[0].startupProbe - it: AUTO type probe can be configured set: service.main.ports.http.protocol: HTTP controllers.main.containers.main.probes: liveness: enabled: true type: AUTO path: /api/version documentSelector: *DeploymentSelector asserts: - documentIndex: 0 isKind: of: Deployment - documentIndex: 0 equal: path: spec.template.spec.containers[0].livenessProbe value: httpGet: path: /api/version port: 8081 scheme: HTTP initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: HTTP type probe can be configured set: controllers.main.containers.main.probes: liveness: enabled: true type: HTTP path: /api/version documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: httpGet: path: /api/version port: 8081 scheme: HTTP initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: HTTPS type probe can be configured set: controllers.main.containers.main.probes: liveness: enabled: true type: HTTPS path: /api/version documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: httpGet: path: /api/version port: 8081 scheme: HTTPS initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: GRPC type probe can be configured without service set: controllers.main.containers.main.probes: liveness: enabled: true type: GRPC documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: grpc: port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: GRPC type probe can be configured with service set: controllers.main.containers.main.probes: liveness: enabled: true type: GRPC service: test documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: grpc: port: 8081 service: test initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: custom liveness probe can be configured set: controllers.main.containers.main.probes: liveness: enabled: true custom: true spec: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].livenessProbe value: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: custom readiness probe can be configured set: controllers.main.containers.main.probes: readiness: enabled: true custom: true spec: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].readinessProbe value: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: custom startup probe can be configured set: controllers.main.containers.main.probes: startup: enabled: true custom: true spec: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].startupProbe value: httpGet: path: /api/version port: 8081 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 1 failureThreshold: 3 - it: User-defined liveness probe port can be configured set: controllers.main.containers.main.probes: liveness: enabled: true port: http documentSelector: *DeploymentSelector asserts: - documentIndex: 0 equal: path: spec.template.spec.containers[0].livenessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: http timeoutSeconds: 1 - it: User-defined readiness probe port can be configured set: controllers.main.containers.main.probes: readiness: enabled: true port: http documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].readinessProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: http timeoutSeconds: 1 - it: User-defined startup probe port can be configured set: controllers.main.containers.main.probes: startup: enabled: true port: http documentSelector: *DeploymentSelector asserts: - equal: path: spec.template.spec.containers[0].startupProbe value: failureThreshold: 3 initialDelaySeconds: 0 periodSeconds: 10 tcpSocket: port: http timeoutSeconds: 1