Skip to content

Commit

Permalink
Custom configuration for ScalarDB tests (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 authored Jul 24, 2024
1 parent 92d2434 commit c08ceea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions scalardb/src/scalardb/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
(com.scalar.db.schemaloader SchemaLoader)
(com.scalar.db.service TransactionFactory
StorageFactory)
(com.scalar.db.transaction.consensuscommit Coordinator)))
(com.scalar.db.transaction.consensuscommit Coordinator)
(java.io FileInputStream)
(java.util Properties)))

(def ^:const RETRIES 8)
(def ^:const RETRIES_FOR_RECONNECTION 3)
Expand Down Expand Up @@ -78,9 +80,18 @@
:primary-key [:tx_id]}})
(cassandra/close-cassandra cluster session)))

(defn- load-config
[test]
(when-let [path (and (seq (:config-file test)) (:config-file test))]
(let [props (Properties.)]
(with-open [stream (FileInputStream. path)]
(.load props stream))
props)))

(defn setup-transaction-tables
[test schemata]
(let [properties (ext/create-properties (:db test) test)
(let [properties (or (load-config test)
(ext/create-properties (:db test) test))
options (ext/create-table-opts (:db test) test)]
(if (= (.getProperty properties "scalar.db.username") "cassandra")
;; Workaround the issue of the schema loader for Cassandra
Expand Down
5 changes: 4 additions & 1 deletion scalardb/src/scalardb/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@

(cli/repeated-opt nil "--consistency-model CONSISTENCY_MODEL"
"consistency model to be checked"
["snapshot-isolation"])])
["snapshot-isolation"])

[nil "--config-file CONFIG_FILE" "ScalarDB config file. When this is given, other configuration options are ignored."
:default ""]])

(defn- test-name
[workload-key faults admin]
Expand Down

0 comments on commit c08ceea

Please sign in to comment.