Skip to content

Commit 6e4f54a

Browse files
committed
bank*: distribute initial balances uniformly
Before this commit the initial distribution was the following: first account has `total-amount` balances, other 9 ones have zero balance. From time to time is appears that there are no attempts to transfer from the first account. It means that all transfers are marked as failed and the history analysis reports fail. Even when there are some successful transfers, there are many attempts to transfer from an account with zero balance: those transfers are useless in terms of tarantool testing. This commit changes the initial distribution to the uniform one and resolves the problems, which are described above. See the linked issue for details. Aside of the problematic bank-lua I changed other banking tests in the same way to unify the approach. How each test is changed: * bank-lua: [100 0 0 0 0 0 0 0 0 0] -> [10 10 10 10 10 10 10 10 10 10]. * bank-multitable-lua: the test already distributes initial balances uniformly, but hardcodes balance value. Now it is deduced from the `total-amount` parameter. * bank: same as bank-lua. * bank-multitable: same as bank-lua. 'bank' and 'bank-multitable' fixes are blind, because they're disabled. See #83. 'bank-lua' and 'bank-multitable-lua' are passed in a manual run. 'bank-lua' gives 2-3 failed transfers of ~40 ones. Before it was like 5-15 *successful* ones of 30-40. (I have no representative statistics, just looked over several runs in CI, but the numbers looks expected.) Fixes #94
1 parent 92eadd7 commit 6e4f54a

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

src/tarantool/bank.clj

+29-17
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
balance INT NOT NULL)")])
3838
(doseq [a (:accounts test)]
3939
(info "Populating account")
40-
(sql/insert! conn table-name {:id a
41-
:balance (if (= a (first (:accounts test)))
42-
(:total-amount test)
43-
0)}))))
40+
; Distribute initial balances uniformly.
41+
(let [initial-balance (/ (:total-amount test)
42+
(count (:accounts test)))]
43+
(sql/insert! conn table-name
44+
{:id a
45+
:balance initial-balance})))))
46+
4447
(assoc this :conn conn :node node))))
4548

4649
(invoke! [this test op]
@@ -91,10 +94,14 @@
9194
"account_id INT NOT NULL,"
9295
"balance INT NOT NULL)")])
9396
(info "Populating account" a)
94-
(sql/insert! conn (str table-name a)
95-
{:id 0
96-
:account_id a
97-
:balance 10})))))
97+
; Distribute initial balances uniformly.
98+
(let [initial-balance (/ (:total-amount test)
99+
(count (:accounts test)))]
100+
(sql/insert! conn (str table-name a)
101+
{:id 0
102+
:account_id a
103+
:balance initial-balance}))))))
104+
98105
(assoc this :conn conn :node node))))
99106

100107
(invoke! [this test op]
@@ -157,10 +164,13 @@
157164
balance INT NOT NULL)")])
158165
(doseq [a (:accounts test)]
159166
(info "Populating account")
160-
(sql/insert! conn table-name {:id a
161-
:balance (if (= a (first (:accounts test)))
162-
(:total-amount test)
163-
0)}))))
167+
; Distribute initial balances uniformly.
168+
(let [initial-balance (/ (:total-amount test)
169+
(count (:accounts test)))]
170+
(sql/insert! conn table-name
171+
{:id a
172+
:balance initial-balance})))))
173+
164174
(assoc this :conn conn :node node))))
165175

166176
(invoke! [this test op]
@@ -220,11 +230,13 @@
220230
"(id INT NOT NULL PRIMARY KEY,"
221231
"balance INT NOT NULL)")])
222232
(info "Populating account" a)
223-
(sql/insert! conn (str table-name a)
224-
{:id 0
225-
:balance (if (= a (first (:accounts test)))
226-
(:total-amount test)
227-
0)})))))
233+
; Distribute initial balances uniformly.
234+
(let [initial-balance (/ (:total-amount test)
235+
(count (:accounts test)))]
236+
(sql/insert! conn (str table-name a)
237+
{:id 0
238+
:balance initial-balance}))))))
239+
228240
(assoc this :conn conn :node node))))
229241

230242
(invoke! [this test op]

0 commit comments

Comments
 (0)