2020-04-02 09:59:28 -04:00
|
|
|
#!/usr/bin/env python3
|
2021-05-28 05:00:04 -04:00
|
|
|
import hashlib
|
|
|
|
import logging
|
2012-10-19 12:20:52 -04:00
|
|
|
import optparse
|
|
|
|
import random
|
2012-11-28 22:34:49 -05:00
|
|
|
import subprocess
|
2021-05-28 05:00:04 -04:00
|
|
|
import sys
|
|
|
|
import time
|
2022-06-17 14:49:25 -04:00
|
|
|
from ctypes import byref, c_int, c_ushort
|
2021-05-28 05:00:04 -04:00
|
|
|
from typing import Dict, List, Set, Tuple
|
|
|
|
|
2022-06-17 14:49:25 -04:00
|
|
|
import zephyr_ctypes
|
2021-05-28 05:00:04 -04:00
|
|
|
import zulip
|
2016-09-10 13:56:23 -04:00
|
|
|
|
2012-10-19 12:20:52 -04:00
|
|
|
parser = optparse.OptionParser()
|
2021-05-28 05:05:11 -04:00
|
|
|
parser.add_option("--verbose", dest="verbose", default=False, action="store_true")
|
|
|
|
parser.add_option("--site", dest="site", default=None, action="store")
|
|
|
|
parser.add_option("--sharded", default=False, action="store_true")
|
2012-10-19 12:20:52 -04:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
2021-05-28 05:05:11 -04:00
|
|
|
mit_user = "tabbott/extra@ATHENA.MIT.EDU"
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
zulip_client = zulip.Client(verbose=True, client="ZulipMonitoring/0.1", site=options.site)
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
# Configure logging
|
2021-05-28 05:03:46 -04:00
|
|
|
log_file = "/var/log/zulip/check-mirroring-log"
|
|
|
|
log_format = "%(asctime)s: %(message)s"
|
2012-11-28 22:34:49 -05:00
|
|
|
logging.basicConfig(format=log_format)
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
formatter = logging.Formatter(log_format)
|
2012-11-28 22:34:49 -05:00
|
|
|
file_handler = logging.FileHandler(log_file)
|
|
|
|
file_handler.setFormatter(formatter)
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
logger = logging.getLogger(__name__)
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
logger.addHandler(file_handler)
|
|
|
|
|
|
|
|
# Initialize list of streams to test
|
|
|
|
if options.sharded:
|
2017-03-20 15:13:10 -04:00
|
|
|
# NOTE: Streams in this list must be in the zulip_user's Zulip
|
2013-08-06 15:32:15 -04:00
|
|
|
# subscriptions, or we won't receive messages via Zulip.
|
2012-11-28 22:34:49 -05:00
|
|
|
|
|
|
|
# The sharded stream list has a bunch of pairs
|
|
|
|
# (stream, shard_name), where sha1sum(stream).startswith(shard_name)
|
|
|
|
test_streams = [
|
|
|
|
("message", "p"),
|
2012-12-12 13:46:18 -05:00
|
|
|
("tabbott-nagios-test-32", "0"),
|
|
|
|
("tabbott-nagios-test-33", "1"),
|
2017-01-24 00:21:14 -05:00
|
|
|
("tabbott-nagios-test-2", "2"),
|
|
|
|
("tabbott-nagios-test-5", "3"),
|
2012-12-12 13:46:18 -05:00
|
|
|
("tabbott-nagios-test-13", "4"),
|
2017-01-24 00:21:14 -05:00
|
|
|
("tabbott-nagios-test-7", "5"),
|
2012-12-12 13:46:18 -05:00
|
|
|
("tabbott-nagios-test-22", "6"),
|
|
|
|
("tabbott-nagios-test-35", "7"),
|
2017-01-24 00:21:14 -05:00
|
|
|
("tabbott-nagios-test-4", "8"),
|
|
|
|
("tabbott-nagios-test-3", "9"),
|
|
|
|
("tabbott-nagios-test-1", "a"),
|
2012-12-12 13:46:18 -05:00
|
|
|
("tabbott-nagios-test-49", "b"),
|
|
|
|
("tabbott-nagios-test-34", "c"),
|
|
|
|
("tabbott-nagios-test-12", "d"),
|
|
|
|
("tabbott-nagios-test-11", "e"),
|
2017-01-24 00:21:14 -05:00
|
|
|
("tabbott-nagios-test-9", "f"),
|
2017-01-24 00:34:26 -05:00
|
|
|
]
|
2012-12-12 13:46:18 -05:00
|
|
|
for (stream, test) in test_streams:
|
|
|
|
if stream == "message":
|
|
|
|
continue
|
2021-05-28 05:03:46 -04:00
|
|
|
assert hashlib.sha1(stream.encode("utf-8")).hexdigest().startswith(test)
|
2012-11-28 22:34:49 -05:00
|
|
|
else:
|
|
|
|
test_streams = [
|
|
|
|
("message", "p"),
|
|
|
|
("tabbott-nagios-test", "a"),
|
2017-01-24 00:34:26 -05:00
|
|
|
]
|
2012-11-28 22:34:49 -05:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def print_status_and_exit(status: int) -> None:
|
2016-09-10 13:56:23 -04:00
|
|
|
|
2012-11-15 14:24:38 -05:00
|
|
|
# The output of this script is used by Nagios. Various outputs,
|
|
|
|
# e.g. true success and punting due to a SERVNAK, result in a
|
|
|
|
# non-alert case, so to give us something unambiguous to check in
|
|
|
|
# Nagios, print the exit status.
|
2016-03-10 11:15:34 -05:00
|
|
|
print(status)
|
2012-11-15 14:24:38 -05:00
|
|
|
sys.exit(status)
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def send_zulip(message: Dict[str, str]) -> None:
|
2013-08-07 11:51:03 -04:00
|
|
|
result = zulip_client.send_message(message)
|
2012-11-15 14:24:38 -05:00
|
|
|
if result["result"] != "success":
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("Error sending zulip, args were:")
|
2016-09-13 00:43:45 -04:00
|
|
|
logger.error(str(message))
|
2016-12-19 14:50:14 -05:00
|
|
|
logger.error(str(result))
|
2012-11-28 22:34:49 -05:00
|
|
|
print_status_and_exit(1)
|
2012-11-15 14:24:38 -05:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2012-12-18 10:54:39 -05:00
|
|
|
# Returns True if and only if we "Detected server failure" sending the zephyr.
|
2020-04-18 18:59:12 -04:00
|
|
|
def send_zephyr(zwrite_args: List[str], content: str) -> bool:
|
2021-05-28 05:03:46 -04:00
|
|
|
p = subprocess.Popen(
|
|
|
|
zwrite_args,
|
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
universal_newlines=True,
|
|
|
|
)
|
2021-03-10 16:55:13 -05:00
|
|
|
stdout, stderr = p.communicate(input=content)
|
2012-11-28 22:34:49 -05:00
|
|
|
if p.returncode != 0:
|
2021-03-10 16:55:13 -05:00
|
|
|
if "Detected server failure while receiving acknowledgement for" in stdout:
|
2012-12-10 13:37:50 -05:00
|
|
|
logger.warning("Got server failure error sending zephyr; retrying")
|
|
|
|
logger.warning(stderr)
|
2012-12-18 10:54:39 -05:00
|
|
|
return True
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.error("Error sending zephyr:")
|
|
|
|
logger.info(stdout)
|
|
|
|
logger.error(stderr)
|
|
|
|
print_status_and_exit(1)
|
2012-12-18 10:54:39 -05:00
|
|
|
return False
|
2012-11-15 14:24:38 -05:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2013-08-06 15:32:15 -04:00
|
|
|
# Subscribe to Zulip
|
2012-11-28 22:34:49 -05:00
|
|
|
try:
|
2013-10-08 14:09:31 -04:00
|
|
|
res = zulip_client.register(event_types=["message"])
|
2021-05-28 05:05:11 -04:00
|
|
|
if "error" in res["result"]:
|
2013-08-06 15:32:15 -04:00
|
|
|
logging.error("Error subscribing to Zulips!")
|
2021-05-28 05:05:11 -04:00
|
|
|
logging.error(res["msg"])
|
2012-11-28 22:34:49 -05:00
|
|
|
print_status_and_exit(1)
|
2021-05-28 05:05:11 -04:00
|
|
|
queue_id, last_event_id = (res["queue_id"], res["last_event_id"])
|
2012-11-28 22:34:49 -05:00
|
|
|
except Exception:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.exception("Unexpected error subscribing to Zulips")
|
2012-11-28 22:34:49 -05:00
|
|
|
print_status_and_exit(1)
|
2012-11-15 14:24:38 -05:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
# Subscribe to Zephyrs
|
|
|
|
zephyr_subs_to_add = []
|
|
|
|
for (stream, test) in test_streams:
|
|
|
|
if stream == "message":
|
2021-05-28 05:05:11 -04:00
|
|
|
zephyr_subs_to_add.append((stream, "personal", mit_user))
|
2012-11-28 22:34:49 -05:00
|
|
|
else:
|
2021-05-28 05:05:11 -04:00
|
|
|
zephyr_subs_to_add.append((stream, "*", "*"))
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2013-01-02 10:27:23 -05:00
|
|
|
actually_subscribed = False
|
2016-03-10 12:43:31 -05:00
|
|
|
for tries in range(10):
|
2012-11-15 14:24:38 -05:00
|
|
|
try:
|
2022-06-17 14:49:25 -04:00
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZInitialize())
|
|
|
|
zephyr_port = c_ushort()
|
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZOpenPort(byref(zephyr_port)))
|
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZCancelSubscriptions(0))
|
|
|
|
|
|
|
|
zephyr_ctypes.check(
|
|
|
|
zephyr_ctypes.ZSubscribeTo(
|
|
|
|
(zephyr_ctypes.ZSubscription_t * len(zephyr_subs_to_add))(
|
|
|
|
*(
|
|
|
|
zephyr_ctypes.ZSubscription_t(
|
|
|
|
zsub_class=cls.encode(),
|
|
|
|
zsub_classinst=instance.encode(),
|
|
|
|
zsub_recipient=recipient.encode(),
|
|
|
|
)
|
|
|
|
for cls, instance, recipient in zephyr_subs_to_add
|
|
|
|
)
|
|
|
|
),
|
|
|
|
len(zephyr_subs_to_add),
|
|
|
|
0,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
nsubs = c_int()
|
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZRetrieveSubscriptions(0, byref(nsubs)))
|
|
|
|
zsubs = (zephyr_ctypes.ZSubscription_t * nsubs.value)()
|
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZGetSubscriptions(zsubs, byref(nsubs)))
|
|
|
|
zephyr_subs = {
|
|
|
|
(
|
|
|
|
zsub.zsub_class.decode(),
|
|
|
|
zsub.zsub_classinst.decode(),
|
|
|
|
zsub.zsub_recipient.decode(),
|
|
|
|
)
|
|
|
|
for zsub in zsubs
|
|
|
|
}
|
|
|
|
finally:
|
|
|
|
zephyr_ctypes.ZFlushSubscriptions()
|
2013-01-02 10:27:23 -05:00
|
|
|
|
|
|
|
missing = 0
|
2012-11-28 22:34:49 -05:00
|
|
|
for elt in zephyr_subs_to_add:
|
|
|
|
if elt not in zephyr_subs:
|
2021-05-28 07:19:40 -04:00
|
|
|
logging.error(f"Failed to subscribe to {elt}")
|
2013-01-02 10:27:23 -05:00
|
|
|
missing += 1
|
|
|
|
if missing == 0:
|
|
|
|
actually_subscribed = True
|
|
|
|
break
|
2022-06-17 14:49:25 -04:00
|
|
|
except zephyr_ctypes.ZephyrError as e:
|
|
|
|
if e.code == zephyr_ctypes.ZERR_SERVNAK:
|
2013-01-02 10:27:23 -05:00
|
|
|
logger.error("SERVNAK repeatedly received, punting rest of test")
|
|
|
|
else:
|
|
|
|
logger.exception("Exception subscribing to zephyrs")
|
|
|
|
|
|
|
|
if not actually_subscribed:
|
|
|
|
logger.error("Failed to subscribe to zephyrs")
|
|
|
|
print_status_and_exit(1)
|
2012-11-15 14:24:38 -05:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
# Prepare keys
|
2017-05-31 15:20:35 -04:00
|
|
|
zhkeys = {} # type: Dict[str, Tuple[str, str]]
|
|
|
|
hzkeys = {} # type: Dict[str, Tuple[str, str]]
|
2021-05-28 05:03:46 -04:00
|
|
|
|
|
|
|
|
2021-03-10 16:55:13 -05:00
|
|
|
def gen_key(key_dict: Dict[str, Tuple[str, str]]) -> str:
|
2012-12-18 10:54:39 -05:00
|
|
|
bits = str(random.getrandbits(32))
|
|
|
|
while bits in key_dict:
|
|
|
|
# Avoid the unlikely event that we get the same bits twice
|
|
|
|
bits = str(random.getrandbits(32))
|
|
|
|
return bits
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def gen_keys(key_dict: Dict[str, Tuple[str, str]]) -> None:
|
2012-11-28 22:34:49 -05:00
|
|
|
for (stream, test) in test_streams:
|
2012-12-18 10:54:39 -05:00
|
|
|
key_dict[gen_key(key_dict)] = (stream, test)
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
gen_keys(zhkeys)
|
|
|
|
gen_keys(hzkeys)
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2012-12-11 17:38:34 -05:00
|
|
|
notices = []
|
|
|
|
|
|
|
|
# We check for new zephyrs multiple times, to avoid filling the zephyr
|
|
|
|
# receive queue with 30+ messages, which might result in messages
|
|
|
|
# being dropped.
|
2020-04-18 18:59:12 -04:00
|
|
|
def receive_zephyrs() -> None:
|
2022-06-17 14:49:25 -04:00
|
|
|
while zephyr_ctypes.ZPending() != 0:
|
|
|
|
notice = zephyr_ctypes.ZNotice_t()
|
|
|
|
sender = zephyr_ctypes.sockaddr_in()
|
2012-12-11 17:38:34 -05:00
|
|
|
try:
|
2022-06-17 14:49:25 -04:00
|
|
|
zephyr_ctypes.check(zephyr_ctypes.ZReceiveNotice(byref(notice), byref(sender)))
|
|
|
|
except zephyr_ctypes.ZephyrError:
|
2012-12-11 17:38:34 -05:00
|
|
|
logging.exception("Exception receiving zephyrs:")
|
|
|
|
break
|
2022-06-17 14:49:25 -04:00
|
|
|
if notice.z_opcode != b"":
|
2023-01-24 03:52:32 -05:00
|
|
|
zephyr_ctypes.ZFreeNotice(byref(notice))
|
2012-12-11 17:38:34 -05:00
|
|
|
continue
|
|
|
|
notices.append(notice)
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.info("Starting sending messages!")
|
|
|
|
# Send zephyrs
|
|
|
|
zsig = "Timothy Good Abbott"
|
|
|
|
for key, (stream, test) in zhkeys.items():
|
|
|
|
if stream == "message":
|
2012-12-10 10:21:49 -05:00
|
|
|
zwrite_args = ["zwrite", "-n", "-s", zsig, mit_user]
|
2012-11-28 22:34:49 -05:00
|
|
|
else:
|
2012-12-10 10:21:49 -05:00
|
|
|
zwrite_args = ["zwrite", "-n", "-s", zsig, "-c", stream, "-i", "test"]
|
2012-12-18 10:54:39 -05:00
|
|
|
server_failure = send_zephyr(zwrite_args, str(key))
|
|
|
|
if server_failure:
|
|
|
|
# Replace the key we're not sure was delivered with a new key
|
|
|
|
value = zhkeys.pop(key)
|
|
|
|
new_key = gen_key(zhkeys)
|
|
|
|
zhkeys[new_key] = value
|
|
|
|
server_failure_again = send_zephyr(zwrite_args, str(new_key))
|
|
|
|
if server_failure_again:
|
2021-05-28 05:03:46 -04:00
|
|
|
logging.error(
|
|
|
|
"Zephyr server failure twice in a row on keys %s and %s! Aborting."
|
|
|
|
% (key, new_key)
|
|
|
|
)
|
2012-12-18 10:54:39 -05:00
|
|
|
print_status_and_exit(1)
|
|
|
|
else:
|
2021-05-28 07:19:40 -04:00
|
|
|
logging.warning(f"Replaced key {key} with {new_key} due to Zephyr server failure.")
|
2013-01-02 10:36:47 -05:00
|
|
|
receive_zephyrs()
|
2012-12-11 17:38:34 -05:00
|
|
|
|
|
|
|
receive_zephyrs()
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.info("Sent Zephyr messages!")
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2013-08-06 15:32:15 -04:00
|
|
|
# Send Zulips
|
2012-11-28 22:34:49 -05:00
|
|
|
for key, (stream, test) in hzkeys.items():
|
|
|
|
if stream == "message":
|
2021-05-28 05:03:46 -04:00
|
|
|
send_zulip(
|
|
|
|
{
|
|
|
|
"type": "private",
|
|
|
|
"content": str(key),
|
|
|
|
"to": zulip_client.email,
|
|
|
|
}
|
|
|
|
)
|
2012-11-28 22:34:49 -05:00
|
|
|
else:
|
2021-05-28 05:03:46 -04:00
|
|
|
send_zulip(
|
|
|
|
{
|
|
|
|
"type": "stream",
|
|
|
|
"subject": "test",
|
|
|
|
"content": str(key),
|
|
|
|
"to": stream,
|
|
|
|
}
|
|
|
|
)
|
2012-12-11 17:38:34 -05:00
|
|
|
receive_zephyrs()
|
2012-11-28 22:34:49 -05:00
|
|
|
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.info("Sent Zulip messages!")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
|
|
|
# Normally messages manage to forward through in under 3 seconds, but
|
|
|
|
# sleep 10 to give a safe margin since the messages do need to do 2
|
|
|
|
# round trips. This alert is for correctness, not performance, and so
|
|
|
|
# we want it to reliably alert only when messages aren't being
|
|
|
|
# delivered at all.
|
|
|
|
time.sleep(10)
|
2012-12-11 17:38:34 -05:00
|
|
|
receive_zephyrs()
|
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.info("Starting receiving messages!")
|
|
|
|
|
2013-08-06 15:32:15 -04:00
|
|
|
# receive zulips
|
2013-10-08 14:09:31 -04:00
|
|
|
res = zulip_client.get_events(queue_id=queue_id, last_event_id=last_event_id)
|
2021-05-28 05:05:11 -04:00
|
|
|
if "error" in res["result"]:
|
2018-01-08 09:49:02 -05:00
|
|
|
logging.error("Error receiving Zulips!")
|
2021-05-28 05:05:11 -04:00
|
|
|
logging.error(res["msg"])
|
2013-10-08 14:09:31 -04:00
|
|
|
print_status_and_exit(1)
|
2021-05-28 05:05:11 -04:00
|
|
|
messages = [event["message"] for event in res["events"]]
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.info("Finished receiving Zulip messages!")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
2012-12-11 17:38:34 -05:00
|
|
|
receive_zephyrs()
|
|
|
|
logger.info("Finished receiving Zephyr messages!")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
2016-03-11 04:57:29 -05:00
|
|
|
all_keys = set(list(zhkeys.keys()) + list(hzkeys.keys()))
|
2021-05-28 05:03:46 -04:00
|
|
|
|
|
|
|
|
2020-04-18 18:59:12 -04:00
|
|
|
def process_keys(content_list: List[str]) -> Tuple[Dict[str, int], Set[str], Set[str], bool, bool]:
|
2016-09-10 13:56:23 -04:00
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
# Start by filtering out any keys that might have come from
|
|
|
|
# concurrent check-mirroring processes
|
|
|
|
content_keys = [key for key in content_list if key in all_keys]
|
2017-05-31 15:20:35 -04:00
|
|
|
key_counts = {} # type: Dict[str, int]
|
2012-11-28 22:34:49 -05:00
|
|
|
for key in all_keys:
|
|
|
|
key_counts[key] = 0
|
|
|
|
for key in content_keys:
|
|
|
|
key_counts[key] += 1
|
2020-04-09 20:14:01 -04:00
|
|
|
z_missing = {key for key in zhkeys.keys() if key_counts[key] == 0}
|
|
|
|
h_missing = {key for key in hzkeys.keys() if key_counts[key] == 0}
|
2012-11-28 22:34:49 -05:00
|
|
|
duplicates = any(val > 1 for val in key_counts.values())
|
|
|
|
success = all(val == 1 for val in key_counts.values())
|
|
|
|
return key_counts, z_missing, h_missing, duplicates, success
|
|
|
|
|
2021-05-28 05:03:46 -04:00
|
|
|
|
2013-08-06 15:32:15 -04:00
|
|
|
# The h_foo variables are about the messages we _received_ in Zulip
|
2012-11-28 22:34:49 -05:00
|
|
|
# The z_foo variables are about the messages we _received_ in Zephyr
|
|
|
|
h_contents = [message["content"] for message in messages]
|
2022-06-17 14:49:25 -04:00
|
|
|
z_contents = [
|
|
|
|
notice.z_message[: notice.z_message_len].split(b"\0")[1].decode(errors="replace")
|
|
|
|
for notice in notices
|
|
|
|
]
|
2012-11-28 22:34:49 -05:00
|
|
|
(h_key_counts, h_missing_z, h_missing_h, h_duplicates, h_success) = process_keys(h_contents)
|
|
|
|
(z_key_counts, z_missing_z, z_missing_h, z_duplicates, z_success) = process_keys(z_contents)
|
2012-10-19 12:20:52 -04:00
|
|
|
|
2023-01-24 03:52:32 -05:00
|
|
|
for notice in notices:
|
|
|
|
zephyr_ctypes.ZFreeNotice(byref(notice))
|
|
|
|
|
2012-11-28 22:34:49 -05:00
|
|
|
if z_success and h_success:
|
|
|
|
logger.info("Success!")
|
2012-11-15 14:24:38 -05:00
|
|
|
print_status_and_exit(0)
|
2012-11-28 22:34:49 -05:00
|
|
|
elif z_success:
|
|
|
|
logger.info("Received everything correctly in Zephyr!")
|
|
|
|
elif h_success:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.info("Received everything correctly in Zulip!")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
|
|
|
logger.error("Messages received the wrong number of times:")
|
|
|
|
for key in all_keys:
|
|
|
|
if z_key_counts[key] == 1 and h_key_counts[key] == 1:
|
|
|
|
continue
|
|
|
|
if key in zhkeys:
|
|
|
|
(stream, test) = zhkeys[key]
|
2021-05-28 05:03:46 -04:00
|
|
|
logger.warning(
|
|
|
|
"%10s: z got %s, h got %s. Sent via Zephyr(%s): class %s"
|
|
|
|
% (key, z_key_counts[key], h_key_counts[key], test, stream)
|
|
|
|
)
|
2012-11-28 22:34:49 -05:00
|
|
|
if key in hzkeys:
|
|
|
|
(stream, test) = hzkeys[key]
|
2021-05-28 05:03:46 -04:00
|
|
|
logger.warning(
|
|
|
|
"%10s: z got %s. h got %s. Sent via Zulip(%s): class %s"
|
|
|
|
% (key, z_key_counts[key], h_key_counts[key], test, stream)
|
|
|
|
)
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.error("")
|
|
|
|
logger.error("Summary of specific problems:")
|
|
|
|
|
|
|
|
if h_duplicates:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zulip: Received duplicate messages!")
|
|
|
|
logger.error("zulip: This is probably a bug in our message loop detection.")
|
|
|
|
logger.error("zulip: where Zulips go zulip=>zephyr=>zulip")
|
2012-11-28 22:34:49 -05:00
|
|
|
if z_duplicates:
|
|
|
|
logger.error("zephyr: Received duplicate messages!")
|
|
|
|
logger.error("zephyr: This is probably a bug in our message loop detection.")
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zephyr: where Zephyrs go zephyr=>zulip=>zephyr")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
|
|
|
if z_missing_z:
|
|
|
|
logger.error("zephyr: Didn't receive all the Zephyrs we sent on the Zephyr end!")
|
2021-05-28 05:03:46 -04:00
|
|
|
logger.error(
|
|
|
|
"zephyr: This is probably an issue with check-mirroring sending or receiving Zephyrs."
|
|
|
|
)
|
2012-11-28 22:34:49 -05:00
|
|
|
if h_missing_h:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zulip: Didn't receive all the Zulips we sent on the Zulip end!")
|
2021-05-28 05:03:46 -04:00
|
|
|
logger.error(
|
|
|
|
"zulip: This is probably an issue with check-mirroring sending or receiving Zulips."
|
|
|
|
)
|
2012-11-28 22:34:49 -05:00
|
|
|
if z_missing_h:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zephyr: Didn't receive all the Zulips we sent on the Zephyr end!")
|
2012-11-28 22:34:49 -05:00
|
|
|
if z_missing_h == h_missing_h:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zephyr: Including some Zulips that we did receive on the Zulip end.")
|
|
|
|
logger.error("zephyr: This suggests we have a zulip=>zephyr mirroring problem.")
|
2012-11-28 22:34:49 -05:00
|
|
|
logger.error("zephyr: aka the personals mirroring script has issues.")
|
|
|
|
if h_missing_z:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zulip: Didn't receive all the Zephyrs we sent on the Zulip end!")
|
2012-11-28 22:34:49 -05:00
|
|
|
if h_missing_z == z_missing_z:
|
2013-08-06 15:32:15 -04:00
|
|
|
logger.error("zulip: Including some Zephyrs that we did receive on the Zephyr end.")
|
|
|
|
logger.error("zulip: This suggests we have a zephyr=>zulip mirroring problem.")
|
|
|
|
logger.error("zulip: aka the global class mirroring script has issues.")
|
2012-11-28 22:34:49 -05:00
|
|
|
|
2013-11-19 17:51:06 -05:00
|
|
|
zulip_client.deregister(queue_id)
|
2012-11-28 22:34:49 -05:00
|
|
|
print_status_and_exit(1)
|