Skip to content

Commit

Permalink
test: fix flaky router_test
Browse files Browse the repository at this point in the history
router_test.lua fails constantly on integration CI in tarantool
with error 'Peer closed' after simulating unconfigured box.

The reason for this problem is unclear, but the following changes
fix it. It might be related to the code, luatest executes
between execs (e.g. type(box.cfg) or box.cfg.<key> = ...).

Closes #403

NO_DOC=testfix
  • Loading branch information
Serpentian authored and Gerold103 committed Mar 28, 2023
1 parent b137b02 commit 28f4aa8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test/router-luatest/router_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -469,24 +469,23 @@ g.test_enable_disable = function(g)
_G.fiber_new:set_joinable(true)
end, {global_cfg})

-- emulate unconfigured box
router:exec(function()
rawset(_G, 'old_box_cfg', box.cfg)
box.cfg = function(...) return _G.old_box_cfg(...) end
end)

local err1, err2 = router:exec(function()
-- emulate unconfigured box
local old_box_cfg = box.cfg
box.cfg = function(...) return old_box_cfg(...) end

rawset(_G, 'static_router', ivshard.router.internal.routers._static_router)
rawset(_G, 'new_router', ivshard.router.internal.routers.new_router)
local _, err_1 = pcall(_G.static_router.info, _G.static_router)
local _, err_2 = pcall(_G.new_router.info, _G.new_router)

box.cfg = old_box_cfg
return err_1, err_2
end)
assert_errors_equals(err1, err2, 'box seems not to be configured')

-- set box status to loading
router:exec(function()
box.cfg = _G.old_box_cfg
rawset(_G, 'old_box_info', box.info)
box.info = {status = 'loading'}
end)
Expand Down

0 comments on commit 28f4aa8

Please sign in to comment.