test: align the file names of the helm unit tests with the chart conventions

The chart conventions demand camelCase file names, forbid short names like `svc` and require the unit tests to
mirror the template structure. The unit tests followed none of that consistently. Four casings existed side by
side - camelCase (extraInitContainers.yaml), kebab-case (checksum-annotations.yaml), a snake and kebab mix
(init_directory_structure.sh-rootless.yaml) and all caps (HA.yaml) - so there was no pattern to copy when
adding a suite, which is how the inconsistency kept growing.

Three groups of problems are fixed:

- svc-configuration.yaml used exactly the short name the conventions forbid for files and keys.
- Several file names repeated their own directory, for example deployment/deployment-additional-config.yaml and
  metric-secret/metrics-secret-servicemonitor-disabled.yaml, which names the subject three times. The directory
  already carries that information, so the file name now only carries the scenario. The default scenario of a
  template is named basics.yaml.
- Four suites lived in a directory of a template they do not assert on. They were filed under deployment/
  because the deployment is rendered as a side effect, not because it is the subject:

      deployment/deprecations.yaml                -> deprecation/deployment.yaml
      deployment/inline-config.yaml               -> config/inlineConfig.yaml
      deployment/storage-class-configuration.yaml -> persistentVolumeClaim/storageClass.yaml
      deployment/svc-configuration.yaml           -> service/configuration.yaml

  storage-class-configuration.yaml is the clearest case: a persistentVolumeClaim directory already existed next
  to it. The suite titles of the two suites whose subject changed are adjusted accordingly.

The Makefile passed `--file unittests/helm/values-conflicting-checks.yaml`, but that file does not exist in the
tree. `helm unittest` ignores a missing path without a warning, so the flag has been dead for an unknown amount
of time while still suggesting the checks run. It is removed; the `unittests/helm/**/*.yaml` glob would pick
the file up anyway if it ever returns.

The naming rule is written down in the copilot instructions, together with the constraint that the glob matches
only a single directory level, so a suite can never be placed directly in unittests/helm/.

