|
53 | 53 |
|
54 | 54 | :imagePullSecrets [{:name "scalardb-ghcr-secret"}]}}) |
55 | 55 |
|
| 56 | +(defn- throw-unsupported-db-error |
| 57 | + [db-type] |
| 58 | + (throw (ex-info "Unsupported DB for ScalarDB Cluster test" {:db db-type}))) |
| 59 | + |
56 | 60 | (defn- update-cluster-values |
57 | 61 | [test values] |
58 | 62 | (let [path [:scalardbCluster :scalardbClusterNodeProperties] |
|
91 | 95 | (case db-type |
92 | 96 | :postgres (c/exec :helm :repo :add |
93 | 97 | "bitnami" "https://charts.bitnami.com/bitnami") |
94 | | - (throw (ex-info "Unsupported DB for ScalarDB Cluster" {:db db-type}))) |
| 98 | + (throw-unsupported-db-error db-type)) |
95 | 99 | ;; ScalarDB cluster |
96 | 100 | (c/exec :helm :repo :add |
97 | 101 | "scalar-labs" "https://scalar-labs.github.io/helm-charts") |
|
102 | 106 |
|
103 | 107 | (defn- configure! |
104 | 108 | [] |
105 | | - (binding [c/*dir* (System/getProperty "user.dir")] |
106 | | - (try |
107 | | - (c/exec :kubectl :delete :secret "scalardb-ghcr-secret") |
| 109 | + (when (and (seq (env :docker-username)) (seq (env :docker-access-token))) |
| 110 | + (binding [c/*dir* (System/getProperty "user.dir")] |
| 111 | + (try |
| 112 | + (c/exec :kubectl :delete :secret "scalardb-ghcr-secret") |
108 | 113 | ;; ignore the failure when the secret doesn't exist |
109 | | - (catch Exception _)) |
110 | | - (c/exec :kubectl :create :secret :docker-registry "scalardb-ghcr-secret" |
111 | | - "--docker-server=ghcr.io" |
112 | | - (str "--docker-username=" (env :docker-username)) |
113 | | - (str "--docker-password=" (env :docker-access-token)))) |
| 114 | + (catch Exception _)) |
| 115 | + (c/exec :kubectl :create :secret :docker-registry "scalardb-ghcr-secret" |
| 116 | + "--docker-server=ghcr.io" |
| 117 | + (str "--docker-username=" (env :docker-username)) |
| 118 | + (str "--docker-password=" (env :docker-access-token))))) |
114 | 119 |
|
115 | 120 | ;; Chaos Mesh |
116 | 121 | (try |
|
134 | 139 | :--set "metrics.image.repository=bitnamilegacy/postgres-exporter" |
135 | 140 | :--set "global.security.allowInsecureImages=true" |
136 | 141 | :--version "16.7.0") |
137 | | - (throw (ex-info "Unsupported DB for ScalarDB Cluster" {:db db-type}))) |
| 142 | + (throw-unsupported-db-error db-type)) |
138 | 143 |
|
139 | 144 | ;; ScalarDB Cluster |
140 | 145 | (let [chart-version (or (some-> (env :helm-chart-version) not-empty) |
|
170 | 175 | (apply c/exec :rm :-f)) |
171 | 176 | (catch Exception _ nil))) |
172 | 177 | (info "wiping the pods...") |
173 | | - (try (c/exec :helm :uninstall POSTGRESQL_NAME) (catch Exception _ nil)) |
174 | | - (try (c/exec :kubectl :delete |
175 | | - :pvc :-l "app.kubernetes.io/instance=postgresql-scalardb-cluster") |
176 | | - (catch Exception _ nil)) |
177 | | - (try (c/exec :helm :uninstall CLUSTER_NAME) (catch Exception _ nil)) |
178 | | - (try (c/exec :helm :uninstall CLUSTER2_NAME) (catch Exception _ nil)) |
179 | | - (try (c/exec :helm :uninstall "chaos-mesh" :-n "chaos-mesh") |
180 | | - (catch Exception _ nil))) |
| 178 | + (doseq [cmd [[:helm :uninstall POSTGRESQL_NAME] |
| 179 | + [:kubectl :delete |
| 180 | + :pvc :-l "app.kubernetes.io/instance=postgresql-scalardb-cluster"] |
| 181 | + [:helm :uninstall CLUSTER_NAME] |
| 182 | + [:helm :uninstall CLUSTER2_NAME] |
| 183 | + [:helm :uninstall "chaos-mesh" :-n "chaos-mesh"]]] |
| 184 | + (try (apply c/exec cmd) (catch Exception _ nil)))) |
181 | 185 |
|
182 | 186 | (defn- get-pod-list |
183 | 187 | [name] |
|
313 | 317 | (str "jdbc:postgresql://" ip ":5432/postgres")) |
314 | 318 | (.setProperty "scalar.db.username" "postgres") |
315 | 319 | (.setProperty "scalar.db.password" "postgres"))) |
316 | | - (throw (ex-info "Unsupported DB for ScalarDB Cluster" |
317 | | - {:db db-type})))))) |
| 320 | + (throw-unsupported-db-error db-type))))) |
318 | 321 |
|
319 | 322 | (defn gen-db |
320 | 323 | [faults admin db-type] |
|
0 commit comments