if job_config.get('last_in_suite', False):
log.debug('Generating coverage for %s', job_config['name'])
- subprocess.Popen(
- args=[
- os.path.join(os.path.dirname(sys.argv[0]), 'teuthology-results'),
- '--timeout',
- job_config.get('results_timeout', '21600'),
- '--email',
- job_config['email'],
- '--archive-dir',
- os.path.join(ctx.archive_dir, safe_archive),
- '--name',
- job_config['name'],
- ])
+ args = [
+ os.path.join(os.path.dirname(sys.argv[0]), 'teuthology-results'),
+ '--timeout',
+ job_config.get('results_timeout', '21600'),
+ '--email',
+ job_config['email'],
+ '--archive-dir',
+ os.path.join(ctx.archive_dir, safe_archive),
+ '--name',
+ job_config['name'],
+ ]
+ if job_config.get('email_on_success', False):
+ args.append('--email-on-success')
+ subprocess.Popen(args=args)
else:
log.debug('Creating archive dir...')
safepath.makedirs(ctx.archive_dir, safe_archive)
'--email',
help='where to send the results of a suite (only applies to the last job in a suite)',
)
+ parser.add_argument(
+ '--email-on-success',
+ action='store_true',
+ default=False,
+ help='email even if all tests pass',
+ )
parser.add_argument(
'--timeout',
help='how many seconds to wait for jobs to finish before emailing results (only applies to the last job in a suite',
if not ctx.last_in_suite:
assert not ctx.email, '--email is only applicable to the last job in a suite'
assert not ctx.timeout, '--timeout is only applicable to the last job in a suite'
+ assert not ctx.email_on_success, '--email-on-success is only applicable to the last job in a suite'
from teuthology.misc import read_config, get_user
if ctx.owner is None:
name=ctx.name,
last_in_suite=ctx.last_in_suite,
email=ctx.email,
+ email_on_success=ctx.email_on_success,
description=ctx.description,
owner=ctx.owner,
verbose=ctx.verbose,
'--email',
help='address to email test failures to',
)
+ parser.add_argument(
+ '--email-on-success',
+ action='store_true',
+ default=False,
+ help='email even if all tests pass',
+ )
parser.add_argument(
'--timeout',
help='how many seconds to wait for jobs to finish before emailing results',
'--email',
help='address to email test failures to',
)
+ parser.add_argument(
+ '--email-on-success',
+ action='store_true',
+ default=False,
+ help='email even if all tests pass',
+ )
parser.add_argument(
'--timeout',
help='how many seconds to wait for all tests to finish (default no wait)',
],
)
+ descriptions = []
failures = []
unfinished = []
for j in sorted(os.listdir(args.archive_dir)):
g = yaml.safe_load_all(f)
for new in g:
summary.update(new)
+ desc = '{test}: {desc}'.format(
+ desc=summary['description'],
+ test=j,
+ )
+ descriptions.append(desc)
if not summary['success']:
- failures.append('{test}: {desc}'.format(
- desc=summary['description'],
- test=j,
- ))
- if (not failures and not unfinished) or not args.email:
+ failures.append(desc)
+
+ if not args.email or not (failures or unfinished or args.email_on_success):
return
- import smtplib
- from email.mime.text import MIMEText
- msg = MIMEText("""
+ if failures or unfinished:
+ subject = '{num_failed} failed and {num_hung} possibly hung tests in {suite}'.format(
+ num_failed=len(failures),
+ num_hung=len(unfinished),
+ suite=args.name,
+ )
+ body = """
The following tests failed:
{failures}
failures='\n'.join(failures),
unfinished='\n'.join(unfinished),
timeout=args.timeout,
- ))
- msg['Subject'] = '{num_failed} failed and {num_hung} possibly hung tests in {suite}'.format(
- num_failed=len(failures),
- num_hung=len(unfinished),
- suite=args.name,
- )
+ )
+ else:
+ subject = 'All tests passed in {suite}!'.format(suite=args.name)
+ body = '\n'.join(descriptions)
+
+ import smtplib
+ from email.mime.text import MIMEText
+ msg = MIMEText(body)
+ msg['Subject'] = subject
msg['From'] = args.teuthology_config['results_sending_email']
msg['To'] = args.email
log.debug('sending email %s', msg.as_string())