fixed lein test

This commit is contained in:
bom 2021-08-10 18:00:43 +02:00
parent 70e3b967f1
commit bc546e33d8
2 changed files with 65 additions and 88 deletions

View file

@ -27,67 +27,39 @@
(deftest should-generate-cron
(is (= {:apiVersion "batch/v1beta1"
:kind "CronJob"
:metadata {:name "cloud-backup"
:labels {:app.kubernetes.part-of "cloud"}}
:spec {:schedule "10 23 * * *"
:successfulJobsHistoryLimit 1
:failedJobsHistoryLimit 1
:jobTemplate
{:spec
{:template
{:spec
{:containers
[{:name "backup-app"
:image "domaindrivenarchitecture/c4k-nextcloud-backup"
:imagePullPolicy "IfNotPresent"
:command ["/entrypoint.sh"]
:env
[{:name "POSTGRES_USER"
:valueFrom
{:secretKeyRef
{:name "postgres-secret"
:key "postgres-user"}}}
{:name "POSTGRES_PASSWORD"
:valueFrom
{:secretKeyRef
{:name "postgres-secret"
:key "postgres-password"}}}
{:name "POSTGRES_DB"
:valueFrom
{:configMapKeyRef
{:name "postgres-config"
:key "postgres-db"}}}
{:name "POSTGRES_HOST"
:value "postgresql-service:5432"}
{:name "POSTGRES_SERVICE"
:value "postgresql-service"}
{:name "POSTGRES_PORT"
:value "5432"}
{:name "AWS_DEFAULT_REGION"
:value "eu-central-1"}
{:name "AWS_ACCESS_KEY_ID_FILE"
:value "/var/run/secrets/backup-secrets/aws-access-key-id"}
{:name "AWS_SECRET_ACCESS_KEY_FILE"
:value "/var/run/secrets/backup-secrets/aws-secret-access-key"}
{:name "RESTIC_REPOSITORY"
:valueFrom
{:configMapKeyRef
{:name "backup-config"
:key "restic-repository"}}}
{:name "RESTIC_PASSWORD_FILE"
:value "/var/run/secrets/backup-secrets/restic-password"}]
:volumeMounts
[{:name "nextcloud-data-volume"
:mountPath "/var/backups"}
{:name "backup-secret-volume"
:mountPath "/var/run/secrets/backup-secrets"
:readOnly true}]}]
:volumes
[{:name "nextcloud-data-volume"
:persistentVolumeClaim
{:claimName "cloud-pvc"}}
{:name "backup-secret-volume"
:secret
{:secretName "backup-secret"}}]
:restartPolicy "OnFailure"}}}}}}
:metadata {:name "cloud-backup", :labels {:app.kubernetes.part-of "cloud"}}
:spec
{:schedule "10 23 * * *"
:successfulJobsHistoryLimit 0
:failedJobsHistoryLimit 0
:jobTemplate
{:spec
{:template
{:spec
{:containers
[{:name "backup-app"
:image "domaindrivenarchitecture/meissa-cloud-backup"
:imagePullPolicy "IfNotPresent"
:command ["/entrypoint.sh"]
:env
[{:name "POSTGRES_USER_FILE", :value "/var/run/secrets/cloud-secrets/postgres-user"}
{:name "POSTGRES_DB_FILE", :value "/var/run/secrets/cloud-secrets/postgres-db"}
{:name "POSTGRES_PASSWORD_FILE", :value "/var/run/secrets/cloud-secrets/postgres-password"}
{:name "POSTGRES_HOST", :value "postgresql-service:5432"}
{:name "POSTGRES_SERVICE", :value "postgresql-service"}
{:name "POSTGRES_PORT", :value "5432"}
{:name "AWS_DEFAULT_REGION", :value "eu-central-1"}
{:name "AWS_ACCESS_KEY_ID_FILE", :value "/var/run/secrets/backup-secrets/aws-access-key-id"}
{:name "AWS_SECRET_ACCESS_KEY_FILE", :value "/var/run/secrets/backup-secrets/aws-secret-access-key"}
{:name "RESTIC_REPOSITORY", :valueFrom {:configMapKeyRef {:name "backup-config", :key "restic-repository"}}}
{:name "RESTIC_PASSWORD_FILE", :value "/var/run/secrets/backup-secrets/restic-password"}]
:volumeMounts
[{:name "cloud-data-volume", :mountPath "/var/backups"}
{:name "backup-secret-volume", :mountPath "/var/run/secrets/backup-secrets", :readOnly true}
{:name "cloud-secret-volume", :mountPath "/var/run/secrets/cloud-secrets", :readOnly true}]}]
:volumes
[{:name "cloud-data-volume", :persistentVolumeClaim {:claimName "cloud-pvc"}}
{:name "cloud-secret-volume", :secret {:secretName "cloud-secret"}}
{:name "backup-secret-volume", :secret {:secretName "backup-secret"}}]
:restartPolicy "OnFailure"}}}}}}
(cut/generate-cron))))

