Skip to content

Backport storage-alerts #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/luatest_helpers/asserts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ function asserts:assert_server_no_alerts(server)
end)
end

function asserts:info_assert_alert(alerts, alert_name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not using anything in this asserts object. So it doesn't need to be a method of it. I suggest to either just duplicate this function in the needed tests, or put it into vtest. This is where we store all our vshard testing helpers.

for _, alert in pairs(alerts) do
if alert[1] == alert_name then
return alert
end
end
t.fail(('There is no %s in alerts').format(alert_name))
end

return asserts
13 changes: 3 additions & 10 deletions test/router-luatest/router_2_2_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local vtest = require('test.luatest_helpers.vtest')
local vutil = require('vshard.util')
local vconsts = require('vshard.consts')
local vserver = require('test.luatest_helpers.server')
local asserts = require('test.luatest_helpers.asserts')

local g = t.group('router')
local cfg_template = {
Expand Down Expand Up @@ -1044,14 +1045,6 @@ g.test_failed_calls_affect_priority = function()
vtest.router_cfg(g.router, global_cfg)
end

local function info_find_alert(alerts, alert_name)
for _, v in pairs(alerts) do
if v[1] == alert_name then
return v
end
end
end

--
-- gh-474: error during alert construction
--
Expand All @@ -1069,7 +1062,7 @@ g.test_info_with_named_identification = function()
ilt.assert(ok, 'no error')
return result.alerts
end)
t.assert(info_find_alert(alerts, 'MISSING_MASTER'),
t.assert(asserts:info_assert_alert(alerts, 'MISSING_MASTER'),
'MISSING_MASTER alert is constructed')

--
Expand All @@ -1085,7 +1078,7 @@ g.test_info_with_named_identification = function()
ilt.assert(ok, 'no error')
return result.alerts
end)
local alert = info_find_alert(alerts, 'UNREACHABLE_MASTER')
local alert = asserts:info_assert_alert(alerts, 'UNREACHABLE_MASTER')
t.assert(alert, 'UNREACHABLE_MASTER alert is constructed')
t.assert_not_str_contains(alert[2], 'replicaset nil',
'alert contains valid replicaset id')
Expand Down
47 changes: 47 additions & 0 deletions test/storage-luatest/persistent_names_2_test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local t = require('luatest')
local vtest = require('test.luatest_helpers.vtest')
local vutil = require('vshard.util')
local asserts = require('test.luatest_helpers.asserts')

local test_group = t.group('storage')

local cfg_template = {
sharding = {
repliacset_1 = {
replicas = {
replica_1_a = {
master = true
},
replica_1_b = {},
},
},
},
bucket_count = 20,
identification_mode = 'name_as_key'
}

local global_cfg

test_group.before_all(function(g)
t.run_only_if(vutil.feature.persistent_names)
global_cfg = vtest.config_new(cfg_template)

vtest.cluster_new(g, global_cfg)
vtest.cluster_bootstrap(g, global_cfg)
vtest.cluster_wait_vclock_all(g)
vtest.cluster_rebalancer_disable(g)
end)

test_group.after_all(function(g)
g.cluster:drop()
end)

test_group.test_named_replicaset_alerts_when_replica_disconnects = function(g)
g.replica_1_b:stop()
local alerts = g.replica_1_a:exec(function()
return ivshard.storage.info().alerts
end)
asserts:info_assert_alert(alerts, 'UNREACHABLE_REPLICA')
asserts:info_assert_alert(alerts, 'UNREACHABLE_REPLICASET')
g.replica_1_b:start()
end
Loading