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

View file

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