Skip to content

Commit 015e3fe

Browse files
committed
config: add config_applied var
1 parent 763de81 commit 015e3fe

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

cartridge/twophase.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ vars:new('options', {
4646
apply_config_timeout = 10,
4747
})
4848

49+
vars:new('config_applied', false)
50+
4951
local function release_config_lock()
5052
local prepared_config = vars.prepared_config
5153
vars.prepared_config = nil
@@ -574,6 +576,7 @@ local function _clusterwide(patch)
574576
end
575577

576578
log.warn('Updating config clusterwide...')
579+
vars.config_applied = false
577580

578581
local clusterwide_config_old = confapplier.get_active_config()
579582
local vshard_utils = require('cartridge.vshard-utils')
@@ -650,6 +653,7 @@ local function _clusterwide(patch)
650653

651654
if err == nil then
652655
log.warn('Clusterwide config updated successfully')
656+
vars.config_applied = true
653657
return true
654658
else
655659
log.error('Clusterwide config update failed')

test/integration/config_test.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,16 @@ test_remotely('test_patch_clusterwide', function()
493493
local _patch = cartridge.config_patch_clusterwide
494494
local _get_ro = cartridge.config_get_readonly
495495

496+
local vars = require('cartridge.vars').new('cartridge.twophase')
497+
496498
--------------------------------------------------------------------
497499
local ok, err = _patch({
498500
['data'] = "friday",
499501
})
500502
t.assert_equals(err, nil)
501503
t.assert_equals(ok, true)
502504
t.assert_equals(_get_ro('data'), 'friday')
505+
t.assert(vars.config_applied)
503506

504507
--------------------------------------------------------------------
505508
local ok, err = _patch({
@@ -508,6 +511,7 @@ test_remotely('test_patch_clusterwide', function()
508511
t.assert_equals(err, nil)
509512
t.assert_equals(ok, true)
510513
t.assert_equals(_get_ro('data'), {today = 'friday'})
514+
t.assert(vars.config_applied)
511515

512516
--------------------------------------------------------------------
513517
local ok, err = _patch({
@@ -517,6 +521,7 @@ test_remotely('test_patch_clusterwide', function()
517521
t.assert_equals(err, nil)
518522
t.assert_equals(ok, true)
519523
t.assert_equals(_get_ro('data'), {tomorow = 'saturday'})
524+
t.assert(vars.config_applied)
520525

521526
local ok, err = _patch({
522527
['data.yml'] = '{tomorow: saturday} # so excited',
@@ -525,6 +530,7 @@ test_remotely('test_patch_clusterwide', function()
525530
t.assert_equals(ok, true)
526531
t.assert_equals(_get_ro('data'), {tomorow = 'saturday'})
527532
t.assert_equals(_get_ro('data.yml'), '{tomorow: saturday} # so excited')
533+
t.assert(vars.config_applied)
528534

529535
--------------------------------------------------------------------
530536
local ok, err = _patch({
@@ -534,6 +540,7 @@ test_remotely('test_patch_clusterwide', function()
534540
t.assert_equals(ok, true)
535541
t.assert_equals(_get_ro('data'), nil)
536542
t.assert_equals(_get_ro('data.yml'), nil)
543+
t.assert(vars.config_applied)
537544

538545
--------------------------------------------------------------------
539546
local ok, err = _patch({
@@ -543,6 +550,7 @@ test_remotely('test_patch_clusterwide', function()
543550
t.assert_equals(ok, true)
544551
t.assert_equals(_get_ro('data'), {afterwards = 'sunday'})
545552
t.assert_equals(_get_ro('data.yml'), '{afterwards: sunday}')
553+
t.assert(vars.config_applied)
546554

547555
--------------------------------------------------------------------
548556
local ok, err = _patch({['data'] = "Fun, fun, fun, fun",})
@@ -551,6 +559,7 @@ test_remotely('test_patch_clusterwide', function()
551559
class_name = 'LoadConfigError',
552560
err = 'Ambiguous sections "data" and "data.yml"'
553561
})
562+
t.assert_not(vars.config_applied)
554563
local ok, err = _patch({
555564
['data'] = "Fun, fun, fun, fun",
556565
['data.yml'] = box.NULL,
@@ -559,6 +568,7 @@ test_remotely('test_patch_clusterwide', function()
559568
t.assert_equals(ok, true)
560569
t.assert_equals(_get_ro('data'), "Fun, fun, fun, fun")
561570
t.assert_equals(_get_ro('data.yml'), nil)
571+
t.assert(vars.config_applied)
562572

563573
--------------------------------------------------------------------
564574
local ok, err = _patch({['data.yml'] = "---\nWeekend\n...",})
@@ -567,6 +577,7 @@ test_remotely('test_patch_clusterwide', function()
567577
class_name = 'LoadConfigError',
568578
err = 'Ambiguous sections "data" and "data.yml"'
569579
})
580+
t.assert_not(vars.config_applied)
570581
local ok, err = _patch({
571582
['data'] = box.NULL,
572583
['data.yml'] = "---\nWeekend\n...",
@@ -575,6 +586,7 @@ test_remotely('test_patch_clusterwide', function()
575586
t.assert_equals(ok, true)
576587
t.assert_equals(_get_ro('data'), "Weekend")
577588
t.assert_equals(_get_ro('data.yml'), "---\nWeekend\n...")
589+
t.assert(vars.config_applied)
578590

579591
--------------------------------------------------------------------
580592
local ok, err = _patch({
@@ -586,6 +598,7 @@ test_remotely('test_patch_clusterwide', function()
586598
class_name = 'PatchConfigError',
587599
err = 'Ambiguous sections "conflict" and "conflict.yml"',
588600
})
601+
t.assert_not(vars.config_applied)
589602
end)
590603

591604

0 commit comments

Comments
 (0)