@@ -144,3 +144,62 @@ g.test_failover = function()
144144 g .cluster .main_server :start ()
145145 g .cluster :wait_until_healthy ()
146146end
147+
148+ local function get_config_checksum (server )
149+ local resp = server :http_request (' get' , ' /metrics' )
150+ local checksum_metric = utils .find_metric (' tnt_cartridge_config_checksum' , resp .json )
151+
152+ t .assert (checksum_metric , ' tnt_cartridge_config_checksum metric should be present' )
153+ t .assert_equals (# checksum_metric , 1 )
154+
155+ local checksum = checksum_metric [1 ].value
156+ t .assert_type (checksum , ' number' , ' Checksum should be a number' )
157+
158+ return checksum
159+ end
160+
161+ g .test_config_checksum_match = function ()
162+ local main_server = g .cluster :server (' main' )
163+ local replica_server = g .cluster :server (' replica' )
164+
165+ local initial_checksum = get_config_checksum (main_server )
166+
167+ main_server .net_box :eval ([[
168+ local patch = require('cartridge').config_patch_clusterwide
169+ local ok, err = patch({
170+ ['text'] = 'text',
171+ })
172+ ]] )
173+
174+ local updated_checksum = get_config_checksum (main_server )
175+ t .assert_not_equals (initial_checksum , updated_checksum , ' Config checksum should change after config update' )
176+
177+ local replica_checksum = get_config_checksum (replica_server )
178+ t .assert_equals (replica_checksum , updated_checksum , ' Nodes should have the same config checksum' )
179+ end
180+
181+ g .test_config_checksum_mismatch = function ()
182+ local main_server = g .cluster :server (' main' )
183+ local replica_server = g .cluster :server (' replica' )
184+
185+ replica_server .net_box :eval ([[
186+ local vars = require('cartridge.vars').new('cartridge.confapplier')
187+ __old_config = vars.clusterwide_config
188+ ]] )
189+
190+ main_server .net_box :eval ([[
191+ local patch = require('cartridge').config_patch_clusterwide
192+ local ok, err = patch({
193+ ['text'] = 'text',
194+ })
195+ ]] )
196+
197+ replica_server .net_box :eval ([[
198+ local vars = require('cartridge.vars').new('cartridge.confapplier')
199+ vars.clusterwide_config = __old_config
200+ ]] )
201+
202+ local main_checksum = get_config_checksum (main_server )
203+ local replica_checksum = get_config_checksum (replica_server )
204+ t .assert_not_equals (main_checksum , replica_checksum , ' Nodes should have different config checksum' )
205+ end
0 commit comments