2011-06-03 21:47:44 +00:00
|
|
|
import argparse
|
2011-06-15 19:10:27 +00:00
|
|
|
import os
|
2011-06-03 21:47:44 +00:00
|
|
|
import yaml
|
|
|
|
|
|
|
|
def config_file(string):
|
|
|
|
config = {}
|
|
|
|
try:
|
|
|
|
with file(string) as f:
|
|
|
|
g = yaml.safe_load_all(f)
|
|
|
|
for new in g:
|
|
|
|
config.update(new)
|
|
|
|
except IOError, e:
|
|
|
|
raise argparse.ArgumentTypeError(str(e))
|
|
|
|
return config
|
|
|
|
|
|
|
|
class MergeConfig(argparse.Action):
|
|
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
|
|
|
config = getattr(namespace, self.dest)
|
|
|
|
for new in values:
|
|
|
|
config.update(new)
|
|
|
|
|
|
|
|
def parse_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Run ceph integration tests')
|
|
|
|
parser.add_argument(
|
|
|
|
'-v', '--verbose',
|
|
|
|
action='store_true', default=None,
|
|
|
|
help='be more verbose',
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'config',
|
|
|
|
metavar='CONFFILE',
|
|
|
|
nargs='+',
|
|
|
|
type=config_file,
|
|
|
|
action=MergeConfig,
|
|
|
|
default={},
|
|
|
|
help='config file to read',
|
|
|
|
)
|
2011-06-07 21:47:30 +00:00
|
|
|
parser.add_argument(
|
|
|
|
'--archive',
|
|
|
|
metavar='DIR',
|
|
|
|
help='path to archive results in',
|
|
|
|
)
|
2011-06-28 21:15:19 +00:00
|
|
|
parser.add_argument(
|
|
|
|
'--description',
|
|
|
|
help='job description'
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--owner',
|
|
|
|
help='job owner'
|
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
return args
|
|
|
|
|
|
|
|
def main():
|
|
|
|
from gevent import monkey; monkey.patch_all()
|
|
|
|
from orchestra import monkey; monkey.patch_all()
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
ctx = parse_args()
|
|
|
|
|
|
|
|
loglevel = logging.INFO
|
|
|
|
if ctx.verbose:
|
|
|
|
loglevel = logging.DEBUG
|
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
level=loglevel,
|
|
|
|
)
|
|
|
|
|
2011-06-15 19:10:27 +00:00
|
|
|
if ctx.archive is not None:
|
|
|
|
os.mkdir(ctx.archive)
|
|
|
|
|
2011-06-15 19:32:22 +00:00
|
|
|
handler = logging.FileHandler(
|
|
|
|
filename=os.path.join(ctx.archive, 'teuthology.log'),
|
|
|
|
)
|
|
|
|
formatter = logging.Formatter(
|
|
|
|
fmt='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
|
|
|
|
datefmt='%Y-%m-%dT%H:%M:%S',
|
|
|
|
)
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
logging.getLogger().addHandler(handler)
|
|
|
|
|
|
|
|
|
2011-06-15 19:10:27 +00:00
|
|
|
with file(os.path.join(ctx.archive, 'config.yaml'), 'w') as f:
|
|
|
|
yaml.safe_dump(ctx.config, f, default_flow_style=False)
|
|
|
|
|
2011-06-03 21:47:58 +00:00
|
|
|
log.debug('\n '.join(['Config:', ] + yaml.safe_dump(ctx.config, default_flow_style=False).splitlines()))
|
2011-06-03 21:47:44 +00:00
|
|
|
log.info('Opening connections...')
|
|
|
|
|
|
|
|
from orchestra import connection, remote
|
|
|
|
import orchestra.cluster
|
|
|
|
|
|
|
|
remotes = [remote.Remote(name=t, ssh=connection.connect(t))
|
|
|
|
for t in ctx.config['targets']]
|
|
|
|
ctx.cluster = orchestra.cluster.Cluster()
|
|
|
|
for rem, roles in zip(remotes, ctx.config['roles']):
|
|
|
|
ctx.cluster.add(rem, roles)
|
|
|
|
|
2011-06-16 20:01:09 +00:00
|
|
|
ctx.summary = {}
|
|
|
|
|
2011-06-28 21:15:19 +00:00
|
|
|
if ctx.owner is not None:
|
|
|
|
ctx.summary['owner'] = ctx.owner
|
|
|
|
else:
|
2011-07-02 01:15:52 +00:00
|
|
|
from teuthology.misc import get_user
|
|
|
|
ctx.summary['owner'] = get_user()
|
2011-06-28 21:15:19 +00:00
|
|
|
|
|
|
|
if ctx.description is not None:
|
|
|
|
ctx.summary['description'] = ctx.description
|
|
|
|
|
2011-06-30 22:53:42 +00:00
|
|
|
for task in ctx.config['tasks']:
|
|
|
|
assert 'kernel' not in task, \
|
|
|
|
'kernel installation shouldn be a base-level item, not part of the tasks list'
|
|
|
|
|
|
|
|
init_tasks = [{'internal.check_conflict': None}]
|
|
|
|
if 'kernel' in ctx.config:
|
|
|
|
init_tasks.append({'kernel': ctx.config['kernel']})
|
|
|
|
init_tasks.extend([
|
|
|
|
{'internal.base': None},
|
|
|
|
{'internal.archive': None},
|
|
|
|
{'internal.coredump': None},
|
|
|
|
{'internal.syslog': None},
|
|
|
|
])
|
|
|
|
|
|
|
|
ctx.config['tasks'][:0] = init_tasks
|
2011-06-16 21:17:14 +00:00
|
|
|
|
2011-06-16 20:01:09 +00:00
|
|
|
from teuthology.run_tasks import run_tasks
|
2011-06-15 22:52:30 +00:00
|
|
|
try:
|
2011-06-16 20:01:09 +00:00
|
|
|
run_tasks(tasks=ctx.config['tasks'], ctx=ctx)
|
2011-06-15 22:52:30 +00:00
|
|
|
finally:
|
|
|
|
if ctx.archive is not None:
|
|
|
|
with file(os.path.join(ctx.archive, 'summary.yaml'), 'w') as f:
|
2011-06-16 20:01:09 +00:00
|
|
|
yaml.safe_dump(ctx.summary, f, default_flow_style=False)
|
2011-06-29 19:23:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def nuke():
|
|
|
|
from gevent import monkey; monkey.patch_all()
|
|
|
|
from orchestra import monkey; monkey.patch_all()
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
ctx = parse_args()
|
|
|
|
|
|
|
|
loglevel = logging.INFO
|
|
|
|
if ctx.verbose:
|
|
|
|
loglevel = logging.DEBUG
|
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
level=loglevel,
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('\n '.join(['targets:', ] + yaml.safe_dump(ctx.config['targets'], default_flow_style=False).splitlines()))
|
|
|
|
log.info('Opening connections...')
|
|
|
|
|
|
|
|
from orchestra import connection, remote, run
|
|
|
|
import orchestra.cluster
|
|
|
|
|
|
|
|
remotes = [remote.Remote(name=t, ssh=connection.connect(t))
|
|
|
|
for t in ctx.config['targets']]
|
|
|
|
ctx.cluster = orchestra.cluster.Cluster()
|
|
|
|
|
|
|
|
for rem, name in zip(remotes, ctx.config['targets']):
|
|
|
|
ctx.cluster.add(rem, name)
|
|
|
|
|
|
|
|
log.info('Killing daemons, unmounting, and removing data...')
|
|
|
|
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'killall',
|
|
|
|
'--quiet',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cmon',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cosd',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cmds',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cfuse',
|
|
|
|
run.Raw(';'),
|
2011-07-01 06:13:35 +00:00
|
|
|
'fusermount', '-u', run.Raw('/tmp/cephtest/mnt.*'),
|
2011-06-29 19:23:44 +00:00
|
|
|
run.Raw(';'),
|
2011-06-30 22:54:12 +00:00
|
|
|
'sudo', 'rm', '-rf', '/tmp/cephtest'
|
2011-06-29 19:23:44 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
log.info('Done.')
|