suite: Dependency checks | Customization integrity | valkey-cluster
release:
  name: gitea-unittests
  namespace: testing
set:
  valkey:
    enabled: false
  valkey-cluster:
    enabled: true
    usePassword: false
    cluster:
      nodes: 5
      replicas: 2
tests:
  - it: "[valkey-cluster] configures correct nodes/replicas"
    template: charts/valkey-cluster/templates/valkey-statefulset.yaml
    asserts:
      - documentIndex: 0
        equal:
          path: spec.replicas
          value: 5
      - documentIndex: 0
        matchRegex:
          path: spec.template.spec.containers[0].args[0]
          pattern: VALKEY_CLUSTER_REPLICAS="2"
  - it: "[valkey-cluster] support auth-less connections"
    asserts:
      - template: charts/valkey-cluster/templates/secret.yaml
        hasDocuments:
          count: 0
      - template: charts/valkey-cluster/templates/valkey-statefulset.yaml
        documentIndex: 0
        contains:
          path: spec.template.spec.containers[0].env
          content:
            name: ALLOW_EMPTY_PASSWORD
            value: "yes"
  - it: "[valkey-cluster] support auth-full connections"
    set:
      valkey-cluster:
        usePassword: true
    asserts:
      - template: charts/valkey-cluster/templates/secret.yaml
        containsDocument:
          kind: Secret
          apiVersion: v1
          name: gitea-unittests-valkey-cluster
          namespace: testing
      - template: charts/valkey-cluster/templates/valkey-statefulset.yaml
        documentIndex: 0
        contains:
          path: spec.template.spec.containers[0].env
          content:
            name: REDISCLI_AUTH
            valueFrom:
              secretKeyRef:
                name: gitea-unittests-valkey-cluster
                key: valkey-password
      - template: charts/valkey-cluster/templates/valkey-statefulset.yaml
        documentIndex: 0
        contains:
          path: spec.template.spec.containers[0].env
          content:
            name: REDISCLI_AUTH
            valueFrom:
              secretKeyRef:
                name: gitea-unittests-valkey-cluster
                key: valkey-password
  - it: "[valkey-cluster] renders the referenced service"
    template: charts/valkey-cluster/templates/headless-svc.yaml
    asserts:
      - containsDocument:
          kind: Service
          apiVersion: v1
          name: gitea-unittests-valkey-cluster-headless
          namespace: testing
      - documentIndex: 0
        contains:
          path: spec.ports
          content:
            name: tcp-redis
            port: 6379
            targetPort: tcp-redis
  - it: "[gitea] waits for valkey-cluster to be up and running"
    template: templates/gitea/init.yaml
    asserts:
      - documentIndex: 0
        matchRegex:
          path: stringData["configure_gitea.sh"]
          pattern: nc -vz -w2 gitea-unittests-valkey-cluster-headless.testing.svc.cluster.local 6379
