def configure_logging(): from sdcm.cluster import Setup logging.config.dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { '()': MultilineMessagesFormatter, 'format': '< t:%(asctime)s f:%(filename)-15s l:%(lineno)-4s c:%(name)-20s p:%(levelname)-5s > %(message)s' }, }, 'filters': { 'filter_remote': { '()': FilterRemote } }, 'handlers': { 'console': { 'level': 'INFO', 'formatter': 'default', 'class': 'logging.StreamHandler', 'stream': 'ext://sys.stdout', # Default is stderr 'filters': ['filter_remote'] }, 'outfile': { 'level': 'DEBUG', '()': MakeFileHandler, 'filename': '{}/sct.log'.format(Setup.logdir()), 'mode': 'w', 'formatter': 'default', } }, 'loggers': { '': { # root logger 'handlers': ['console', 'outfile'], 'level': 'DEBUG', 'propagate': True }, 'botocore': { 'level': 'CRITICAL' }, 'boto3': { 'level': 'CRITICAL' }, 'paramiko.transport': { 'level': 'CRITICAL' }, 'cassandra.connection': { 'level': 'INFO' }, 'invoke': { 'level': 'CRITICAL' } } })
def run_test(argv, backend, config, logdir): if config: os.environ['SCT_CONFIG_FILES'] = str(list(config)) if backend: os.environ['SCT_CLUSTER_BACKEND'] = backend if logdir: os.environ['_SCT_LOGDIR'] = logdir logfile = os.path.join(Setup.logdir(), 'output.log') sys.stdout = OutputLogger(logfile, sys.stdout) sys.stderr = OutputLogger(logfile, sys.stderr) unittest.main(module=None, argv=['python -m unittest', argv], testRunner=xmlrunner.XMLTestRunner(stream=sys.stderr, output=os.path.join( Setup.logdir(), 'test-reports')), failfast=False, buffer=False, catchbreak=True)