• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / expirationd / 5115098733

pending completion
5115098733

push

github

web-flow
Merge b179ea619 into 455d4364a

58 of 58 new or added lines in 1 file covered. (100.0%)

5754 of 6044 relevant lines covered (95.2%)

11.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.28
/test/unit/update_and_kill_test.lua
1
local fiber = require("fiber")
2
local t = require("luatest")
3

4
local helpers = require("test.helper")
5

6
local g = t.group('update_and_kill', {
7
    {index_type = 'TREE', engine = 'vinyl'},
8
    {index_type = 'TREE', engine = 'memtx'},
9
    {index_type = 'HASH', engine = 'memtx'},
10
})
11

12
g.before_each({index_type = 'TREE'}, function(cg)
13
    t.skip_if(cg.params.engine == 'vinyl' and not helpers.vinyl_is_supported(),
14
        'Blocked by https://github.com/tarantool/tarantool/issues/6448')
15
    cg.first_space = helpers.create_space_with_tree_index(cg.params.engine)
16
    local second_space = helpers.create_space('second_space', cg.params.engine)
17
    second_space:create_index('primary')
18
    cg.second_space = second_space
19
end)
20

21
g.before_each({index_type = 'HASH'}, function(cg)
22
    cg.first_space = helpers.create_space_with_hash_index(cg.params.engine)
23
    local second_space = helpers.create_space('second_space', cg.params.engine)
24
    second_space:create_index('primary', {type = 'HASH'})
25
    cg.second_space = second_space
26
end)
27

28
g.after_each(function(cg)
29
    if cg.task ~= nil then
30
        cg.task:kill()
31
    end
32
    cg.first_space:drop()
33
    cg.second_space:drop()
34
end)
35

36
function g.test_expirationd_update(cg)
37
    local first_space = cg.first_space
38
    local second_space = cg.second_space
39

40
    local first_expd_link = require("expirationd")
41

42
    -- Start tasks by first expirationd link.
43
    local first_expd_tasks_cnt = 4
44
    local first_expd_task_name_prefix = "first_"
45
    for i = 1, first_expd_tasks_cnt do
46
        first_expd_link.start(first_expd_task_name_prefix .. i, first_space.id, helpers.is_expired_true)
47
    end
48

49
    -- Check updating in progress message.
50
    local chan = fiber.channel(1)
51
    fiber.create(function()
52
        first_expd_link.update()
53
        chan:put(1)
54
    end)
55
    local _, err = pcall(function() first_expd_link.start() end)
56
    t.assert_str_contains(err, "Wait until update is done")
57
    chan:get()
58

59
    -- Check that links are not equals.
60
    local second_expd_link = require("expirationd")
61
    t.assert_not_equals(
62
        tostring(first_expd_link):match("0x.*"),
63
        tostring(second_expd_link):match("0x.*"))
64

65
    -- Start tasks by second expirationd link.
66
    local second_expd_tasks_cnt = 4
67
    local second_expd_task_name_prefix = "second_"
68
    for i = 1, second_expd_tasks_cnt do
69
        second_expd_link.start(second_expd_task_name_prefix .. i, second_space.id, helpers.is_expired_true)
70
    end
71

72
    -- Check that we have all tasks be shared between both tasks.
73
    t.assert_equals(first_expd_link.tasks(), second_expd_link.tasks())
74

75
    -- And tasks work correctly.
76
    for _, space in pairs({first_space, second_space}) do
77
        local total = 10
78
        for i = 1, total do
79
            space:insert({i, tostring(i)})
80
        end
81

82
        t.assert_equals(space:count(), total)
83
        helpers.retrying({}, function()
84
            t.assert_equals(space:count(), 0)
85
        end)
86
    end
87

88
    for _, task_name in pairs(second_expd_link.tasks()) do
89
        second_expd_link.kill(task_name)
90
    end
91

92
    -- Back old link in require. It's necessary to avoid problem of double update call.
93
    -- The problem that we can't use old link properly after double update.
94
    -- Old link wouldn't see new tasks which were started by new link. That could happen without this line.
95
    -- Expirationd module changes only one previous link that stores in package.loaded.
96
    package.loaded["expirationd"] = first_expd_link
97
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc