From 8a57ffd2fb40aa4c4f28b58967d3af440e854933 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Fri, 24 May 2013 14:33:48 -0400 Subject: [PATCH] TST: test all stock jails to have actions and correctly specifying blocktype --- testcases/clientreadertestcase.py | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/testcases/clientreadertestcase.py b/testcases/clientreadertestcase.py index faa8dcd6..dbaa8ec2 100644 --- a/testcases/clientreadertestcase.py +++ b/testcases/clientreadertestcase.py @@ -144,10 +144,38 @@ class JailsReaderTest(unittest.TestCase): # and warn on useDNS self.assertTrue(['set', j, 'usedns', 'warn'] in comm_commands) self.assertTrue(['start', j] in comm_commands) + # last commands should be the 'start' commands self.assertEqual(comm_commands[-1][0], 'start') - # TODO: make sure that all of the jails have actions assigned, - # otherwise it makes little to no sense + + for j in jails._JailsReader__jails: + actions = j._JailReader__actions + jail_name = j.getName() + # make sure that all of the jails have actions assigned, + # otherwise it makes little to no sense + self.assertTrue(len(actions), + msg="No actions found for jail %s" % jail_name) + + # Test for presence of blocktype (in relation to gh-232) + for action in actions: + commands = action.convert() + file_ = action.getFile() + if '' in str(commands): + # Verify that it is among cInfo + self.assertTrue('blocktype' in action._ActionReader__cInfo) + # Verify that we have a call to set it up + blocktype_present = False + target_command = [ 'set', jail_name, 'setcinfo', file_, 'blocktype' ] + for command in commands: + if (len(command) > 5 and + command[:5] == target_command): + blocktype_present = True + continue + self.assertTrue( + blocktype_present, + msg="Found no %s command among %s" + % (target_command, str(commands)) ) + def testConfigurator(self): configurator = Configurator()