View file

@ -54,28 +54,33 @@
(cut/generate-persistent-volume {:nextcloud-data-volume-path "xx"}))))
(deftest should-generate-deployment
(is (= {:containers
[{:image "domaindrivenarchitecture/meissa-cloud-app"
:name "cloud-app"
:imagePullPolicy "IfNotPresent"
:ports [{:containerPort 80}]
:env
[{:name "DB_USERNAME_FILE"
:value
"/var/run/secrets/postgres-secret/postgres-user"}
{:name "DB_PASSWORD_FILE"
:value
"/var/run/secrets/postgres-secret/postgres-password"}
{:name "FQDN", :value "xx"}]
:command ["/app/entrypoint.sh"]
:volumeMounts
[{:mountPath "/var/nextcloud", :name "cloud-data-volume"}
{:name "postgres-secret-volume"
:mountPath "/var/run/secrets/postgres-secret"
:readOnly true}]}]
:volumes
[{:name "cloud-data-volume"
:persistentVolumeClaim {:claimName "cloud-pvc"}}
{:name "postgres-secret-volume"
:secret {:secretName "postgres-secret"}}]}
(get-in (cut/generate-deployment {:fqdn "xx"}) [:spec :template :spec]))))
(is (= {:apiVersion "apps/v1"
:kind "Deployment"
:metadata {:name "cloud"}
:spec
{:selector {:matchLabels {:app "cloud"}}
:strategy {:type "Recreate"}
:template
{:metadata {:labels {:app "cloud"}}
:spec
{:containers
[{:image "domaindrivenarchitecture/meissa-cloud-app"
:name "cloud-app"
:imagePullPolicy "IfNotPresent"
:ports [{:containerPort 80}]
:env
[{:name "NEXTCLOUD_ADMIN_USER_FILE", :value "/var/run/secrets/cloud-secrets/nextcloud-admin-user"}
{:name "NEXTCLOUD_ADMIN_PASSWORD_FILE", :value "/var/run/secrets/cloud-secrets/nextcloud-admin-password"}
{:name "NEXTCLOUD_TRUSTED_DOMAINS", :value "xx"}
{:name "POSTGRES_USER_FILE", :value "/var/run/secrets/cloud-secrets/postgres-user"}
{:name "POSTGRES_PASSWORD_FILE", :value "/var/run/secrets/cloud-secrets/postgres-password"}
{:name "POSTGRES_DB_FILE", :value "/var/run/secrets/cloud-secrets/postgres-db"}
{:name "POSTGRES_HOST", :value "postgresql-service:5432"}]
:volumeMounts
[{:name "cloud-data-volume", :mountPath "/var/www/html"}
{:name "cloud-secret-volume", :mountPath "/var/run/secrets/cloud-secrets", :readOnly true}]}]
:volumes
[{:name "cloud-data-volume", :persistentVolumeClaim {:claimName "cloud-pvc"}}
{:name "cloud-secret-volume", :secret {:secretName "cloud-secret"}}
{:name "backup-secret-volume", :secret {:secretName "backup-secret"}}]}}}}
(cut/generate-deployment {:fqdn "xx"}))))