From: Loic Dachary Date: Tue, 6 Oct 2015 16:18:44 +0000 (+0200) Subject: misc: wait_until_osds_up must verify 'up' in state X-Git-Tag: 1.1.0~802^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=19ddca97ea429031c8fda9a1f45012f73e41cf4a;p=teuthology.git misc: wait_until_osds_up must verify 'up' in state It is not enough to count the number of entries in the osds array, wait_until_osds_up must count which one are actually up by checking if the string "up" is in the "state" array. http://tracker.ceph.com/issues/13363 Fixes: #13363 Signed-off-by: Loic Dachary --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 7dbb0e3d10..06ac08ca41 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -910,7 +910,7 @@ def wait_until_osds_up(ctx, cluster, remote): ) out = r.stdout.getvalue() j = json.loads('\n'.join(out.split('\n')[1:])) - up = len(j['osds']) + up = len(filter(lambda o: 'up' in o['state'], j['osds'])) log.debug('%d of %d OSDs are up' % (up, num_osds)) if up == num_osds: break diff --git a/teuthology/test/test_misc.py b/teuthology/test/test_misc.py index c3da5dbc10..71a534acbf 100644 --- a/teuthology/test/test_misc.py +++ b/teuthology/test/test_misc.py @@ -12,6 +12,27 @@ class FakeRemote(object): pass +def test_wait_until_osds_up(): + ctx = argparse.Namespace() + remote = FakeRemote() + class r(): + class o: + def getvalue(self): + return 'IGNORED\n{"osds":[{"state":["up"]}]}' + stdout = o() + + remote.run = lambda **kwargs: r() + ctx.cluster = cluster.Cluster( + remotes=[ + (remote, ['osd.0', 'client.1']) + ], + ) + with patch.multiple( + misc, + get_testdir=lambda ctx: "TESTDIR", + ): + misc.wait_until_osds_up(ctx, ctx.cluster, remote) + def test_get_clients_simple(): ctx = argparse.Namespace() remote = FakeRemote()