mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Make BeakerLib logging less verbose
Logs from Beaker jobs are normally very brief, with the standard output/error containing detailed information. Make ipa-run-tests with BeakerLib plugin follow this convention. Only include INFO and higher level messages in the Beaker logs. Downgrade several message levels to DEBUG. Log to console using Python logging instead of showing the Beaker logs. Since ipa-run-tests sets up its own logging, Nose's own log handling just causes duplicate messages. Disable it with --nologcapture.
This commit is contained in:
parent
19a0d51d89
commit
c47f3154be
@ -76,7 +76,9 @@ class BeakerLibPlugin(Plugin):
|
|||||||
|
|
||||||
# Set up the Bash process
|
# Set up the Bash process
|
||||||
self.bash = subprocess.Popen(['bash'],
|
self.bash = subprocess.Popen(['bash'],
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=open('/dev/null', 'w'),
|
||||||
|
stderr=open('/dev/null', 'w'))
|
||||||
source_path = os.path.join(self.env['BEAKERLIB'], 'beakerlib.sh')
|
source_path = os.path.join(self.env['BEAKERLIB'], 'beakerlib.sh')
|
||||||
self.run_beakerlib_command(['.', source_path])
|
self.run_beakerlib_command(['.', source_path])
|
||||||
|
|
||||||
@ -88,16 +90,12 @@ class BeakerLibPlugin(Plugin):
|
|||||||
self.setup_log_handler(BeakerLibLogHandler(self.run_beakerlib_command))
|
self.setup_log_handler(BeakerLibLogHandler(self.run_beakerlib_command))
|
||||||
|
|
||||||
def setup_log_handler(self, handler):
|
def setup_log_handler(self, handler):
|
||||||
# Remove the console handler (BeakerLib will print to stderr)
|
|
||||||
if 'console' in log_mgr.handlers:
|
|
||||||
log_mgr.remove_handler('console')
|
|
||||||
# Configure our logger
|
|
||||||
log_mgr.configure(
|
log_mgr.configure(
|
||||||
{
|
{
|
||||||
'default_level': 'DEBUG',
|
'default_level': 'DEBUG',
|
||||||
'handlers': [{'log_handler': handler,
|
'handlers': [{'log_handler': handler,
|
||||||
'format': '[%(name)s] %(message)s',
|
'format': '[%(name)s] %(message)s',
|
||||||
'level': 'debug'}]},
|
'level': 'info'}]},
|
||||||
configure_state='beakerlib_plugin')
|
configure_state='beakerlib_plugin')
|
||||||
|
|
||||||
def run_beakerlib_command(self, cmd):
|
def run_beakerlib_command(self, cmd):
|
||||||
@ -207,7 +205,6 @@ class BeakerLibPlugin(Plugin):
|
|||||||
tarname = os.path.join(dirname, 'logs.tar.xz')
|
tarname = os.path.join(dirname, 'logs.tar.xz')
|
||||||
with open(tarname, 'w') as f:
|
with open(tarname, 'w') as f:
|
||||||
f.write(cmd.stdout_text)
|
f.write(cmd.stdout_text)
|
||||||
self.log.info('%s', dirname)
|
|
||||||
ipautil.run(['tar', 'xJvf', 'logs.tar.xz'], cwd=dirname)
|
ipautil.run(['tar', 'xJvf', 'logs.tar.xz'], cwd=dirname)
|
||||||
os.unlink(tarname)
|
os.unlink(tarname)
|
||||||
|
|
||||||
@ -219,7 +216,7 @@ class BeakerLibPlugin(Plugin):
|
|||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
fullname = os.path.relpath(
|
fullname = os.path.relpath(
|
||||||
os.path.join(dirpath, filename), topdirname)
|
os.path.join(dirpath, filename), topdirname)
|
||||||
self.log.info('Submitting file: %s', fullname)
|
self.log.debug('Submitting file: %s', fullname)
|
||||||
self.run_beakerlib_command(['rlFileSubmit', fullname])
|
self.run_beakerlib_command(['rlFileSubmit', fullname])
|
||||||
self.run_beakerlib_command(['popd'])
|
self.run_beakerlib_command(['popd'])
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ from ipatests.order_plugin import OrderTests
|
|||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
sys.argv[0],
|
sys.argv[0],
|
||||||
'-v',
|
|
||||||
'--with-doctest',
|
'--with-doctest',
|
||||||
'--doctest-tests',
|
'--doctest-tests',
|
||||||
'--with-ordered-tests',
|
'--with-ordered-tests',
|
||||||
'--exclude=plugins',
|
'--exclude=plugins',
|
||||||
|
'--nologcapture',
|
||||||
'--logging-filter=-paramiko',
|
'--logging-filter=-paramiko',
|
||||||
'--where', os.path.dirname(ipatests.__file__),
|
'--where', os.path.dirname(ipatests.__file__),
|
||||||
]
|
]
|
||||||
@ -72,7 +72,7 @@ log_mgr.configure(
|
|||||||
'handlers': [{'log_handler': LogHandler(),
|
'handlers': [{'log_handler': LogHandler(),
|
||||||
'format': '[%(name)s] %(message)s',
|
'format': '[%(name)s] %(message)s',
|
||||||
'level': 'debug'},
|
'level': 'debug'},
|
||||||
{'level': 'info',
|
{'level': 'debug',
|
||||||
'name': 'console',
|
'name': 'console',
|
||||||
'stream': sys.stderr}]},
|
'stream': sys.stderr}]},
|
||||||
configure_state='tests')
|
configure_state='tests')
|
||||||
|
@ -99,7 +99,7 @@ class RemoteCommand(object):
|
|||||||
self.log.error('Exit code: %s', self.returncode)
|
self.log.error('Exit code: %s', self.returncode)
|
||||||
raise subprocess.CalledProcessError(self.returncode, self.argv)
|
raise subprocess.CalledProcessError(self.returncode, self.argv)
|
||||||
else:
|
else:
|
||||||
self.log.info('Exit code: %s', self.returncode)
|
self.log.debug('Exit code: %s', self.returncode)
|
||||||
return self.returncode
|
return self.returncode
|
||||||
|
|
||||||
def _start_pipe_thread(self, result_list, stream, name, do_log=True):
|
def _start_pipe_thread(self, result_list, stream, name, do_log=True):
|
||||||
@ -108,7 +108,7 @@ class RemoteCommand(object):
|
|||||||
def read_stream():
|
def read_stream():
|
||||||
for line in stream:
|
for line in stream:
|
||||||
if do_log:
|
if do_log:
|
||||||
log.info(line.rstrip('\n'))
|
log.debug(line.rstrip('\n'))
|
||||||
result_list.append(line)
|
result_list.append(line)
|
||||||
|
|
||||||
thread = threading.Thread(target=read_stream)
|
thread = threading.Thread(target=read_stream)
|
||||||
@ -285,7 +285,7 @@ class Host(object):
|
|||||||
|
|
||||||
def get_file_contents(self, filename):
|
def get_file_contents(self, filename):
|
||||||
"""Read the named remote file and return the contents as a string"""
|
"""Read the named remote file and return the contents as a string"""
|
||||||
self.log.info('READ %s', filename)
|
self.log.debug('READ %s', filename)
|
||||||
with self.sftp.open(filename) as f:
|
with self.sftp.open(filename) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class Host(object):
|
|||||||
|
|
||||||
def file_exists(self, filename):
|
def file_exists(self, filename):
|
||||||
"""Return true if the named remote file exists"""
|
"""Return true if the named remote file exists"""
|
||||||
self.log.info('STAT %s', filename)
|
self.log.debug('STAT %s', filename)
|
||||||
try:
|
try:
|
||||||
self.sftp.stat(filename)
|
self.sftp.stat(filename)
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
@ -308,7 +308,7 @@ class Host(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_file(self, remotepath, localpath):
|
def get_file(self, remotepath, localpath):
|
||||||
self.log.info('GET %s', remotepath)
|
self.log.debug('GET %s', remotepath)
|
||||||
self.sftp.get(remotepath, localpath)
|
self.sftp.get(remotepath, localpath)
|
||||||
|
|
||||||
def put_file(self, localpath, remotepath):
|
def put_file(self, localpath, remotepath):
|
||||||
|
@ -64,7 +64,7 @@ def fix_etc_hosts(host):
|
|||||||
flags=re.MULTILINE)
|
flags=re.MULTILINE)
|
||||||
# Add the host's info again
|
# Add the host's info again
|
||||||
contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
|
contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
|
||||||
log.info('Writing the following to /etc/hosts:\n%s', contents)
|
log.debug('Writing the following to /etc/hosts:\n%s', contents)
|
||||||
host.put_file_contents('/etc/hosts', contents)
|
host.put_file_contents('/etc/hosts', contents)
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ def fix_resolv_conf(host):
|
|||||||
if other_host.role in ('master', 'replica'):
|
if other_host.role in ('master', 'replica'):
|
||||||
lines.append('nameserver %s' % other_host.ip)
|
lines.append('nameserver %s' % other_host.ip)
|
||||||
contents = '\n'.join(lines)
|
contents = '\n'.join(lines)
|
||||||
log.info('Writing the following to /etc/resolv.conf:\n%s', contents)
|
log.debug('Writing the following to /etc/resolv.conf:\n%s', contents)
|
||||||
host.put_file_contents('/etc/resolv.conf', contents)
|
host.put_file_contents('/etc/resolv.conf', contents)
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ def restore_hostname(host):
|
|||||||
try:
|
try:
|
||||||
hostname = host.get_file_contents(backupname)
|
hostname = host.get_file_contents(backupname)
|
||||||
except IOError:
|
except IOError:
|
||||||
log.info('No hostname backed up on %s' % host.hostname)
|
log.debug('No hostname backed up on %s' % host.hostname)
|
||||||
else:
|
else:
|
||||||
host.run_command(['hostname', hostname.strip()])
|
host.run_command(['hostname', hostname.strip()])
|
||||||
host.run_command(['rm', backupname])
|
host.run_command(['rm', backupname])
|
||||||
|
Loading…
Reference in New Issue
Block a user