From c08ceeacfb2a07abe5c0bb2a85a271baba4b7705 Mon Sep 17 00:00:00 2001 From: Yuji Ito Date: Wed, 24 Jul 2024 16:02:39 +0200 Subject: [PATCH] Custom configuration for ScalarDB tests (#128) --- scalardb/src/scalardb/core.clj | 15 +++++++++++++-- scalardb/src/scalardb/runner.clj | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scalardb/src/scalardb/core.clj b/scalardb/src/scalardb/core.clj index 2902b96..44d7564 100644 --- a/scalardb/src/scalardb/core.clj +++ b/scalardb/src/scalardb/core.clj @@ -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) @@ -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 diff --git a/scalardb/src/scalardb/runner.clj b/scalardb/src/scalardb/runner.clj index 5be70c4..b175cc0 100644 --- a/scalardb/src/scalardb/runner.clj +++ b/scalardb/src/scalardb/runner.clj @@ -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]