Skip to content

Commit 9f5566f

Browse files
test: rework flaky vshard strategy test cases
Before this patch, retry in vshard call resulted in test fail since each case expects the exact count of API calls. It often had failed in repository CI and tarantool/tarantool integration CI (see [1], for example). 1. https://github.com/tarantool/tarantool/actions/runs/4222968119/attempts/6
1 parent 09b0ce2 commit 9f5566f

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

test/integration/read_calls_strategies_test.lua

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,21 @@ pgroup.before_all(function(g)
4444
g.cluster.main_server.net_box:call('clear_vshard_calls')
4545
end
4646

47-
g.get_vshard_calls = function()
48-
return g.cluster.main_server.net_box:eval('return _G.vshard_calls')
47+
g.get_vshard_call_strategies = function()
48+
-- Retries are possible, especially in CI, so we don't assert
49+
-- the quantity of calls, only strategies used.
50+
local vshard_calls = g.cluster.main_server.net_box:eval('return _G.vshard_calls')
51+
52+
local vshard_call_strategies_map = {}
53+
for _, v in ipairs(vshard_calls) do
54+
vshard_call_strategies_map[v] = true
55+
end
56+
57+
local vshard_call_strategies = {}
58+
for k, _ in pairs(vshard_call_strategies_map) do
59+
table.insert(vshard_call_strategies, k)
60+
end
61+
return vshard_call_strategies
4962
end
5063

5164
-- patch vshard.router.call* functions
@@ -69,8 +82,8 @@ pgroup.test_get = function(g)
6982
prefer_replica = g.params.prefer_replica
7083
}})
7184
t.assert_equals(err, nil)
72-
local vshard_calls = g.get_vshard_calls('call_single_impl')
73-
t.assert_equals(vshard_calls, {g.params.exp_vshard_call})
85+
local vshard_call_strategies = g.get_vshard_call_strategies('call_single_impl')
86+
t.assert_equals(vshard_call_strategies, {g.params.exp_vshard_call})
7487
end
7588

7689
pgroup.test_select = function(g)
@@ -82,8 +95,8 @@ pgroup.test_select = function(g)
8295
fullscan = true
8396
}})
8497
t.assert_equals(err, nil)
85-
local vshard_calls = g.get_vshard_calls('call_impl')
86-
t.assert_equals(vshard_calls, {g.params.exp_vshard_call, g.params.exp_vshard_call})
98+
local vshard_call_strategies = g.get_vshard_call_strategies('call_impl')
99+
t.assert_equals(vshard_call_strategies, {g.params.exp_vshard_call})
87100
end
88101

89102
pgroup.test_pairs = function(g)
@@ -102,8 +115,8 @@ pgroup.test_pairs = function(g)
102115
for _, _ in crud.pairs('customers', nil, opts) do end
103116
]], {opts})
104117
t.assert_equals(err, nil)
105-
local vshard_calls = g.get_vshard_calls('call_impl')
106-
t.assert_equals(vshard_calls, {g.params.exp_vshard_call, g.params.exp_vshard_call})
118+
local vshard_call_strategies = g.get_vshard_call_strategies('call_impl')
119+
t.assert_equals(vshard_call_strategies, {g.params.exp_vshard_call})
107120
end
108121

109122
pgroup.test_count = function(g)
@@ -115,6 +128,6 @@ pgroup.test_count = function(g)
115128
fullscan = true
116129
}})
117130
t.assert_equals(err, nil)
118-
local vshard_calls = g.get_vshard_calls('call_impl')
119-
t.assert_equals(vshard_calls, {g.params.exp_vshard_call, g.params.exp_vshard_call})
131+
local vshard_call_strategies = g.get_vshard_call_strategies('call_impl')
132+
t.assert_equals(vshard_call_strategies, {g.params.exp_vshard_call})
120133
end

0 commit comments

Comments
 (0)