logging.basicConfig(
level=loglevel,
- )
+ )
base_arg = [
os.path.join(os.path.dirname(sys.argv[0]), 'teuthology-schedule'),
'--name', args.name,
'--num', str(args.num),
'--worker', args.worker,
- ]
+ ]
if args.verbose:
base_arg.append('-v')
if args.owner:
collections = [
(os.path.join(args.base, collection), collection)
for collection in args.collections
- ]
+ ]
num_jobs = 0
for collection, collection_name in sorted(collections):
log.debug('Collection %s in %s' % (collection_name, collection))
- configs = [(combine_path(collection_name, item[0]), item[1]) for item in build_matrix(collection)]
- log.info('Collection %s in %s generated %d jobs' % (collection_name, collection, len(configs)))
+ configs = [(combine_path(collection_name, item[0]), item[1])
+ for item in build_matrix(collection)]
+ log.info('Collection %s in %s generated %d jobs' %
+ (collection_name, collection, len(configs)))
num_jobs += len(configs)
arch = get_arch(args.config)
if exclude_arch:
if exclude_arch == arch:
- log.info(
- 'Skipping due to excluded_arch: %s facets %s', exclude_arch, description
- )
+ log.info('Skipping due to excluded_arch: %s facets %s',
+ exclude_arch, description)
continue
if exclude_os_type:
if exclude_os_type == os_type:
- log.info(
- 'Skipping due to excluded_os_type: %s facets %s', exclude_os_type, description
- )
+ log.info('Skipping due to excluded_os_type: %s facets %s',
+ exclude_os_type, description)
continue
- # We should not run multiple tests (changing distros) unless the machine is a VPS
+ # We should not run multiple tests (changing distros) unless the
+ # machine is a VPS.
# Re-imaging baremetal is not yet supported.
if machine_type != 'vps':
if os_type and os_type != 'ubuntu':
log.info(
- 'Skipping due to non-ubuntu on baremetal facets %s', description
- )
+ 'Skipping due to non-ubuntu on baremetal facets %s',
+ description)
continue
log.info(
'Scheduling %s', description
- )
+ )
arg = copy.deepcopy(base_arg)
arg.extend([
- '--description', description,
- '--',
- ])
+ '--description', description,
+ '--',
+ ])
arg.extend(args.config)
arg.extend(config)
else:
subprocess.check_call(
args=arg,
- )
+ )
if num_jobs:
arg = copy.deepcopy(base_arg)
else:
subprocess.check_call(
args=arg,
- )
+ )
def combine_path(left, right):
return os.path.join(left, right)
return left
+
def build_matrix(path):
"""
Return a list of items describe by path
sublists = []
for fn in files:
raw = build_matrix(os.path.join(path, fn))
- sublists.append([(combine_path(fn, item[0]), item[1]) for item in raw])
+ sublists.append([(combine_path(fn, item[0]), item[1])
+ for item in raw])
out = []
if sublists:
for sublist in itertools.product(*sublists):
out = []
for fn in files:
raw = build_matrix(os.path.join(path, fn))
- out.extend([(combine_path(fn, item[0]), item[1]) for item in raw])
+ out.extend([(combine_path(fn, item[0]), item[1])
+ for item in raw])
return out
return []
g = yaml.safe_load_all(f)
for new in g:
summary.update(new)
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ENOENT:
print '%s ' % j,
# tail
tail = os.popen(
'tail -1 %s/%s/teuthology.log' % (archive_dir, j)
- ).read().rstrip()
+ ).read().rstrip()
print tail,
- except IOError, e:
+ except IOError as e:
continue
print ''
continue
desc=summary.get('description', '-'),
success='pass' if summary.get('success', False) else 'FAIL',
duration=int(summary.get('duration', 0)),
- )
+ )
if verbose and 'failure_reason' in summary:
print ' {reason}'.format(reason=summary['failure_reason'])
+
def generate_coverage(args):
log.info('starting coverage generation')
subprocess.Popen(
os.path.join(os.path.dirname(sys.argv[0]), 'teuthology-coverage'),
'-v',
'-o',
- os.path.join(args.teuthology_config['coverage_output_dir'], args.name),
+ os.path.join(args.teuthology_config[
+ 'coverage_output_dir'], args.name),
'--html-output',
- os.path.join(args.teuthology_config['coverage_html_dir'], args.name),
+ os.path.join(args.teuthology_config[
+ 'coverage_html_dir'], args.name),
'--cov-tools-dir',
args.teuthology_config['coverage_tools_dir'],
args.archive_dir,
- ],
- )
+ ],
+ )
+
def email_results(subject, from_, to, body):
log.info('Sending results to {to}: {body}'.format(to=to, body=body))
smtp.sendmail(msg['From'], [msg['To']], msg.as_string())
smtp.quit()
+
def results():
- parser = argparse.ArgumentParser(description='Email teuthology suite results')
+ parser = argparse.ArgumentParser(
+ description='Email teuthology suite results')
parser.add_argument(
'--email',
help='address to email test failures to',
- )
+ )
parser.add_argument(
'--timeout',
- help='how many seconds to wait for all tests to finish (default no wait)',
+ help='how many seconds to wait for all tests to finish (default no ' +
+ 'wait)',
type=int,
default=0,
- )
+ )
parser.add_argument(
'--archive-dir',
metavar='DIR',
help='path under which results for the suite are stored',
required=True,
- )
+ )
parser.add_argument(
'--name',
help='name of the suite',
required=True,
- )
+ )
parser.add_argument(
'-v', '--verbose',
action='store_true', default=False,
help='be more verbose',
- )
+ )
args = parser.parse_args()
loglevel = logging.INFO
logging.basicConfig(
level=loglevel,
- )
+ )
misc.read_config(args)
handler = logging.FileHandler(
filename=os.path.join(args.archive_dir, 'results.log'),
- )
+ )
formatter = logging.Formatter(
fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(message)s',
datefmt='%Y-%m-%dT%H:%M:%S',
- )
+ )
handler.setFormatter(formatter)
logging.getLogger().addHandler(handler)
f for f in sorted(os.listdir(args.archive_dir))
if not f.startswith('.')
and os.path.isdir(os.path.join(args.archive_dir, f))
- and not os.path.exists(os.path.join(args.archive_dir, f, 'summary.yaml'))
+ and not os.path.exists(os.path.join(
+ args.archive_dir, f, 'summary.yaml'))
]
starttime = time.time()
log.info('Waiting up to %d seconds for tests to finish...', args.timeout)
dir_contents = os.listdir(archive_dir)
def is_job_dir(parent, subdir):
- if os.path.isdir(os.path.join(parent, subdir)) and re.match('\d+$', subdir):
+ if (os.path.isdir(os.path.join(parent, subdir)) and re.match('\d+$',
+ subdir)):
return True
return False
}
-
def build_email_body(name, archive_dir, timeout):
failed = {}
hung = {}
if machine_type:
return machine_type
return None
-