mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Multimaster test for events handling on master disconnect
This commit is contained in:
parent
1654fe8824
commit
c1efae673a
1
tests/multimaster/minion/__init__.py
Normal file
1
tests/multimaster/minion/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
66
tests/multimaster/minion/test_event.py
Normal file
66
tests/multimaster/minion/test_event.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user