@@ -19,6 +19,12 @@ local server_opts = {
1919 }
2020}
2121
22+ local function require_declarative_configuration ()
23+ t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
24+ [[ Declarative configuration works on Tarantool 3.0.0+.
25+ See tarantool/tarantool@13149d65bc9d for details]] )
26+ end
27+
2228local function assert_instance_running (c , instance , replicaset )
2329 local server = c [instance ]
2430 t .assert (type (server ) == ' table' )
@@ -45,9 +51,7 @@ g.test_start_stop = function()
4551 t .assert_equals (server :eval (' return box.info.ro' ), is_ro )
4652 end
4753
48- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
49- [[ Declarative configuration works on Tarantool 3.0.0+.
50- See tarantool/tarantool@13149d65bc9d for details]] )
54+ require_declarative_configuration ()
5155
5256 local config = cbuilder :new ()
5357 :use_group (' group-a' )
@@ -88,9 +92,7 @@ g.test_start_stop = function()
8892end
8993
9094g .test_start_instance = function ()
91- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
92- [[ Declarative configuration works on Tarantool 3.0.0+.
93- See tarantool/tarantool@13149d65bc9d for details]] )
95+ require_declarative_configuration ()
9496
9597 t .assert_equals (g .cluster , nil )
9698
@@ -122,10 +124,34 @@ g.test_start_instance = function()
122124 assert_instance_stopped (c , ' i-002' )
123125end
124126
127+ g .test_manual_lifecycle = function ()
128+ require_declarative_configuration ()
129+
130+ local config = cbuilder :new ()
131+ :use_group (' cluster' )
132+ :use_replicaset (' cluster-rs' )
133+ :add_instance (' cluster-1' , {})
134+ :config ()
135+
136+ local c1 = cluster :new (config , server_opts , {auto_cleanup = false })
137+
138+ t .assert_equals (g ._cluster , nil )
139+
140+ c1 :start ()
141+ assert_instance_running (c1 , ' cluster-1' )
142+ c1 :drop ()
143+
144+ local c2 = cluster :new (config , server_opts , {auto_cleanup = false })
145+
146+ t .assert_equals (g ._cluster , nil )
147+
148+ c2 :start ()
149+ assert_instance_running (c2 , ' cluster-1' )
150+ c2 :drop ()
151+ end
152+
125153g .test_sync = function ()
126- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
127- [[ Declarative configuration works on Tarantool 3.0.0+.
128- See tarantool/tarantool@13149d65bc9d for details]] )
154+ require_declarative_configuration ()
129155
130156 t .assert_equals (g ._cluster , nil )
131157
@@ -186,9 +212,7 @@ g.test_sync = function()
186212end
187213
188214g .test_sync_start_stop = function ()
189- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
190- [[ Declarative configuration works on Tarantool 3.0.0+.
191- See tarantool/tarantool@13149d65bc9d for details]] )
215+ require_declarative_configuration ()
192216
193217 t .assert_equals (g ._cluster , nil )
194218
@@ -235,9 +259,7 @@ g.test_sync_start_stop = function()
235259end
236260
237261g .test_reload = function ()
238- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
239- [[ Declarative configuration works on Tarantool 3.0.0+.
240- See tarantool/tarantool@13149d65bc9d for details]] )
262+ require_declarative_configuration ()
241263
242264 local function assert_instance_failover_mode (c , instance , mode )
243265 local server = c ._server_map [instance ]
@@ -279,9 +301,7 @@ g.test_reload = function()
279301end
280302
281303g .test_each = function ()
282- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
283- [[ Declarative configuration works on Tarantool 3.0.0+.
284- See tarantool/tarantool@13149d65bc9d for details]] )
304+ require_declarative_configuration ()
285305
286306 local config = cbuilder :new ()
287307 :use_group (' g-001' )
@@ -305,9 +325,7 @@ g.test_each = function()
305325end
306326
307327g .test_startup_error = function ()
308- t .run_only_if (utils .version_current_ge_than (3 , 0 , 0 ),
309- [[ Declarative configuration works on Tarantool 3.0.0+.
310- See tarantool/tarantool@13149d65bc9d for details]] )
328+ require_declarative_configuration ()
311329
312330 local config = cbuilder :new ()
313331 :use_group (' g-001' )
@@ -318,3 +336,51 @@ g.test_startup_error = function()
318336
319337 cluster :startup_error (config , ' No such file' )
320338end
339+
340+ local g_persistent_clusters = t .group (' persistent_clusters' )
341+
342+ g_persistent_clusters .before_all (function ()
343+ require_declarative_configuration ()
344+
345+ g_persistent_clusters .instances = {}
346+ g_persistent_clusters .pids = {}
347+
348+ for i = 1 , 3 do
349+ local index = tostring (i )
350+ local instance = ' persistent-' .. index .. ' -1'
351+ local config = cbuilder :new ()
352+ :use_group (' persistent-group-' .. index )
353+ :use_replicaset (' persistent-rs-' .. index )
354+ :add_instance (instance , {})
355+ :config ()
356+
357+ local c = cluster :new (config , server_opts , {auto_cleanup = false })
358+ c :start ()
359+ assert_instance_running (c , instance )
360+
361+ g_persistent_clusters .instances [i ] = {cluster = c , instance = instance }
362+ g_persistent_clusters .pids [i ] = c [instance ].process .pid
363+ end
364+ end )
365+
366+ g_persistent_clusters .after_all (function ()
367+ for _ , cdata in ipairs (g_persistent_clusters .instances or {}) do
368+ cdata .cluster :drop ()
369+ end
370+ end )
371+
372+ g_persistent_clusters .test_clusters_survive_between_tests = function ()
373+ for _ , cdata in ipairs (g_persistent_clusters .instances ) do
374+ assert_instance_running (cdata .cluster , cdata .instance )
375+ end
376+ end
377+
378+ g_persistent_clusters .test_clusters_keep_same_process = function ()
379+ for i , cdata in ipairs (g_persistent_clusters .instances ) do
380+ local server = cdata .cluster [cdata .instance ]
381+
382+ t .assert_is_not (server .process , nil )
383+ t .assert_equals (server .process .pid , g_persistent_clusters .pids [i ])
384+ assert_instance_running (cdata .cluster , cdata .instance )
385+ end
386+ end
0 commit comments