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
{: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 :volumeMounts
[{:name "nextcloud-data-volume" [{:name "cloud-data-volume", :mountPath "/var/backups"}
:mountPath "/var/backups"} {:name "backup-secret-volume", :mountPath "/var/run/secrets/backup-secrets", :readOnly true}
{:name "backup-secret-volume" {:name "cloud-secret-volume", :mountPath "/var/run/secrets/cloud-secrets", :readOnly true}]}]
:mountPath "/var/run/secrets/backup-secrets"
:readOnly true}]}]
:volumes :volumes
[{:name "nextcloud-data-volume" [{:name "cloud-data-volume", :persistentVolumeClaim {:claimName "cloud-pvc"}}
:persistentVolumeClaim {:name "cloud-secret-volume", :secret {:secretName "cloud-secret"}}
{:claimName "cloud-pvc"}} {:name "backup-secret-volume", :secret {:secretName "backup-secret"}}]
{:name "backup-secret-volume"
:secret
{:secretName "backup-secret"}}]
:restartPolicy "OnFailure"}}}}}} :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"
: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" [{:image "domaindrivenarchitecture/meissa-cloud-app"
:name "cloud-app" :name "cloud-app"
:imagePullPolicy "IfNotPresent" :imagePullPolicy "IfNotPresent"
:ports [{:containerPort 80}] :ports [{:containerPort 80}]
:env :env
[{:name "DB_USERNAME_FILE" [{:name "NEXTCLOUD_ADMIN_USER_FILE", :value "/var/run/secrets/cloud-secrets/nextcloud-admin-user"}
:value {:name "NEXTCLOUD_ADMIN_PASSWORD_FILE", :value "/var/run/secrets/cloud-secrets/nextcloud-admin-password"}
"/var/run/secrets/postgres-secret/postgres-user"} {:name "NEXTCLOUD_TRUSTED_DOMAINS", :value "xx"}
{:name "DB_PASSWORD_FILE" {:name "POSTGRES_USER_FILE", :value "/var/run/secrets/cloud-secrets/postgres-user"}
:value {:name "POSTGRES_PASSWORD_FILE", :value "/var/run/secrets/cloud-secrets/postgres-password"}
"/var/run/secrets/postgres-secret/postgres-password"} {:name "POSTGRES_DB_FILE", :value "/var/run/secrets/cloud-secrets/postgres-db"}
{:name "FQDN", :value "xx"}] {:name "POSTGRES_HOST", :value "postgresql-service:5432"}]
:command ["/app/entrypoint.sh"]
:volumeMounts :volumeMounts
[{:mountPath "/var/nextcloud", :name "cloud-data-volume"} [{:name "cloud-data-volume", :mountPath "/var/www/html"}
{:name "postgres-secret-volume" {:name "cloud-secret-volume", :mountPath "/var/run/secrets/cloud-secrets", :readOnly true}]}]
:mountPath "/var/run/secrets/postgres-secret"
:readOnly true}]}]
:volumes :volumes
[{:name "cloud-data-volume" [{:name "cloud-data-volume", :persistentVolumeClaim {:claimName "cloud-pvc"}}
:persistentVolumeClaim {:claimName "cloud-pvc"}} {:name "cloud-secret-volume", :secret {:secretName "cloud-secret"}}
{:name "postgres-secret-volume" {:name "backup-secret-volume", :secret {:secretName "backup-secret"}}]}}}}
:secret {:secretName "postgres-secret"}}]} (cut/generate-deployment {:fqdn "xx"}))))
(get-in (cut/generate-deployment {:fqdn "xx"}) [:spec :template :spec]))))