The contributor guidelines require that the title of a unit test is "a short sentence starting with a capital
letter and ending without a period". Only 30 of the 269 titles followed that rule. The remaining ones were
lowercase verb phrases ("renders a deployment"), which made the test output read inconsistently depending on
which suite was running, and made it impossible to tell a convention violation from an intentional style.
All titles are now imperative, capitalized and unquoted-safe:
renders a deployment -> Render a Deployment
should not render when gatewayAPI.enabled is false -> Skip rendering when gatewayAPI.enabled is false
skips gpg volume spec -> Skip the gpg volume spec
The bracketed prefixes of the dependency checks and of the server section suite are kept, because they group
the tests by the chart they assert on. Only the sentence behind the prefix was rewritten.
Beyond the pure capitalization three classes of titles needed real rewording:
- The titles in image-configuration.yaml named a subject instead of a scenario ("default values", "tag
override", "digest and global registry"). They now describe what is rendered.
- init_directory_structure.sh-rootless.yaml carried "it does not chown /data ...", which rendered as
"it it does not chown" in the test output.
- The "should" prefix in the Gateway API and route suites added no information once the title is a sentence.
The title of the GIT_GC_REPOS test lost its embedded double quotes. The title was previously an unquoted YAML
scalar, so the quotes were literal characters; quoting the title turned them into a parse error. The value is
unambiguous without them.
Three byte-identical tests asserting pgpool.adminPassword existed in customization-integrity-postgresql-ha.yaml
- same template, same assertion, same expected value. They were a copy-paste artifact and shared one title, so
two of them are removed. No coverage is lost, which is why the test count drops from 269 to 267.
No snapshot files are tracked and no suite uses matchSnapshot, so retitling cannot invalidate stored snapshots.
Co-authored-by: Copilot <copilot@github.com>
376 lines
11 KiB
YAML
376 lines
11 KiB
YAML
suite: deployment template (basic)
|
|
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"
|