From 188794eefc3f8a04164e8e25d18d876dc1fb76e1 Mon Sep 17 00:00:00 2001 From: yito88 Date: Thu, 31 Oct 2024 22:15:39 +0100 Subject: [PATCH] seq exec read txs --- scalardb/src/scalardb/transfer.clj | 5 +---- scalardb/test/scalardb/transfer_2pc_test.clj | 18 +++++------------- scalardb/test/scalardb/transfer_test.clj | 17 +++++------------ 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/scalardb/src/scalardb/transfer.clj b/scalardb/src/scalardb/transfer.clj index b526113..bc00d67 100644 --- a/scalardb/src/scalardb/transfer.clj +++ b/scalardb/src/scalardb/transfer.clj @@ -156,10 +156,7 @@ [test n] (scalar/check-transaction-connection! test) (scalar/check-storage-connection! test) - (try - (doall (pmap #(read-record-with-retry test %) (range n))) - ;; unwrap the exception - (catch java.util.concurrent.ExecutionException e (throw (.getCause e))))) + (doall (map #(read-record-with-retry test %) (range n)))) (defrecord TransferClient [initialized? n initial-balance max-txs] client/Client diff --git a/scalardb/test/scalardb/transfer_2pc_test.clj b/scalardb/test/scalardb/transfer_2pc_test.clj index 485d1e5..6ad953b 100644 --- a/scalardb/test/scalardb/transfer_2pc_test.clj +++ b/scalardb/test/scalardb/transfer_2pc_test.clj @@ -227,26 +227,18 @@ scalar/prepare-transaction-service! (spy/spy) scalar/prepare-storage-service! (spy/spy) scalar/start-transaction (spy/stub mock-transaction-throws-exception)] - (let [num-accounts 5 - client (client/open! (transfer-2pc/->TransferClient (atom false) - num-accounts - 100 1) - nil nil) - retries-reconnection (* num-accounts - (+ (quot scalar/RETRIES - scalar/RETRIES_FOR_RECONNECTION) - 1))] + (let [client (client/open! (transfer-2pc/->TransferClient (atom false) 5 100 1) + nil nil)] (is (thrown? clojure.lang.ExceptionInfo (client/invoke! client {:db mock-db :storage (ref mock-storage)} (#'transfer/get-all {:client client} nil)))) - (is (spy/called-n-times? scalar/exponential-backoff - (* scalar/RETRIES num-accounts))) + (is (spy/called-n-times? scalar/exponential-backoff scalar/RETRIES)) (is (spy/called-n-times? scalar/prepare-transaction-service! - retries-reconnection)) + (+ (quot scalar/RETRIES scalar/RETRIES_FOR_RECONNECTION) 1))) (is (spy/called-n-times? scalar/prepare-storage-service! - retries-reconnection))))) + (+ (quot scalar/RETRIES scalar/RETRIES_FOR_RECONNECTION) 1)))))) (deftest transfer-client-check-tx-test (with-redefs [scalar/check-transaction-states (spy/stub 1)] diff --git a/scalardb/test/scalardb/transfer_test.clj b/scalardb/test/scalardb/transfer_test.clj index f9e2e2c..b750c60 100644 --- a/scalardb/test/scalardb/transfer_test.clj +++ b/scalardb/test/scalardb/transfer_test.clj @@ -197,25 +197,18 @@ scalar/prepare-transaction-service! (spy/spy) scalar/prepare-storage-service! (spy/spy) scalar/start-transaction (spy/stub mock-transaction-throws-exception)] - (let [num-accounts 5 - client (client/open! (transfer/->TransferClient (atom false) - num-accounts 100 1) - nil nil) - retries-reconnection (* num-accounts - (+ (quot scalar/RETRIES - scalar/RETRIES_FOR_RECONNECTION) - 1))] + (let [client (client/open! (transfer/->TransferClient (atom false) 5 100 1) + nil nil)] (is (thrown? clojure.lang.ExceptionInfo (client/invoke! client {:db mock-db :storage (ref mock-storage)} (#'transfer/get-all {:client client} nil)))) - (is (spy/called-n-times? scalar/exponential-backoff - (* scalar/RETRIES num-accounts))) + (is (spy/called-n-times? scalar/exponential-backoff scalar/RETRIES)) (is (spy/called-n-times? scalar/prepare-transaction-service! - retries-reconnection)) + (+ (quot scalar/RETRIES scalar/RETRIES_FOR_RECONNECTION) 1))) (is (spy/called-n-times? scalar/prepare-storage-service! - retries-reconnection))))) + (+ (quot scalar/RETRIES scalar/RETRIES_FOR_RECONNECTION) 1)))))) (deftest transfer-client-check-tx-test (with-redefs [scalar/check-transaction-states (spy/stub 1)]