Skip to content

Commit

Permalink
test: default_tuple_drop_function
Browse files Browse the repository at this point in the history
Transferring the taptest to the luatest testing system with renaming the
tests and using the existing spaces in helpers.

Check that the default expiration function will work. After
expiration, there will be no tuples in the space.
All tuples will be deleted.

Updated test's name:

- default drop function test -> test_default_tuple_drop_function

Part of #61
  • Loading branch information
ArtDu committed Apr 10, 2023
1 parent ffcbe70 commit fc03fef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 42 deletions.
47 changes: 5 additions & 42 deletions test.lua
Expand Up @@ -274,14 +274,12 @@ init_box()
-- TAP TESTS:
-- 1. kill zombie test
-- 2. multiple expires test
-- 3. default drop function test
-- 4. restart test
-- 5. complex key test
-- 6. delays and scan callbacks test
-- 7. error callback test
-- 3. restart test
-- 4. complex key test
-- 5. delays and scan callbacks test
-- 6. error callback test
-- ========================================================================= --

test:plan(7)
test:plan(6)

test:test("zombie task kill", function(test)
test:plan(4)
Expand Down Expand Up @@ -379,41 +377,6 @@ test:test("multiple expires test", function(test)
expirationd.kill("test")
end)

test:test("default drop function test", function(test)
test:plan(2)
local tuples_count = 10
local space_name = 'drop_test'
local space = box.space[space_name]
for i = 1, tuples_count do
space:insert{i, 'test_data', fiber.time()}
end
test:is(space:count{}, tuples_count, 'tuples are in space')

expirationd.start(
"test",
space_name,
check_tuple_expire_by_timestamp,
{
args = {
field_no = 3,
archive_space_id = archive_space_id,
},
tuples_per_iteration = 10,
full_scan_time = 1,
}
)

local task = expirationd.task("test")
local res = wait_cond(
function()
return space:count{} == 0
end,
2
)
test:is(res, true, 'all tuples are expired with default function')
expirationd.kill("test")
end)

test:test("restart test", function(test)
test:plan(5)
local tuples_count = 10
Expand Down
30 changes: 30 additions & 0 deletions test/unit/expiration_process_test.lua
Expand Up @@ -212,3 +212,33 @@ function g.test_check_tuples_not_expired_by_timestamp(cg)
t.assert_equals(space_archive:count(), total)
end)
end

function g.test_default_tuple_drop_function(cg)
local space = cg.space
local task_name = cg.task_name
local space_archive = cg.space_archive

local total = 10
local time = fiber.time()
for i = 1, total do
space:insert({i, tostring(i), time})
end
-- Tuples are in space.
t.assert_equals(space:count{}, total)

cg.task = expirationd.start(task_name, space.id, check_tuple_expire_by_timestamp,
{
args = {
field_no = 3,
},
})
cg.total = total
local task = cg.task

-- All tuples are expired with default function.
helpers.retrying({}, function()
t.assert_equals(task.expired_tuples_count, total)
t.assert_equals(space_archive:count(), 0)
t.assert_equals(space:count{}, 0)
end)
end

0 comments on commit fc03fef

Please sign in to comment.