Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed Jul 4, 2024
1 parent 8e78d46 commit c239ff0
Showing 1 changed file with 10 additions and 36 deletions.
46 changes: 10 additions & 36 deletions test/integration/expel_last_instance_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,6 @@ g.before_all(function()
g.cluster:start()

g.to_be_expelled = g.cluster:server('B-1')
-- wait until all buckets are created
t.helpers.retrying({}, function()
local count = g.to_be_expelled:exec(function()
return _G.vshard.storage.buckets_count()
end)
t.assert_equals(count, 1500)
end)

g.to_be_expelled:exec(function()
-- this fiber will exit if the bucket count is decreased
-- we'll need that to check alerts later
local fiber = require('fiber')
local before_count = _G.vshard.storage.buckets_count()
fiber.create(function()
while true do
if _G.vshard.storage.buckets_count() < before_count then
os.exit(0)
end
fiber.sleep(0.1)
end
end)
end)
end)

g.after_all(function()
Expand All @@ -57,32 +35,26 @@ g.after_all(function()
end)

function g.test_expel()
g.cluster.main_server:setup_replicaset({
weight = 0,
uuid = g.to_be_expelled.replicaset_uuid,
})
g.cluster:wait_until_healthy()

g.to_be_expelled:stop()

g.cluster.main_server:exec(function(uuid)
package.loaded.cartridge.admin_disable_servers({uuid})
end, {g.to_be_expelled.instance_uuid})


local router_alerts
t.helpers.retrying({}, function()
local alerts = g.cluster.main_server:exec(function()
return require('vshard').router.info().alerts
end)
t.assert_equals(#alerts, 1)
router_alerts = alerts
end)
g.cluster.main_server:setup_replicaset({
weight = 0,
uuid = g.to_be_expelled.replicaset_uuid,
})

t.helpers.retrying({}, function()
t.assert_equals(
helpers.list_cluster_issues(g.cluster.main_server),
{{
level = "warning",
topic = "vshard",
message = router_alerts[1][2],
message = "1500 buckets are not discovered",
instance_uuid = g.cluster.main_server.instance_uuid,
replicaset_uuid = g.cluster.main_server.replicaset_uuid,
}}
Expand All @@ -100,6 +72,8 @@ function g.test_expel()
-- return g.to_be_expelled back to proceed the expel
g.to_be_expelled:start()

g.cluster:wait_until_healthy()

-- enable server before expelling
g.cluster.main_server:exec(function(uuid)
package.loaded.cartridge.admin_enable_servers({uuid})
Expand Down

0 comments on commit c239ff0

Please sign in to comment.