Skip to content

Commit ee47035

Browse files
committed
test: fix test_mvcc_vinyl_tx_conflict
The patch changes the logic of the test. It makes the test more determined. The patch also adds comments into the test to make it easier to understand. Closes #104 Closes #105
1 parent e19fe51 commit ee47035

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

test/helper.lua

-3
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ t.before_suite(function()
201201
wal_dir = t.datadir,
202202
memtx_dir = t.datadir,
203203
vinyl_dir = t.datadir,
204-
-- vinyl_memory is changed to test test_mvcc_vinyl_tx_conflict.
205-
-- TODO: Commented out until tarantool/expirationd#105 is resolved.
206-
-- vinyl_memory = 1024,
207204
}
208205

209206
local tree_code = [[function(tuple)

test/unit/atomic_iteration_test.lua

+23-16
Original file line numberDiff line numberDiff line change
@@ -134,39 +134,46 @@ end
134134
-- just check expirationd task continue work after conflicts
135135
function g.test_mvcc_vinyl_tx_conflict(cg)
136136
t.skip_if(cg.params.engine ~= 'vinyl', 'Unsupported engine')
137-
-- TODO: Remove the line below when tarantool/expirationd#105 is resolved.
138-
t.skip('Skipped until tarantool/expirationd#105 is resolved')
137+
local tuples_cnt = 10
139138

140-
for i = 1,10 do
139+
for i = 1,tuples_cnt do
141140
cg.space:insert({i, tostring(i), nil, nil, 0})
142141
end
143142

144143
local updaters = {}
145-
for i = 1,10 do
146-
local updater = fiber.create(function()
144+
for i = 1,tuples_cnt do
145+
local updater = fiber.new(function()
147146
fiber.name(string.format("updater of %d", i), { truncate = true })
148-
while true do
149-
cg.space:update({i}, { {"+", 5, 1} })
150-
fiber.yield()
151-
end
147+
cg.space:update({i}, { {"+", 5, 1} })
152148
end)
149+
updater:set_joinable(true)
153150
table.insert(updaters, updater)
154151
end
155152

156-
local task = expirationd.start("clean_all", cg.space.id, helpers.is_expired_debug,
157-
{atomic_iteration = true})
153+
local is_expired = function(args, tuple)
154+
-- The idea is to switch explicity to an updater fiber in the middle of
155+
-- an expirationd's transaction:
156+
-- Delete from expirationd + update from an updater == conflict at the
157+
-- expirationd's transaction.
158+
fiber.yield()
159+
return helpers.is_expired_debug(args, tuple)
160+
end
158161

159-
-- wait for tuples expired
160-
fiber.sleep(3)
162+
helpers.iteration_result = {}
163+
local task = expirationd.start("clean_all", cg.space.id, is_expired,
164+
{atomic_iteration = true})
165+
-- ensure that expirationd task does not delete a tuple yet
166+
t.assert_equals(helpers.iteration_result, {})
161167

162-
for i = 1,10 do
163-
updaters[i]:cancel()
168+
for _, updater in pairs(updaters) do
169+
updater:join()
164170
end
165171

166172
helpers.retrying({}, function()
167173
t.assert_equals(cg.space:select(), {})
168174
end)
169-
t.assert(box.stat.vinyl().tx.conflict > 0)
175+
t.assert_gt(box.stat.vinyl().tx.conflict, 0)
176+
t.assert_gt(#helpers.iteration_result, tuples_cnt)
170177
t.assert_equals(box.stat.vinyl().tx.conflict, box.stat.vinyl().tx.rollback)
171178
t.assert_equals(box.stat.vinyl().tx.transactions, 0)
172179
task:kill()

0 commit comments

Comments
 (0)