2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Peer test (Single test, not much configurable here)
|
|
|
|
"""
|
2012-02-24 23:05:17 +00:00
|
|
|
import logging
|
|
|
|
import json
|
2016-06-02 22:24:56 +00:00
|
|
|
import time
|
2012-02-24 23:05:17 +00:00
|
|
|
|
2013-07-22 21:21:51 +00:00
|
|
|
import ceph_manager
|
|
|
|
from teuthology import misc as teuthology
|
2014-08-07 14:24:59 +00:00
|
|
|
from util.rados import rados
|
2012-02-24 23:05:17 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
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)
|
2014-03-27 16:35:28 +00:00
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.iterkeys()
|
2012-02-24 23:05:17 +00:00
|
|
|
|
|
|
|
manager = ceph_manager.CephManager(
|
|
|
|
mon,
|
|
|
|
ctx=ctx,
|
|
|
|
logger=log.getChild('ceph_manager'),
|
|
|
|
)
|
|
|
|
|
2012-04-19 19:43:54 +00:00
|
|
|
while len(manager.get_osd_status()['up']) < 3:
|
2016-06-02 22:24:56 +00:00
|
|
|
time.sleep(10)
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 1, 2])
|
2012-02-24 23:05:17 +00:00
|
|
|
manager.wait_for_clean()
|
|
|
|
|
2013-02-11 14:59:17 +00:00
|
|
|
for i in range(3):
|
|
|
|
manager.set_config(
|
|
|
|
i,
|
|
|
|
osd_recovery_delay_start=120)
|
|
|
|
|
2012-02-24 23:05:17 +00:00
|
|
|
# take on osd down
|
|
|
|
manager.kill_osd(2)
|
|
|
|
manager.mark_down_osd(2)
|
|
|
|
|
|
|
|
# kludge to make sure they get a map
|
2013-01-23 20:37:39 +00:00
|
|
|
rados(ctx, mon, ['-p', 'data', 'get', 'dummy', '-'])
|
2012-02-24 23:05:17 +00:00
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 1])
|
2012-02-24 23:05:17 +00:00
|
|
|
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)
|
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 2])
|
2012-02-24 23:05:17 +00:00
|
|
|
|
2012-02-26 05:05:00 +00:00
|
|
|
manager.wait_for_active_or_down()
|
|
|
|
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 2])
|
2012-02-26 05:05:00 +00:00
|
|
|
|
2012-02-24 23:05:17 +00:00
|
|
|
# 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')
|
2012-07-03 23:04:12 +00:00
|
|
|
log.debug("out string %s",out)
|
2013-06-13 21:51:21 +00:00
|
|
|
j = json.loads(out)
|
2012-02-28 17:50:29 +00:00
|
|
|
log.info("pg is %s, query json is %s", pg, j)
|
2012-02-24 23:05:17 +00:00
|
|
|
|
|
|
|
if pg['state'].count('down'):
|
|
|
|
num_down_pgs += 1
|
|
|
|
# verify that it is blocked on osd.1
|
|
|
|
rs = j['recovery_state']
|
2016-12-22 04:06:09 +00:00
|
|
|
assert len(rs) >= 2
|
|
|
|
assert rs[0]['name'] == 'Started/Primary/Peering/Down'
|
2012-02-24 23:05:17 +00:00
|
|
|
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)
|
2017-05-18 22:16:55 +00:00
|
|
|
manager.flush_pg_stats([0, 1, 2])
|
2012-02-24 23:05:17 +00:00
|
|
|
manager.wait_for_clean()
|