From ef91beb79abef49e0cc36fec4a25316d51b6b0be Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 26 Mar 2015 16:51:56 -0700 Subject: [PATCH] tasks/watch_notify_same_primary: wait for watch before notify Make sure watch is done registering and ready before sending the notifies. Fixes: #10634 Signed-off-by: Sage Weil (cherry picked from commit bafe87a8e51cdedad84ac6ea8ecd6504a7d9dd2e) --- tasks/watch_notify_same_primary.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tasks/watch_notify_same_primary.py b/tasks/watch_notify_same_primary.py index b83a7a972358a..168b6bb6c30e7 100644 --- a/tasks/watch_notify_same_primary.py +++ b/tasks/watch_notify_same_primary.py @@ -7,6 +7,7 @@ import contextlib import logging from teuthology.orchestra import run +from teuthology.contextutil import safe_while log = logging.getLogger(__name__) @@ -57,7 +58,7 @@ def task(ctx, config): obj(n), "/etc/resolv.conf"], logger=log.getChild('watch.{id}'.format(id=n))) - return remote.run( + proc = remote.run( args = [ "rados", "-p", pool, @@ -67,7 +68,28 @@ def task(ctx, config): stdout=StringIO(), stderr=StringIO(), wait=False) - watches = [start_watch(i) for i in range(20)] + return proc + + num = 20 + + watches = [start_watch(i) for i in range(num)] + + # wait for them all to register + for i in range(num): + with safe_while() as proceed: + while proceed(): + proc = remote.run( + args = [ + "rados", + "-p", pool, + "listwatchers", + obj(i)], + stdout=StringIO()) + lines = proc.stdout.getvalue() + num_watchers = lines.count('watcher=') + log.info('i see %d watchers for %s', num_watchers, obj(i)) + if num_watchers >= 1: + break def notify(n, msg): remote.run( -- 2.39.5