Skip to content
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

tests: Use FQDNs as bad nodes hostnames #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions tests/MilkCheckTests/EngineTests/ActionTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ def test_nb_timeout_local(self):
def test_mix_errors_timeout(self):
"""Test the result of mixed timeout and error actions."""
# timeout host configuration is in setup_sshconfig (__init__.py)
action = Action(name='start', target='badname,timeout,localhost',
action = Action(name='start', target='badname.example.org.,timeout,localhost',
command='/bin/true', timeout=0.9)
action.errors = 1
service = Service('test_service')
service.add_action(action)
service.run('start')
self.assertEqual(action.nodes_error(), NodeSet('badname'))
self.assertEqual(str(action.nodes_error()), str(NodeSet('badname.example.org.')))
self.assertEqual(action.nb_errors(), 1)
self.assertEqual(action.nodes_timeout(), NodeSet('timeout'))
self.assertEqual(action.nb_timeout(), 1)
Expand All @@ -207,7 +207,7 @@ def test_mix_errors_timeout(self):
service.reset()
action.errors = 2
service.run('start')
self.assertEqual(action.nodes_error(), NodeSet('badname'))
self.assertEqual(action.nodes_error(), NodeSet('badname.example.org.'))
self.assertEqual(action.nb_errors(), 1)
self.assertEqual(action.nodes_timeout(), NodeSet('timeout'))
self.assertEqual(action.nb_timeout(), 1)
Expand All @@ -217,7 +217,7 @@ def test_mix_errors_timeout(self):
action.errors = 2
action.warnings = 2
service.run('start')
self.assertEqual(action.nodes_error(), NodeSet('badname'))
self.assertEqual(action.nodes_error(), NodeSet('badname.example.org.'))
self.assertEqual(action.nb_errors(), 1)
self.assertEqual(action.nodes_timeout(), NodeSet('timeout'))
self.assertEqual(action.nb_timeout(), 1)
Expand Down
4 changes: 2 additions & 2 deletions tests/MilkCheckTests/EngineTests/ServiceGroupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def test_filter(self):

def test_filter_from_service_group(self):
"""a service can filter error nodes from a service group"""
nodes = "%s,BADNODE" % HOSTNAME
nodes = "%s,BADNODE.EXAMPLE.ORG." % HOSTNAME

grp = ServiceGroup('group')
subsvc = Service('subsvc')
Expand All @@ -602,7 +602,7 @@ def test_filter_from_service_group(self):

def test_mix_require_filter_from_service_group(self):
"""mixing filter and require to a failed service group is ok"""
nodes = "%s,BADNODE" % HOSTNAME
nodes = "%s,BADNODE.EXAMPLE.ORG." % HOSTNAME

grp = ServiceGroup('group')
subsvc = Service('subsvc')
Expand Down
10 changes: 5 additions & 5 deletions tests/MilkCheckTests/EngineTests/ServiceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def test_filter_dep_timeout(self):
def test_filter_dep_error_propagation(self):
"""error nodes are propagated along 'filter' dependencies (one node)"""
svc1 = Service('first')
tgt = '%s,fakenode' % HOSTNAME
tgt = '%s,fakenode.' % HOSTNAME
svc1.add_action(Action('start', command='true', target=tgt))

svc2 = Service('second')
Expand Down Expand Up @@ -789,15 +789,15 @@ def test_filter_error_no_action(self):
def test_filter_two_deps(self):
"""error nodes are send even with multiple filter deps"""
svc1 = Service('top')
tgt = '%s,fakenode' % HOSTNAME
tgt = '%s,fakenode.' % HOSTNAME
svc1.add_action(Action('start', command='true', target=tgt))

svc2 = Service('bottom1')
svc2.add_action(Action('start', command='true', target=HOSTNAME))
svc2.add_dep(svc1, sgth=FILTER)

svc3 = Service('bottom2')
svc3.add_action(Action('start', command='true', target='fakenode'))
svc3.add_action(Action('start', command='true', target='fakenode.'))
svc3.add_dep(svc1, sgth=FILTER)

svc4 = Service('src')
Expand All @@ -813,14 +813,14 @@ def test_filter_two_deps(self):
def test_filter_mixed(self):
"""test filter and regular deps works fine together"""
svc1 = Service('top1')
tgt = '%s,fakenode' % HOSTNAME
tgt = '%s,fakenode.' % HOSTNAME
svc1.add_action(Action('start', command='true', target=tgt))

svc2 = Service('top2')
svc2.add_action(Action('start', command='true', target=HOSTNAME))

svc3 = Service('bottom')
svc3.add_action(Action('start', command='true', target='fakenode'))
svc3.add_action(Action('start', command='true', target='fakenode.'))
svc3.add_dep(svc1, sgth=REQUIRE)
svc3.add_dep(svc2, sgth=FILTER)

Expand Down
64 changes: 32 additions & 32 deletions tests/MilkCheckTests/UITests/CliTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,23 @@ def setUp(self):
inter2.desc = 'I am the service I2'

# Actions S1
start_svc1 = Action('start', HOSTNAME + ', BADNODE', '/bin/true')
start_svc1 = Action('start', HOSTNAME + ', BADNODE.EXAMPLE.ORG.', '/bin/true')
start_svc1.delay = 1
stop_svc1 = Action('stop', HOSTNAME + ',BADNODE', '/bin/true')
stop_svc1 = Action('stop', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/true')
stop_svc1.delay = 1
svc1.add_actions(start_svc1, stop_svc1)
# Actions S2
svc2.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/true'))
svc2.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/true'))
svc2.add_action(Action('start', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/true'))
svc2.add_action(Action('stop', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/true'))
# Actions S3
svc3.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/false'))
svc3.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/false'))
svc3.add_action(Action('start', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/false'))
svc3.add_action(Action('stop', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/false'))
# Actions I1
inter1.add_action(Action('start', HOSTNAME, 'echo ok'))
inter1.add_action(Action('stop', HOSTNAME, 'echo ok'))
# Actions I2
inter2.add_action(Action('start', HOSTNAME + ',BADNODE', '/bin/true'))
inter2.add_action(Action('stop', HOSTNAME + ',BADNODE', '/bin/true'))
inter2.add_action(Action('start', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/true'))
inter2.add_action(Action('stop', HOSTNAME + ',BADNODE.EXAMPLE.ORG.', '/bin/true'))

# Build graph
svc1.add_dep(target=svc2)
Expand All @@ -246,8 +246,8 @@ def test_execute_std_verbosity(self):
self._output_check(['S3', 'start'], RC_ERROR,
"""G1.I1 - I am the service I1 [ OK ]
start G1.I2 ran in 0.00 s
> BADNODE: ssh: Could not resolve hostname badnode: Name or service not known
> BADNODE exited with 255
> BADNODE.EXAMPLE.ORG.: ssh: Could not resolve hostname badnode.example.org.: Name or service not known
> BADNODE.EXAMPLE.ORG. exited with 255
G1.I2 - I am the service I2 [ ERROR ]
G1 [DEP_ERROR]
S3 - I am the service S3 [DEP_ERROR]
Expand All @@ -259,12 +259,12 @@ def test_execute_verbosity_1(self):
"""start G1.I1 on HOSTNAME
> echo ok
G1.I1 - I am the service I1 [ OK ]
start G1.I2 on BADNODE,HOSTNAME
start G1.I2 on BADNODE.EXAMPLE.ORG.,HOSTNAME
> /bin/true
start G1.I2 ran in 0.00 s
> BADNODE: ssh: Could not resolve hostname badnode: Name or service not known
> BADNODE.EXAMPLE.ORG.: ssh: Could not resolve hostname badnode.example.org.: Name or service not known
> HOSTNAME exited with 0
> BADNODE exited with 255
> BADNODE.EXAMPLE.ORG. exited with 255
G1.I2 - I am the service I2 [ ERROR ]
G1 [DEP_ERROR]
S3 - I am the service S3 [DEP_ERROR]
Expand All @@ -279,12 +279,12 @@ def test_execute_verbosity_2(self):
> HOSTNAME: ok
> HOSTNAME exited with 0
G1.I1 - I am the service I1 [ OK ]
start G1.I2 on BADNODE,HOSTNAME
start G1.I2 on BADNODE.EXAMPLE.ORG.,HOSTNAME
> /bin/true
start G1.I2 ran in 0.00 s
> BADNODE: ssh: Could not resolve hostname badnode: Name or service not known
> BADNODE.EXAMPLE.ORG.: ssh: Could not resolve hostname badnode.example.org.: Name or service not known
> HOSTNAME exited with 0
> BADNODE exited with 255
> BADNODE.EXAMPLE.ORG. exited with 255
G1.I2 - I am the service I2 [ ERROR ]
G1 [DEP_ERROR]
S3 - I am the service S3 [DEP_ERROR]
Expand All @@ -299,12 +299,12 @@ def test_execute_debug(self):
> HOSTNAME: ok
> HOSTNAME exited with 0
G1.I1 - I am the service I1 [ OK ]
start G1.I2 on BADNODE,HOSTNAME
start G1.I2 on BADNODE.EXAMPLE.ORG.,HOSTNAME
> /bin/true
start G1.I2 ran in 0.00 s
> BADNODE: ssh: Could not resolve hostname badnode: Name or service not known
> BADNODE.EXAMPLE.ORG.: ssh: Could not resolve hostname badnode.example.org.: Name or service not known
> HOSTNAME exited with 0
> BADNODE exited with 255
> BADNODE.EXAMPLE.ORG. exited with 255
G1.I2 - I am the service I2 [ ERROR ]
G1 [DEP_ERROR]
S3 - I am the service S3 [DEP_ERROR]
Expand All @@ -325,7 +325,7 @@ def test_execute_debug(self):

def test_excluded_node(self):
'''Execute with a node exclusion (-vvv -x ...)'''
self._output_check(['S3', 'stop', '-vvv', '-x', 'BADNODE'], RC_ERROR,
self._output_check(['S3', 'stop', '-vvv', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_ERROR,
"""stop S1 will fire in 1 s
stop S1 on HOSTNAME
> /bin/true
Expand Down Expand Up @@ -377,7 +377,7 @@ def test_selected_node(self):

def test_execute_explicit_service(self):
'''Execute a service from the CLI (-vvv -x ...)'''
self._output_check(['G1', 'stop', '-vvv', '-x', 'BADNODE'], RC_ERROR,
self._output_check(['G1', 'stop', '-vvv', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_ERROR,
"""stop S1 will fire in 1 s
stop S1 on HOSTNAME
> /bin/true
Expand All @@ -394,7 +394,7 @@ def test_execute_explicit_service(self):

def test_execute_services_exclusion(self):
'''CLI execute() (-X S3 -x ... -vvv)'''
self._output_check(['S1', 'start', '-vvv', '-X', 'S3', '-x', 'BADNODE'],
self._output_check(['S1', 'start', '-vvv', '-X', 'S3', '-x', 'BADNODE.EXAMPLE.ORG.'],
RC_OK,
"""start S2 on HOSTNAME
> /bin/true
Expand Down Expand Up @@ -424,7 +424,7 @@ def test_execute_unknown_exception(self):

def test_multiple_services(self):
"""CLI execute() with explicit services (S1 G1 -d)"""
self._output_check(['S3', 'G1', 'start', '-d', '-x', 'BADNODE'],
self._output_check(['S3', 'G1', 'start', '-d', '-x', 'BADNODE.EXAMPLE.ORG.'],
RC_ERROR,
"""start G1.I1 on HOSTNAME
> echo ok
Expand All @@ -449,7 +449,7 @@ def test_multiple_services(self):
config_dir:
confirm_actions: []
dryrun: False
excluded_nodes: BADNODE
excluded_nodes: BADNODE.EXAMPLE.ORG.
fanout: 64
nodeps: False
report: no
Expand All @@ -461,7 +461,7 @@ def test_multiple_services(self):

def test_multiple_services_reverse(self):
"""CLI reverse execute() with explicit services (S1 S3 -d)"""
self._output_check(['S1', 'S3', 'stop', '-d', '-x', 'BADNODE'],
self._output_check(['S1', 'S3', 'stop', '-d', '-x', 'BADNODE.EXAMPLE.ORG.'],
RC_ERROR,
"""stop S1 will fire in 1 s
stop S1 on HOSTNAME
Expand All @@ -480,7 +480,7 @@ def test_multiple_services_reverse(self):
config_dir:
confirm_actions: []
dryrun: False
excluded_nodes: BADNODE
excluded_nodes: BADNODE.EXAMPLE.ORG.
fanout: 64
nodeps: False
report: no
Expand All @@ -494,7 +494,7 @@ def test_overall_graph(self):
"""CLI execute() with whole graph (-v -x )"""
# This could be avoided if the graph is simplified
self.manager.remove_inter_dep(self.svc2.name)
self._output_check(['start', '-v', '-x', 'BADNODE'], RC_ERROR,
self._output_check(['start', '-v', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_ERROR,
"""start G1.I1 on HOSTNAME
> echo ok
G1.I1 - I am the service I1 [ OK ]
Expand All @@ -515,7 +515,7 @@ def test_overall_graph_reverse(self):
"""CLI reverse execute() with whole graph (-v -x )"""
# This could be avoided if the graph is simplified
self.manager.remove_inter_dep(self.svc2.name)
self._output_check(['stop', '-v', '-x', 'BADNODE'], RC_ERROR,
self._output_check(['stop', '-v', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_ERROR,
"""stop S1 on HOSTNAME
> /bin/true
S1 - I am the service S1 [ OK ]
Expand All @@ -530,7 +530,7 @@ def test_overall_graph_reverse(self):

def test_nodeps_service(self):
"""--nodeps option specifying an explicit service"""
self._output_check(['S3', 'start', '--nodeps', '-x', 'BADNODE'],
self._output_check(['S3', 'start', '--nodeps', '-x', 'BADNODE.EXAMPLE.ORG.'],
RC_ERROR,
"""start S3 ran in 0.00 s
> HOSTNAME exited with 1
Expand All @@ -539,19 +539,19 @@ def test_nodeps_service(self):

def test_nodeps_service_reverse(self):
"""--nodeps option with an explicit service and a reverse action"""
self._output_check(['S2', 'stop', '--nodeps', '-x', 'BADNODE'], RC_OK,
self._output_check(['S2', 'stop', '--nodeps', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_OK,
"""S2 - I am the service S2 [ OK ]
""", "[S2]\r")

def test_nodeps_all(self):
"""--nodeps option without specifying an explicit service list"""
self._output_check(['start', '--nodeps', '-x', 'BADNODE'], RC_OK,
self._output_check(['start', '--nodeps', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_OK,
"""S1 - I am the service S1 [ OK ]
""", "[S1]\r")

def test_no_running_status(self):
"""Test if we don't have stderr output when terminal is not a tty"""
self._output_check(['S2', 'start', '-x', 'BADNODE'], RC_OK,
self._output_check(['S2', 'start', '-x', 'BADNODE.EXAMPLE.ORG.'], RC_OK,
"""S2 - I am the service S2 [ OK ]
""", "", show_running=False)

Expand Down