Skip to content

Commit

Permalink
Fix tests in cartridge
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Feb 10, 2025
1 parent 09a26d4 commit ef90697
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions membership.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ local _ack_trigger = stash.get('_ack_trigger') or fiber.cond()
local _ack_cache = stash.get('_ack_cache') or {}
local _resolve_cache = stash.get('_resolve_cache') or {}
local _allowed_uri_set = stash.get('_allowed_uri_set')
local _params = stash.get('_params')

local function after_reload()
stash.set('_ack_cache', _ack_cache)
stash.set('_ack_trigger', _ack_trigger)
stash.set('_sync_trigger', _sync_trigger)
stash.set('_resolve_cache', _resolve_cache)
stash.set('_allowed_uri_set', _allowed_uri_set)
stash.set('_params', _params)
end

local _sock = stash.get('_sock')
Expand Down Expand Up @@ -1007,14 +1009,22 @@ local function remove_member(uri)
end

--- Filter out members from the list.
--- If the function wasn't called or allowed uri list
--- if empty, all members are allowed.
-- @function set_allowed_members
-- @tparam uris table URIs to leave in the list
local function set_allowed_members(uris)
checks('table')
events.clear()
table.clear(_protocol_round_list)
table.clear(_allowed_uri_set)
if next(uris) == nil then
return
end
for _, uri in ipairs(uris) do
_allowed_uri_set[uri] = true
end
fiber.yield()
for uri in pairs(stash['members._all_members'] or {}) do
if not _allowed_uri_set[uri] then
members.remove(uri)
Expand Down
4 changes: 3 additions & 1 deletion membership/members.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local _all_members = table.copy(stash.get('members._all_members')) or {
}

local _allowed_uri_set = stash.get('_allowed_uri_set')
local _params = stash.get('_params')

function members.after_reload()
stash.set('members._all_members', _all_members)
Expand Down Expand Up @@ -91,7 +92,8 @@ function members.set(uri, status, incarnation, params)

local member = _all_members[uri]

if not _allowed_uri_set[uri] and (status == opts.LEFT or status == opts.DEAD) then
if next(_allowed_uri_set) and not _allowed_uri_set[uri]
and (status == opts.SUSPECT or status == opts.LEFT or status == opts.DEAD) then
opts.log_debug('Ignoring member %s with status %s', uri, opts.STATUS_NAMES[status])
return
end
Expand Down

0 comments on commit ef90697

Please sign in to comment.