Compare commits

..

No commits in common. "2e39383a041ba31c944bd7e814ed955c32e3276e" and "e0e59e26206836ccf54da4e1a64dd774e7474f0c" have entirely different histories.

12 changed files with 40 additions and 31 deletions

View file

@ -9,10 +9,9 @@
;; ---------------------------------------------------------
:deps
{;; Application
;;org.clojure/clojure {:mvn/version "1.11.4"}
org.clojure/spec.alpha {:mvn/version "0.5.238"}
;; org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
;; :git/sha "644a7fc216e43d5da87b07471b0f87d874107d1a"}
org.clojure/clojure {:mvn/version "1.11.4"}
org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "79e7daaead944583eece42ff5665be208d019861"}
orchestra/orchestra {:mvn/version "2021.01.01-1"}
babashka/babashka.curl {:mvn/version "0.1.2"}}
;; ---------------------------------------------------------
@ -29,8 +28,7 @@
;; call with :watch? true to start file watcher and re-run tests on saved changes
:test/run
{:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}
expound/expound {:mvn/version "0.9.0"}}
:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:main-opts ["-m" "kaocha.runner"]
:exec-fn kaocha.runner/exec-fn
:exec-args {:randomize? false

View file

@ -3,7 +3,6 @@
[clojure.spec.alpha :as s]))
(s/def ::command (s/cat
:opts (s/? map?)
:app string?
:params (s/* string?)))
(s/def ::commands (s/coll-of ::command))

View file

@ -1,15 +1,17 @@
(ns dda.backup.monitoring.domain
(:require
[dda.backup.restic.domain :as rd]
[dda.backup.monitoring.element :as e]
[orchestra.core :refer [defn-spec]]
[clojure.spec.alpha :as s]))
(s/def ::type #{"gauge"})
(s/def ::value (s/+ ::e/metric-element))
(s/def ::labels map?)
(s/def ::metric-value pos?)
(s/def ::metric-element (s/keys :req-un [::labels ::metric-value]))
(s/def ::value (s/+ ::metric-element))
(s/def ::metric (s/keys :req-un [::type
::value]))
(s/def ::backup-size (s/spec ::e/value))
(s/def ::backup-size (s/spec ::metric-value))
(s/def ::docstring string?)
(s/def ::__name__ string?)

View file

@ -1,7 +0,0 @@
(ns dda.backup.monitoring.element
(:require
[clojure.spec.alpha :as s]))
(s/def ::labels map?)
(s/def ::value pos?)
(s/def ::metric-element (s/keys :req-un [::labels ::value]))

View file

@ -30,11 +30,9 @@
(s/merge ::pg-config
::rd/restic-config))
(s/def ::pg-command (s/* string?))
(defn-spec psql-command ::cd/command
[config ::pg-config
command ::pg-command]
command ::cd/command]
(let [{:keys [pg-host pg-port pg-db pg-user]} config]
(into
["psql" "-d" pg-db "-h" pg-host "-p" (str pg-port) "-U" pg-user
@ -43,7 +41,7 @@
(defn-spec pgdumpall-command ::cd/command
[config ::pg-role-dump-config
command ::pg-command]
command ::cd/command]
(let [{:keys [pg-host pg-port pg-user pg-role-prefix]} config]
(into
[]
@ -56,7 +54,7 @@
(defn-spec pgdump-command ::cd/command
[config ::pg-db-dump-config
command ::pg-command]
command ::cd/command]
(let [{:keys [pg-host pg-port pg-db pg-user]} config]
(into
[]

View file

@ -1,8 +1,13 @@
(ns dda.backup.backup.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.backup.domain :as cut]))
(st/instrument `cut/backup-files-command)
(st/instrument `cut/backup-role-command)
(st/instrument `cut/backup-db-command)
(deftest should-calculate-backup-files-command
(is (= [[{:dir "dir-to-backup"}
"restic"

View file

@ -6,13 +6,7 @@
(deftest should-verify-command
(is (= {:app "restic", :params ["-r" "repo/dir" "-v" "init" "--cacert" "ca"]}
(s/conform ::cut/command ["restic" "-r" "repo/dir" "-v" "init" "--cacert" "ca"])))
(is (= {:app "restic"}
(s/conform ::cut/command ["restic"])))
(is (= {:opts {:dir "dir"} :app "restic", :params ["-r" "repo/dir" "-v" "init" "--cacert" "ca"]}
(s/conform ::cut/command [{:dir "dir"} "restic" "-r" "repo/dir" "-v" "init" "--cacert" "ca"])))
(is (= {:opts {:dir "dir"} :app "restic"}
(s/conform ::cut/command [{:dir "dir"} "restic"]))))
(s/conform ::cut/command ["restic" "-r" "repo/dir" "-v" "init" "--cacert" "ca"]))))
(deftest should-verify-commands
(is (= [{:app "ls"}

View file

@ -1,6 +1,7 @@
(ns dda.backup.monitoring.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.monitoring.domain :as cut]))
(deftest should-generate-monitoring-data

View file

@ -1,8 +1,13 @@
(ns dda.backup.postgresql.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.postgresql.domain :as cut]))
(st/instrument `cut/pgpass)
(st/instrument `cut/db-drop-command)
(st/instrument `cut/db-create-command)
(deftest should-calculate-pgpass
(is (= "localhost:5432:mydb:user:password\nlocalhost:5432:template1:user:password\n"
(cut/pgpass {:restic-repository "repo"

View file

@ -1,7 +1,7 @@
(ns dda.backup.restic.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[orchestra.spec.test :as st]
[clojure.spec.test.alpha :as st]
[dda.backup.restic.domain :as cut]))
(st/instrument `cut/repo-command)

View file

@ -1,8 +1,12 @@
(ns dda.backup.restore.domain-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[dda.backup.restore.domain :as cut]))
(st/instrument `cut/restore-dir-command)
(st/instrument `cut/restore-db-command)
(deftest should-calculate-restore-dir
(is (= [["rm" "-rf" "dir-to-backup"]
["restic"

View file

@ -10,6 +10,16 @@
;; ---------------------------------------------------------
#kaocha/v1 {:plugins [:orchestra]
#kaocha/v1 {:plugins [:orchestra
:kaocha.plugin.alpha/info
:profiling
:print-invocations
:hooks
:notifier
:kaocha.plugin/version-filter]
:kaocha/bindings {kaocha.stacktrace/*stacktrace-filters* []
kaocha.stacktrace/*stacktrace-stop-list* []}
:reporter kaocha.report/documentation}