Bash / bash-unittest (push) Successful in 14s
Bash / shellcheck (push) Successful in 20s
changelog / changelog (push) Successful in 16s
Helm / helm-lint (push) Successful in 15s
Helm / helm-unittest (push) Successful in 32s
Markdown linter / markdown-lint (push) Successful in 15s
Markdown linter / markdown-link-checker (push) Successful in 56s
The contributor guidelines never defined how a `suite` title has to look, only how an `it` title has to look. Without a rule five competing schemes grew side by side: `config template | cache config`, `deployment template (probes)`, `ServiceMonitor template (basic)`, `Test Gateway API httpRoute.yaml` and `Dependency checks | Customization integrity | valkey`. 24 of the 49 titles started with a lowercase letter, which contradicts the sentence rule that already applies to the test titles. More than cosmetics, the missing rule produced three concrete defects: - `deployment template` was used by both deployment-additional-config.yaml and extraInitContainers.yaml, and `Init template` by both init_directory_structure.sh.yaml and its rootless counterpart. `helm unittest` identifies a failing suite by its title, so a failure in either file printed the same header and the report did not say which file to open. - deployment/inline-config.yaml was titled `config template`, although it lives in the deployment directory and asserts on secret_inlineConfig.yaml. It read like a sixth member of the `config template | ...` group. - persistentVolumeClaim.yaml was titled `PVC template`, using exactly the short name the chart conventions forbid for files and keys. All suites now follow `Test <subject> <scenario>`, for example `Test deployment probes` or `Test gateway API httpRoute`. The subject is the template under test, the scenario is what distinguishes the suite from its siblings, so every title is unique and sorts next to its related suites. The `Test ` prefix of the Gateway API, ingress and route suites is kept, because it is the only part of the old schemes that already read as a sentence; the redundant `.yaml` suffix and the `tests` suffix of the storage class suite are dropped. The rule is written down in the Unit Tests section of the copilot instructions, so the next suite does not have to guess which of the five schemes was meant. Co-authored-by: Copilot <copilot@github.com>
376 lines
11 KiB
YAML
376 lines
11 KiB
YAML
suite: Test deployment basics
|
|
release:
|
|
name: gitea-unittests
|
|
namespace: testing
|
|
templates:
|
|
- templates/deployment.yaml
|
|
- templates/secret_admin.yaml
|
|
- templates/secret_config.yaml
|
|
- templates/secret_gpg.yaml
|
|
- templates/secret_init.yaml
|
|
- templates/secret_inlineConfig.yaml
|
|
- templates/secret_metrics.yaml
|
|
tests:
|
|
- it: "Render a Deployment"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- containsDocument:
|
|
kind: Deployment
|
|
apiVersion: apps/v1
|
|
name: gitea-unittests
|
|
- it: "Skip rendering when the Deployment is disabled"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.enabled: false
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 0
|
|
- it: "Render the configured Deployment labels"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.labels:
|
|
hello: world
|
|
asserts:
|
|
- isSubset:
|
|
path: metadata.labels
|
|
content:
|
|
hello: world
|
|
- isSubset:
|
|
path: spec.template.metadata.labels
|
|
content:
|
|
hello: world
|
|
- isNotSubset:
|
|
path: spec.selector.matchLabels
|
|
content:
|
|
hello: world
|
|
- it: "Omit the Deployment labels from the selector matchLabels"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.labels:
|
|
custom-label: custom-value
|
|
another-label: another-value
|
|
asserts:
|
|
- equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/name: gitea
|
|
app.kubernetes.io/instance: gitea-unittests
|
|
- it: "Render the Deployment labels even when none are configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- isSubset:
|
|
path: metadata.labels
|
|
content:
|
|
app: gitea
|
|
app.kubernetes.io/name: gitea
|
|
app.kubernetes.io/instance: gitea-unittests
|
|
app.kubernetes.io/managed-by: Helm
|
|
- it: "Omit the Deployment annotations when none are configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: metadata.annotations
|
|
- it: "Render the configured Deployment annotations"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.annotations:
|
|
hello: world
|
|
asserts:
|
|
- equal:
|
|
path: metadata.annotations
|
|
value:
|
|
hello: world
|
|
- it: "Omit the nodeSelector when none is configured"
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.nodeSelector
|
|
template: templates/deployment.yaml
|
|
- it: "Render the configured nodeSelector"
|
|
set:
|
|
deployment.nodeSelector:
|
|
foo: bar
|
|
bar: foo
|
|
asserts:
|
|
- isSubset:
|
|
path: spec.template.spec.nodeSelector
|
|
content:
|
|
foo: bar
|
|
bar: foo
|
|
template: templates/deployment.yaml
|
|
- it: "Omit the affinity when none is configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.affinity
|
|
- it: "Render the configured affinity"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.affinity:
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: kubernetes.io/os
|
|
operator: In
|
|
values:
|
|
- linux
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.affinity
|
|
value:
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: kubernetes.io/os
|
|
operator: In
|
|
values:
|
|
- linux
|
|
- it: "Omit the dnsConfig when none is configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.dnsConfig
|
|
- it: "Render the configured dnsConfig"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.dnsConfig:
|
|
nameservers:
|
|
- 192.0.2.1
|
|
options:
|
|
- name: ndots
|
|
value: "2"
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.dnsConfig
|
|
value:
|
|
nameservers:
|
|
- 192.0.2.1
|
|
options:
|
|
- name: ndots
|
|
value: "2"
|
|
- it: "Omit the priorityClassName when none is configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.priorityClassName
|
|
- it: "Render the configured priorityClassName"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.priorityClassName: high-priority
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.priorityClassName
|
|
value: high-priority
|
|
- it: "Omit the schedulerName when none is configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.schedulerName
|
|
- it: "Render the configured schedulerName"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.schedulerName: stork
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.schedulerName
|
|
value: stork
|
|
- it: "Default the strategy to a rolling update"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- equal:
|
|
path: spec.strategy
|
|
value:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxUnavailable: 0
|
|
maxSurge: 100%
|
|
- it: "Omit rollingUpdate for other strategy types"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.strategy.type: Recreate
|
|
asserts:
|
|
- equal:
|
|
path: spec.strategy
|
|
value:
|
|
type: Recreate
|
|
- it: "Omit the tolerations when none are configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.tolerations
|
|
- it: "Render the configured tolerations"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.tolerations:
|
|
- key: database/type
|
|
operator: Equal
|
|
value: postgres
|
|
effect: NoSchedule
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.tolerations
|
|
value:
|
|
- key: database/type
|
|
operator: Equal
|
|
value: postgres
|
|
effect: NoSchedule
|
|
- it: "Omit the topologySpreadConstraints when none are configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.topologySpreadConstraints
|
|
- it: "Render the configured topologySpreadConstraints"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.topologySpreadConstraints:
|
|
- topologyKey: kubernetes.io/hostname
|
|
whenUnsatisfiable: DoNotSchedule
|
|
maxSkew: 1
|
|
labelSelector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: gitea-unittests
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.topologySpreadConstraints
|
|
value:
|
|
- topologyKey: kubernetes.io/hostname
|
|
whenUnsatisfiable: DoNotSchedule
|
|
maxSkew: 1
|
|
labelSelector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: gitea-unittests
|
|
|
|
- it: "Inject TMP_EXISTING_ENVS_FILE into the 'init-app-ini' init container"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[1].env
|
|
content:
|
|
name: TMP_EXISTING_ENVS_FILE
|
|
value: /tmp/existing-envs
|
|
- it: "Inject ENV_TO_INI_MOUNT_POINT into the 'init-app-ini' init container"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[1].env
|
|
content:
|
|
name: ENV_TO_INI_MOUNT_POINT
|
|
value: /env-to-ini-mounts
|
|
- it: "Inject deployment.gitea.env into all init containers and the gitea container"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.gitea.env:
|
|
- name: VARIABLE
|
|
value: my-value
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[0].env
|
|
content:
|
|
name: VARIABLE
|
|
value: my-value
|
|
- contains:
|
|
path: spec.template.spec.initContainers[1].env
|
|
content:
|
|
name: VARIABLE
|
|
value: my-value
|
|
- contains:
|
|
path: spec.template.spec.initContainers[2].env
|
|
content:
|
|
name: VARIABLE
|
|
value: my-value
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: VARIABLE
|
|
value: my-value
|
|
- it: "Render GOMAXPROCS when the CPU resources are defined"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.gitea.resources:
|
|
limits:
|
|
cpu: 200ms
|
|
memory: 200Mi
|
|
requests:
|
|
cpu: 100ms
|
|
memory: 100Mi
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: GOMAXPROCS
|
|
valueFrom:
|
|
resourceFieldRef:
|
|
divisor: "1"
|
|
resource: limits.cpu
|
|
- equal:
|
|
path: spec.template.spec.containers[0].resources
|
|
value:
|
|
limits:
|
|
cpu: 200ms
|
|
memory: 200Mi
|
|
requests:
|
|
cpu: 100ms
|
|
memory: 100Mi
|
|
- it: "Default the container resources to an empty map and omit GOMAXPROCS"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.containers[0].resources
|
|
value: {}
|
|
- notContains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: GOMAXPROCS
|
|
valueFrom:
|
|
resourceFieldRef:
|
|
divisor: "1"
|
|
resource: limits.cpu
|
|
- it: "Omit the pod level resources when none are configured"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- notExists:
|
|
path: spec.template.spec.resources
|
|
- it: "Render the configured pod level resources"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
deployment.resources:
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|
|
requests:
|
|
cpu: 250m
|
|
memory: 256Mi
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.resources
|
|
value:
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|
|
requests:
|
|
cpu: 250m
|
|
memory: 256Mi
|
|
- it: "Render the configured volumeMount path of the init containers"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
initContainersScriptsVolumeMountPath: "/custom/init/path"
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
|
|
value: "/custom/init/path"
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
|
|
value: "/custom/init/path"
|
|
- it: "Render the default volumeMount path of the init containers"
|
|
template: templates/deployment.yaml
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="init")].mountPath
|
|
value: "/usr/sbinx"
|
|
- equal:
|
|
path: spec.template.spec.initContainers[*].volumeMounts[?(@.name=="config")].mountPath
|
|
value: "/usr/sbinx"
|