summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-28 17:10:52 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-28 17:10:52 -0500
commitd1715e2fa400d80d401fc590825e0c9c713a63a9 (patch)
tree4109ef8c6a5ef819a7ebb75852cef58962ce5022 /src
parentf301da8af95a184c6302df2d6e4418787c73b6bd (diff)
downloadbcfg2-d1715e2fa400d80d401fc590825e0c9c713a63a9.tar.gz
bcfg2-d1715e2fa400d80d401fc590825e0c9c713a63a9.tar.bz2
bcfg2-d1715e2fa400d80d401fc590825e0c9c713a63a9.zip
bcfg2-test: various improvements
- avoided hang on Ctrl-C - better output formatting and verbosity
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sbin/bcfg2-test51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test
index 815d2740c..4123effe4 100755
--- a/src/sbin/bcfg2-test
+++ b/src/sbin/bcfg2-test
@@ -3,7 +3,9 @@
"""This tool verifies that all clients known to the server build
without failures"""
+import os
import sys
+import signal
import fnmatch
import logging
import Bcfg2.Logger
@@ -12,6 +14,7 @@ from nose.core import TestProgram
from nose.suite import LazySuite
from unittest import TestCase
+
class ClientTest(TestCase):
"""
A test case representing the build of all of the configuration for
@@ -20,7 +23,7 @@ class ClientTest(TestCase):
files that we know will cause errors (because they are private
files we don't have access to, for instance)
"""
- __test__ = False # Do not collect
+ __test__ = False # Do not collect
def __init__(self, bcfg2_core, client, ignore=None):
TestCase.__init__(self)
@@ -44,6 +47,9 @@ class ClientTest(TestCase):
return True
return False
+ def shortDescription(self):
+ return "Building configuration for %s" % self.client
+
def runTest(self):
""" run this individual test """
config = self.bcfg2_core.BuildConfiguration(self.client)
@@ -63,6 +69,15 @@ class ClientTest(TestCase):
id = __str__
+
+def get_sigint_handler(core):
+ def hdlr(sig, frame):
+ core.shutdown()
+ os._exit(1)
+
+ return hdlr
+
+
def main():
optinfo = dict(noseopts=Bcfg2.Options.TEST_NOSEOPTS,
test_ignore=Bcfg2.Options.TEST_IGNORE,
@@ -75,10 +90,22 @@ def main():
setup.buildHelpMessage()
setup.parse(sys.argv[1:])
- if setup['verbose']:
- Bcfg2.Logger.setup_logging("bcfg2-test", to_syslog=setup['syslog'])
+ if setup['debug']:
+ level = logging.DEBUG
+ elif setup['verbose']:
+ level = logging.INFO
+ else:
+ level = logging.WARNING
+ Bcfg2.Logger.setup_logging("bcfg2-test",
+ to_console=setup['verbose'] or setup['debug'],
+ to_syslog=False,
+ to_file=setup['logging'],
+ level=level)
+ if (setup['debug'] or setup['verbose']) and "-v" not in setup['noseopts']:
+ setup['noseopts'].append("-v")
core = Bcfg2.Server.Core.BaseCore(setup)
+ signal.signal(signal.SIGINT, get_sigint_handler(core))
ignore = dict()
for entry in setup['test_ignore']:
@@ -88,21 +115,23 @@ def main():
except KeyError:
ignore[tag] = [name]
- def run_tests():
- """ Run the test suite """
- core.fam.handle_events_in_interval(0.1)
+ core.fam.handle_events_in_interval(0.1)
- if setup['args']:
- clients = setup['args']
- else:
- clients = core.metadata.clients
+ if setup['args']:
+ clients = setup['args']
+ else:
+ clients = core.metadata.clients
+ def run_tests():
+ """ Run the test suite """
for client in clients:
- logging.info("Building %s" % client)
yield ClientTest(core, client, ignore)
TestProgram(argv=sys.argv[0:1] + setup['noseopts'],
suite=LazySuite(run_tests))
+ core.shutdown()
+ os._exit(0) # pylint: disable=W0212
+
if __name__ == "__main__":
sys.exit(main())