All 49 suites and 267 tests still pass.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-10-03 22:19:39 +02:00
co-authored by Copilot
parent fef4190a74
commit eeacda2a25
42 changed files with 5 additions and 4 deletions
-243
View File
@@ -1,243 +0,0 @@
suite: Test deployment deprecations
release:
name: gitea-unittests
namespace: testing
templates:
- templates/deprecation.yaml
tests:
- it: "Render nothing with the default values"
asserts:
- hasDocuments:
count: 0
- it: "Fail when the removed `affinity` value is set"
set:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
asserts:
- failedTemplate:
errorMessage: "`affinity` does no longer exist. Please refer to the changelog and configure `deployment.affinity` instead."
- it: "Fail when the removed `containerSecurityContext` value is set"
set:
containerSecurityContext:
runAsUser: 1000
asserts:
- failedTemplate:
errorMessage: "`containerSecurityContext` does no longer exist. Please refer to the changelog and configure `deployment.gitea.securityContext` instead."
- it: "Fail when the removed `deployment.env` value is set"
set:
deployment.env:
- name: VARIABLE
value: my-value
asserts:
- failedTemplate:
errorMessage: "`deployment.env` does no longer exist. Please refer to the changelog and configure `deployment.gitea.env` instead."
- it: "Fail when the removed `dnsConfig` value is set"
set:
dnsConfig:
nameservers:
- 192.0.2.1
asserts:
- failedTemplate:
errorMessage: "`dnsConfig` does no longer exist. Please refer to the changelog and configure `deployment.dnsConfig` instead."
- it: "Fail when the removed `extraContainerVolumeMounts` value is set"
set:
extraContainerVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
asserts:
- failedTemplate:
errorMessage: "`extraContainerVolumeMounts` does no longer exist. Please refer to the changelog and configure `deployment.gitea.volumeMounts` instead."
- it: "Fail when the removed `extraInitVolumeMounts` value is set"
set:
extraInitVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
asserts:
- failedTemplate:
errorMessage: "`extraInitVolumeMounts` does no longer exist. Please refer to the changelog and configure `deployment.<initContainer>.volumeMounts` instead."
- it: "Fail when the removed `extraVolumeMounts` value is set"
set:
extraVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
asserts:
- failedTemplate:
errorMessage: "`extraVolumeMounts` does no longer exist. Please refer to the changelog and configure `deployment.gitea.volumeMounts` and `deployment.<initContainer>.volumeMounts` instead."
- it: "Fail when the removed `extraVolumes` value is set"
set:
extraVolumes:
- name: postgres-ssl-vol
secret:
secretName: gitea-postgres-ssl
asserts:
- failedTemplate:
errorMessage: "`extraVolumes` does no longer exist. Please refer to the changelog and configure `deployment.volumes` instead."
- it: "Fail when the removed `ingress.className` value is set"
set:
ingress.className: ""
asserts:
- failedTemplate:
errorMessage: "`ingress.className` does no longer exist. Please refer to the changelog and configure `ingress.ingressClassName` instead."
- it: "Fail when the removed `nodeSelector` value is set"
set:
nodeSelector:
foo: bar
asserts:
- failedTemplate:
errorMessage: "`nodeSelector` does no longer exist. Please refer to the changelog and configure `deployment.nodeSelector` instead."
- it: "Fail when the removed `openshift.hostUsers` value is set"
set:
openshift.hostUsers: false
asserts:
- failedTemplate:
errorMessage: "`openshift.hostUsers` does no longer exist. Please refer to the changelog and configure `deployment.hostUsers` instead."
- it: "Fail when the removed `priorityClassName` value is set"
set:
priorityClassName: high-priority
asserts:
- failedTemplate:
errorMessage: "`priorityClassName` does no longer exist. Please refer to the changelog and configure `deployment.priorityClassName` instead."
- it: "Fail when the removed `podSecurityContext` value is set"
set:
podSecurityContext:
fsGroup: 1000
asserts:
- failedTemplate:
errorMessage: "`podSecurityContext` does no longer exist. Please refer to the changelog and configure `deployment.securityContext` instead."
- it: "Fail when the removed `postExtraInitContainers` value is set"
set:
postExtraInitContainers:
- name: post-init-container
image: docker.io/library/busybox
asserts:
- failedTemplate:
errorMessage: "`postExtraInitContainers` does no longer exist. Please refer to the changelog and append an entry with a `container` key to `deployment.initContainers` instead."
- it: "Fail when the removed `preExtraInitContainers` value is set"
set:
preExtraInitContainers:
- name: pre-init-container
image: docker.io/library/busybox
asserts:
- failedTemplate:
errorMessage: "`preExtraInitContainers` does no longer exist. Please refer to the changelog and prepend an entry with a `container` key to `deployment.initContainers` instead."
- it: "Fail when the removed `resources` value is set"
set:
resources:
limits:
cpu: 100m
asserts:
- failedTemplate:
errorMessage: "`resources` does no longer exist. Please refer to the changelog and configure `deployment.gitea.resources` instead."
- it: "Fail when the removed `replicaCount` value is set"
set:
replicaCount: 2
asserts:
- failedTemplate:
errorMessage: "`replicaCount` does no longer exist. Please refer to the changelog and configure `deployment.replicas` instead."
- it: "Fail when the removed `schedulerName` value is set"
set:
schedulerName: stork
asserts:
- failedTemplate:
errorMessage: "`schedulerName` does no longer exist. Please refer to the changelog and configure `deployment.schedulerName` instead."
- it: "Fail when the removed `securityContext` value is set"
set:
securityContext:
runAsUser: 1000
asserts:
- failedTemplate:
errorMessage: "`securityContext` does no longer exist. Please refer to the changelog and configure `deployment.securityContext` and `deployment.gitea.securityContext` instead."
- it: "Fail when the removed `strategy` value is set"
set:
strategy:
type: Recreate
asserts:
- failedTemplate:
errorMessage: "`strategy` does no longer exist. Please refer to the changelog and configure `deployment.strategy` instead."
- it: "Fail when the removed `test` value is set"
set:
test:
enabled: false
asserts:
- failedTemplate:
errorMessage: "`test` does no longer exist. Please refer to the changelog. The `helm test` connection Pod has been removed without replacement."
- it: "Fail when the removed `tolerations` value is set"
set:
tolerations:
- key: database/type
operator: Equal
value: postgres
effect: NoSchedule
asserts:
- failedTemplate:
errorMessage: "`tolerations` does no longer exist. Please refer to the changelog and configure `deployment.tolerations` instead."
- it: "Fail when the removed `topologySpreadConstraints` value is set"
set:
topologySpreadConstraints:
- topologyKey: kubernetes.io/hostname
asserts:
- failedTemplate:
errorMessage: "`topologySpreadConstraints` does no longer exist. Please refer to the changelog and configure `deployment.topologySpreadConstraints` instead."
- it: "Skip the deprecation checks when `checkDeprecation` is disabled"
set:
checkDeprecation: false
affinity:
nodeAffinity: {}
containerSecurityContext:
runAsUser: 1000
deployment.env:
- name: VARIABLE
value: my-value
dnsConfig:
nameservers:
- 192.0.2.1
extraContainerVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
extraInitVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
extraVolumeMounts:
- name: postgres-ssl-vol
mountPath: /pg-ssl
extraVolumes:
- name: postgres-ssl-vol
secret:
secretName: gitea-postgres-ssl
nodeSelector:
foo: bar
podSecurityContext:
fsGroup: 1000
postExtraInitContainers:
- name: post-init-container
image: docker.io/library/busybox
preExtraInitContainers:
- name: pre-init-container
image: docker.io/library/busybox
priorityClassName: high-priority
replicaCount: 2
resources:
limits:
cpu: 100m
schedulerName: stork
securityContext:
runAsUser: 1000
strategy:
type: Recreate
tolerations:
- key: database/type
operator: Equal
value: postgres
effect: NoSchedule
topologySpreadConstraints:
- topologyKey: kubernetes.io/hostname
asserts:
- hasDocuments:
count: 0
@@ -1,44 +0,0 @@
suite: Test deployment inline config
release:
name: gitea-unittests
namespace: testing
templates:
- templates/secret_inlineConfig.yaml
tests:
- it: "Render the inline config of data.server via tpl"
set:
global.giteaHostName: "gitea.example.com"
ingress.enabled: true
ingress.hosts[0].host: "{{ .Values.global.giteaHostName }}"
ingress.tls:
- secretName: gitea-tls
hosts:
- "{{ .Values.global.giteaHostName }}"
asserts:
- documentIndex: 0
matchRegex:
path: metadata.name
pattern: .*-inline-config$
- documentIndex: 0
matchRegex:
path: data.server
decodeBase64: true
pattern: DOMAIN=gitea\.example\.com
- documentIndex: 0
matchRegex:
path: data.server
decodeBase64: true
pattern: ROOT_URL=https://gitea\.example\.com
- documentIndex: 0
matchRegex:
path: data.server
decodeBase64: true
pattern: SSH_DOMAIN=gitea\.example\.com
- it: "Render data instead of stringData so removed sections are pruned on upgrade"
asserts:
- documentIndex: 0
notExists:
path: stringData
- documentIndex: 0
exists:
path: data.server
@@ -1,17 +0,0 @@
chart:
appVersion: 1.27.3
release:
name: gitea-unittests
namespace: testing
suite: Test deployment storage class configuration
templates:
- templates/persistentVolumeClaim.yaml
tests:
- it: "Render the storageClassName when persistence.new.storageClassName is defined"
set:
persistence.enabled: true
persistence.new.storageClassName: my-storage-class
asserts:
- equal:
path: spec.storageClassName
value: my-storage-class
@@ -1,118 +0,0 @@
suite: Test httpService and sshService configuration
release:
name: gitea-unittests
namespace: testing
templates:
- templates/service_ssh.yaml
- templates/service_http.yaml
tests:
- it: "Add custom labels to the SSH Service"
template: templates/service_ssh.yaml
set:
service:
ssh:
labels:
gitea/testkey: testvalue
asserts:
- equal:
path: metadata.labels["gitea/testkey"]
value: "testvalue"
- it: "Keep the existing labels of the SSH Service"
template: templates/service_ssh.yaml
set:
service:
ssh:
labels: {}
asserts:
- exists:
path: metadata.labels["app"]
- it: "Add custom labels to the HTTP Service"
template: templates/service_http.yaml
set:
service:
http:
labels:
gitea/testkey: testvalue
asserts:
- equal:
path: metadata.labels["gitea/testkey"]
value: "testvalue"
- it: "Keep the existing labels of the HTTP Service"
template: templates/service_http.yaml
set:
service:
http:
labels: {}
asserts:
- exists:
path: metadata.labels["app"]
- it: "Render service.ssh.loadBalancerClass when the type is LoadBalancer"
template: templates/service_ssh.yaml
set:
service:
ssh:
loadBalancerClass: "example.com/class"
type: LoadBalancer
loadBalancerIP: "1.2.3.4"
loadBalancerSourceRanges:
- "1.2.3.4/32"
- "5.6.7.8/32"
asserts:
- equal:
path: spec.loadBalancerClass
value: "example.com/class"
- equal:
path: spec.loadBalancerIP
value: "1.2.3.4"
- equal:
path: spec.loadBalancerSourceRanges
value: ["1.2.3.4/32", "5.6.7.8/32"]
- it: "Skip the loadBalancer properties when the type is not LoadBalancer"
template: templates/service_http.yaml
set:
service:
http:
type: ClusterIP
loadBalancerClass: "example.com/class"
loadBalancerIP: "1.2.3.4"
loadBalancerSourceRanges:
- "1.2.3.4/32"
- "5.6.7.8/32"
asserts:
- notExists:
path: spec.loadBalancerClass
- notExists:
path: spec.loadBalancerIP
- notExists:
path: spec.loadBalancerSourceRanges
- it: "Skip loadBalancerClass by default even when the type is LoadBalancer"
template: templates/service_http.yaml
set:
service:
http:
type: LoadBalancer
loadBalancerIP: "1.2.3.4"
asserts:
- notExists:
path: spec.loadBalancerClass
- equal:
path: spec.loadBalancerIP
value: "1.2.3.4"
- it: "Render both the SSH and the HTTP Service"
templates:
- templates/service_ssh.yaml
- templates/service_http.yaml
asserts:
- matchRegex:
path: metadata.name
pattern: "^gitea-unittests-(?:ssh|http)$"
- matchRegex:
path: spec.ports[0].name
pattern: "^(?:ssh|http)$"