check-mirroring: Fix some issues with startup process timing.
It seems that check-mirroring was reporting a lot of spurious failures due to it sometimes taking more than 3 seconds for the setup phase of check-mirroring's receive path to run. So fix this: (1) Wait a bit more than 3 seconds for the receiver to subscribe to messages (2) Subscribe to Humbug messages before forking (we can't do this with zephyr.init() because python-zephyr gets totally messed up if you use it from multiple processes with a shared initialization) (3) Get rid of the old time.sleep(0.x) values that were intended to make messages arrive in order -- since we're now checking that messages correctly arrived using set(), they aren't needed. (4) Use a single request to subscribe to both zephyr classes we need to subscribe to (saves 1 RTT). (imported from commit d96aef05405ce43e9a4a549de189da9a2e393875)
This commit is contained in:
parent
ba33df97bb
commit
ca34a2a02f
|
@ -60,10 +60,12 @@ def print_humbug(message):
|
||||||
print message["type"], message['sender_email'], \
|
print message["type"], message['sender_email'], \
|
||||||
message['display_recipient'], message['content']
|
message['display_recipient'], message['content']
|
||||||
|
|
||||||
|
max_message_id = humbug_client.get_profile()['max_message_id']
|
||||||
|
|
||||||
child_pid = os.fork()
|
child_pid = os.fork()
|
||||||
if child_pid == 0:
|
if child_pid == 0:
|
||||||
# Run the humbug => zephyr mirror in the child
|
# Run the humbug => zephyr mirror in the child
|
||||||
time.sleep(3)
|
time.sleep(5)
|
||||||
result = humbug_client.send_message({
|
result = humbug_client.send_message({
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": str(hzkey1),
|
"content": str(hzkey1),
|
||||||
|
@ -74,7 +76,6 @@ if child_pid == 0:
|
||||||
print "key1 send error:"
|
print "key1 send error:"
|
||||||
print result
|
print result
|
||||||
|
|
||||||
time.sleep(0.2)
|
|
||||||
result = humbug_client.send_message({
|
result = humbug_client.send_message({
|
||||||
"type": "stream",
|
"type": "stream",
|
||||||
"subject": "test",
|
"subject": "test",
|
||||||
|
@ -88,7 +89,6 @@ if child_pid == 0:
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Sent Humbug messages!"
|
print "Sent Humbug messages!"
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
import zephyr
|
import zephyr
|
||||||
try:
|
try:
|
||||||
|
@ -104,7 +104,6 @@ if child_pid == 0:
|
||||||
cls="message", instance="personal")
|
cls="message", instance="personal")
|
||||||
zeph.setmessage("%s\0%s" % (zsig, zhkey1))
|
zeph.setmessage("%s\0%s" % (zsig, zhkey1))
|
||||||
zeph.send()
|
zeph.send()
|
||||||
time.sleep(0.2)
|
|
||||||
|
|
||||||
zeph = zephyr.ZNotice(sender=mit_user, auth=True,
|
zeph = zephyr.ZNotice(sender=mit_user, auth=True,
|
||||||
cls="tabbott-nagios-test", instance="test")
|
cls="tabbott-nagios-test", instance="test")
|
||||||
|
@ -113,23 +112,18 @@ if child_pid == 0:
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Sent Zephyr messages!"
|
print "Sent Zephyr messages!"
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
failed = False
|
failed = False
|
||||||
import zephyr
|
import zephyr
|
||||||
try:
|
try:
|
||||||
zephyr.init()
|
zephyr.init()
|
||||||
subs = zephyr.Subscriptions()
|
zephyr._z.subAll([('message', 'personal', 'tabbott/extra@ATHENA.MIT.EDU'),
|
||||||
subs.add(('message', 'personal', 'tabbott/extra@ATHENA.MIT.EDU'))
|
('tabbott-nagios-test', '*', '*')])
|
||||||
subs.add(('tabbott-nagios-test', '*', '*'))
|
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
if "SERVNAK received" in e:
|
if "SERVNAK received" in e:
|
||||||
print "SERVNAK received, punting rest of test"
|
print "SERVNAK received, punting rest of test"
|
||||||
print_status_and_exit(0)
|
print_status_and_exit(0)
|
||||||
|
|
||||||
|
|
||||||
max_message_id = humbug_client.get_profile()['max_message_id']
|
|
||||||
|
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "Receiving messages!"
|
print "Receiving messages!"
|
||||||
|
|
Loading…
Reference in a new issue