33local fun = require (' fun' )
44local log = require (' log' )
55local tap = require (' tap' )
6+ local yaml = require (' yaml' )
67local fiber = require (' fiber' )
78local strict = require (' strict' )
89local expirationd = require (' expirationd' )
5051-- Expiration handlers examples
5152-- ========================================================================= --
5253
54+ local function len (arg )
55+ local len = 0
56+ for k , v in pairs (arg ) do
57+ len = len + 1
58+ end
59+ return len
60+ end
61+
5362-- check tuple's expiration by timestamp (stored in last field)
5463local function check_tuple_expire_by_timestamp (args , tuple )
5564 local tuple_expire_time = get_field (tuple , args .field_no )
@@ -443,26 +452,40 @@ test:test("default drop function test", function(test)
443452end )
444453
445454test :test (" restart test" , function (test )
446- test :plan (3 )
455+ test :plan (5 )
447456 local tuples_count = 10
448457 local space_name = ' restart_test'
449458 local space = box .space [space_name ]
450459
451- local task = expirationd .run_task (
452- " test" ,
453- space_name ,
454- check_tuple_expire_by_timestamp ,
455- nil ,
456- {
457- field_no = 3 ,
458- archive_space_id = archive_space_id
459- },
460- 10 ,
461- 1
460+ local task1 = expirationd .run_task (
461+ " test1" , space_name , check_tuple_expire_by_timestamp ,
462+ nil , { field_no = 3 , archive_space_id = archive_space_id }, 10 , 1
463+ )
464+ local task2 = expirationd .run_task (
465+ " test2" , space_name , check_tuple_expire_by_timestamp ,
466+ nil , { field_no = 3 , archive_space_id = archive_space_id }, 10 , 1
467+ )
468+ local task3 = expirationd .run_task (
469+ " test3" , space_name , check_tuple_expire_by_timestamp ,
470+ nil , { field_no = 3 , archive_space_id = archive_space_id }, 10 , 1
471+ )
472+ local task4 = expirationd .run_task (
473+ " test4" , space_name , check_tuple_expire_by_timestamp ,
474+ nil , { field_no = 3 , archive_space_id = archive_space_id }, 10 , 1
462475 )
463476
477+ local fiber_cnt = len (fiber .info ())
464478 local old_expd = expirationd
465- expirationd .update ()
479+
480+ local chan = fiber .channel (1 )
481+ local fiber_update = fiber .create (function ()
482+ expirationd .update ()
483+ chan :put (1 )
484+ end )
485+ local ok , err = pcall (function () expirationd .start () end )
486+ test :like (err , " .*Wait until update is done.*" , " error while reloading" )
487+ chan :get ()
488+
466489 for i = 1 , tuples_count do
467490 space :insert {i , ' test_data' , fiber .time () + 1 }
468491 end
@@ -476,9 +499,13 @@ test:test("restart test", function(test)
476499 fiber .sleep (4 )
477500 test :is (space :count {}, 0 , ' all tuples are expired' )
478501
479- task :statistics ()
502+ task1 :statistics ()
503+ test :is (fiber_cnt , len (fiber .info ()), " check for absence of ghost fibers" )
480504
481- expirationd .kill_task (" test" )
505+ expirationd .kill_task (" test1" )
506+ expirationd .kill_task (" test2" )
507+ expirationd .kill_task (" test3" )
508+ expirationd .kill_task (" test4" )
482509end )
483510
484511test :test (" complex key test" , function (test )
0 commit comments