mirror of
https://github.com/ceph/ceph
synced 2024-12-16 16:39:21 +00:00
ace4cb07b2
Teuthology uses /tmp/cephtest/ as the scratch test directory for a run. This patch replaces /tmp/cephtest/ everywhere with a per-run directory: {basedir}/{rundir} where {basedir} is a directory configured in .teuthology.yaml (/tmp/cephtest if not specified), and {rundir} is the name of the run, as given in --name. If no name is specified, {user}-{timestamp} is used. To get the old behavior (/tmp/cephtest), set test_path: /tmp/cephtest in .teuthology.yaml. This change was modivated by #3782, which requires a test dir that survives across reboots, but also resolves #3767. Signed-off-by: Sam Lang <sam.lang@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
113 lines
3.6 KiB
Python
113 lines
3.6 KiB
Python
import logging
|
|
import ceph_manager
|
|
import json
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def rados(ctx, remote, cmd):
|
|
testdir = teuthology.get_testdir(ctx)
|
|
log.info("rados %s" % ' '.join(cmd))
|
|
pre = [
|
|
'LD_LIBRARY_PATH={tdir}/binary/usr/local/lib'.format(tdir=testdir),
|
|
'{tdir}/enable-coredump'.format(tdir=testdir),
|
|
'{tdir}/binary/usr/local/bin/ceph-coverage'.format(tdir=testdir),
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
'{tdir}/binary/usr/local/bin/rados'.format(tdir=testdir),
|
|
'-c', '{tdir}/ceph.conf'.format(tdir=testdir),
|
|
];
|
|
pre.extend(cmd)
|
|
proc = remote.run(
|
|
args=pre,
|
|
check_status=False
|
|
)
|
|
return proc.exitstatus
|
|
|
|
def normalize_state(r):
|
|
r = r.replace('+scrubbing', '')
|
|
r = r.replace('+deep', '')
|
|
return r
|
|
|
|
def task(ctx, config):
|
|
"""
|
|
Test peering.
|
|
"""
|
|
if config is None:
|
|
config = {}
|
|
assert isinstance(config, dict), \
|
|
'peer task only accepts a dict for configuration'
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.iterkeys()
|
|
|
|
manager = ceph_manager.CephManager(
|
|
mon,
|
|
ctx=ctx,
|
|
logger=log.getChild('ceph_manager'),
|
|
)
|
|
|
|
while len(manager.get_osd_status()['up']) < 3:
|
|
manager.sleep(10)
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.1', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.2', 'flush_pg_stats')
|
|
manager.wait_for_clean()
|
|
|
|
# take on osd down
|
|
manager.kill_osd(2)
|
|
manager.mark_down_osd(2)
|
|
|
|
# kludge to make sure they get a map
|
|
rados(ctx, mon, ['-p', 'data', 'get', 'dummy', '-'])
|
|
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.1', 'flush_pg_stats')
|
|
manager.wait_for_recovery()
|
|
|
|
# kill another and revive 2, so that some pgs can't peer.
|
|
manager.kill_osd(1)
|
|
manager.mark_down_osd(1)
|
|
manager.revive_osd(2)
|
|
manager.wait_till_osd_is_up(2)
|
|
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.2', 'flush_pg_stats')
|
|
|
|
manager.wait_for_active_or_down()
|
|
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.2', 'flush_pg_stats')
|
|
|
|
# look for down pgs
|
|
num_down_pgs = 0
|
|
pgs = manager.get_pg_stats()
|
|
for pg in pgs:
|
|
out = manager.raw_cluster_cmd('pg', pg['pgid'], 'query')
|
|
log.debug("out string %s",out)
|
|
j = json.loads('\n'.join(out.split('\n')[1:]))
|
|
log.info("pg is %s, query json is %s", pg, j)
|
|
assert normalize_state(j['state']) == normalize_state(pg['state'])
|
|
|
|
if pg['state'].count('down'):
|
|
num_down_pgs += 1
|
|
# verify that it is blocked on osd.1
|
|
rs = j['recovery_state']
|
|
assert len(rs) > 0
|
|
assert rs[0]['name'] == 'Started/Primary/Peering/GetInfo'
|
|
assert rs[1]['name'] == 'Started/Primary/Peering'
|
|
assert rs[1]['blocked']
|
|
assert rs[1]['down_osds_we_would_probe'] == [1]
|
|
assert len(rs[1]['peering_blocked_by']) == 1
|
|
assert rs[1]['peering_blocked_by'][0]['osd'] == 1
|
|
|
|
assert num_down_pgs > 0
|
|
|
|
# bring it all back
|
|
manager.revive_osd(1)
|
|
manager.wait_till_osd_is_up(1)
|
|
manager.raw_cluster_cmd('tell', 'osd.0', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.1', 'flush_pg_stats')
|
|
manager.raw_cluster_cmd('tell', 'osd.2', 'flush_pg_stats')
|
|
manager.wait_for_clean()
|