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>
131 lines
4.2 KiB
YAML
131 lines
4.2 KiB
YAML
suite: Test deployment with signing enabled
|
|
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: "Add the gpg init container"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.existingSecret.enabled: true
|
|
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.template.spec.initContainers[2].name
|
|
value: configure-gpg
|
|
- equal:
|
|
path: spec.template.spec.initContainers[2].command
|
|
value: ["/usr/sbinx/configure_gpg_environment.sh"]
|
|
- equal:
|
|
path: spec.template.spec.initContainers[2].securityContext
|
|
value:
|
|
runAsUser: 1000
|
|
- equal:
|
|
path: spec.template.spec.initContainers[2].env
|
|
value:
|
|
- name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: custom-gpg-secret
|
|
key: gpgHome
|
|
- name: TMP_RAW_GPG_KEY
|
|
value: /raw/private.asc
|
|
- equal:
|
|
path: spec.template.spec.initContainers[2].volumeMounts
|
|
value:
|
|
- name: init
|
|
mountPath: /usr/sbinx
|
|
- name: data
|
|
mountPath: /data
|
|
- name: gpg-private-key
|
|
mountPath: /raw
|
|
readOnly: true
|
|
- it: "Add the gpg env to the `init-directories` init container"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.existingSecret.enabled: true
|
|
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.initContainers[0].env
|
|
content:
|
|
name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: custom-gpg-secret
|
|
key: gpgHome
|
|
- it: "Add the gpg env to the runtime container"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.existingSecret.enabled: true
|
|
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: custom-gpg-secret
|
|
key: gpgHome
|
|
- it: "Read the gpg home from the configured key of an existing Secret"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.existingSecret.enabled: true
|
|
secrets.gpg.existingSecret.secretName: "custom-gpg-secret"
|
|
secrets.gpg.existingSecret.gpgHomeKey: custom-gpg-home
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.containers[0].env
|
|
content:
|
|
name: GNUPGHOME
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: custom-gpg-secret
|
|
key: custom-gpg-home
|
|
- it: "Add the gpg volume spec"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.new.privateKey: "gpg-key-placeholder"
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.volumes
|
|
content:
|
|
name: gpg-private-key
|
|
secret:
|
|
secretName: gitea-unittests-gpg-key
|
|
items:
|
|
- key: privateKey
|
|
path: private.asc
|
|
defaultMode: 0100
|
|
- it: "Render the gpg volume spec with an external reference"
|
|
template: templates/deployment.yaml
|
|
set:
|
|
secrets.gpg.enabled: true
|
|
secrets.gpg.existingSecret.enabled: true
|
|
secrets.gpg.existingSecret.secretName: custom-gpg-secret
|
|
secrets.gpg.existingSecret.privateKeyKey: custom-private-key
|
|
asserts:
|
|
- contains:
|
|
path: spec.template.spec.volumes
|
|
content:
|
|
name: gpg-private-key
|
|
secret:
|
|
secretName: custom-gpg-secret
|
|
items:
|
|
- key: custom-private-key
|
|
path: private.asc
|
|
defaultMode: 0100
|