Multimaster test for events handling on master disconnect

This commit is contained in:
Dmitry Kuzmenko 2019-08-16 21:34:42 +03:00
parent 1654fe8824
commit c1efae673a
No known key found for this signature in database
GPG Key ID: 4C7CAD30C95651DA
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1 @@
# -*- coding: utf-8 -*-

View File

@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing libs
from tests.support.case import MultimasterModuleCase, ShellTestCase
from tests.support.helpers import skip_if_not_root, destructiveTest
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
from tests.support.unit import skipIf
import salt.modules.iptables
HAS_IPTABLES = salt.modules.iptables.__virtual__()
@destructiveTest
@skip_if_not_root
@skipIf(not HAS_IPTABLES, 'iptables command is not available')
class TestHandleEvents(MultimasterModuleCase, ShellTestCase, AdaptedConfigurationTestCaseMixin):
'''
Validate the events handling in multimaster environment
'''
def test_minion_hangs_on_master_failure_50814(self):
'''
Check minion handling events for the alive master when another master is dead.
The case being checked here is described in details in issue #50814.
'''
disconnect_master_rule = '-i lo -p tcp --dport {0} -j DROP'.format(
self.mm_master_opts['ret_port'])
# Disconnect the master.
res = self.run_function(
'iptables.append',
('filter', 'INPUT', disconnect_master_rule),
master_tgt=1,
)
self.assertTrue(res)
try:
# Send an event. This would return okay.
res = self.run_function(
'event.send',
('myco/foo/bar',),
master_tgt=1,
)
self.assertTrue(res)
# Send one more event. Minion was hanging on this. This is fixed by #53417
res = self.run_function(
'event.send',
('myco/foo/bar',),
master_tgt=1,
timeout=60,
)
self.assertTrue(res)
finally:
# Remove the firewall rule taking master online back.
# Since minion could be not responsive now use `salt-call --local` for this.
res = self.run_call(
"iptables.delete filter INPUT rule='{0}'".format(disconnect_master_rule),
local=True)
self.assertEqual(res, ['local:'])
# Ensure the master is back.
res = self.run_function(
'event.send',
('myco/foo/bar',),
master_tgt=0,
)
self.assertTrue(res)