snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
83
tools/tests/test_check_rabbitmq_queue.py
Normal file
83
tools/tests/test_check_rabbitmq_queue.py
Normal file
@@ -0,0 +1,83 @@
|
||||
import time
|
||||
from unittest import TestCase, mock
|
||||
|
||||
from scripts.lib.check_rabbitmq_queue import CRITICAL, OK, UNKNOWN, WARNING, analyze_queue_stats
|
||||
|
||||
|
||||
class AnalyzeQueueStatsTests(TestCase):
|
||||
def test_no_stats_available(self) -> None:
|
||||
result = analyze_queue_stats("name", {}, 0)
|
||||
self.assertEqual(result["status"], UNKNOWN)
|
||||
|
||||
def test_queue_stuck(self) -> None:
|
||||
"""Last update > 5 minutes ago and there's events in the queue."""
|
||||
|
||||
result = analyze_queue_stats("name", {"update_time": time.time() - 301}, 100)
|
||||
self.assertEqual(result["status"], CRITICAL)
|
||||
self.assertIn("queue appears to be stuck", result["message"])
|
||||
|
||||
def test_queue_just_started(self) -> None:
|
||||
"""
|
||||
We just started processing a burst of events, and haven't processed enough
|
||||
to log productivity statistics yet.
|
||||
"""
|
||||
result = analyze_queue_stats(
|
||||
"name",
|
||||
{
|
||||
"update_time": time.time(),
|
||||
"recent_average_consume_time": None,
|
||||
},
|
||||
10000,
|
||||
)
|
||||
self.assertEqual(result["status"], OK)
|
||||
|
||||
def test_queue_normal(self) -> None:
|
||||
"""10000 events and each takes a second => it'll take a long time to empty."""
|
||||
result = analyze_queue_stats(
|
||||
"name",
|
||||
{
|
||||
"update_time": time.time(),
|
||||
"queue_last_emptied_timestamp": time.time() - 10000,
|
||||
"recent_average_consume_time": 1,
|
||||
},
|
||||
10000,
|
||||
)
|
||||
self.assertEqual(result["status"], CRITICAL)
|
||||
self.assertIn("clearing the backlog", result["message"])
|
||||
|
||||
# If we're doing 10K/sec, it's OK.
|
||||
result = analyze_queue_stats(
|
||||
"name",
|
||||
{
|
||||
"update_time": time.time(),
|
||||
"queue_last_emptied_timestamp": time.time() - 10000,
|
||||
"recent_average_consume_time": 0.0001,
|
||||
},
|
||||
10000,
|
||||
)
|
||||
self.assertEqual(result["status"], OK)
|
||||
|
||||
# Verify logic around whether it'll take MAX_SECONDS_TO_CLEAR to clear queue.
|
||||
with mock.patch.dict("scripts.lib.check_rabbitmq_queue.MAX_SECONDS_TO_CLEAR", {"name": 10}):
|
||||
result = analyze_queue_stats(
|
||||
"name",
|
||||
{
|
||||
"update_time": time.time(),
|
||||
"queue_last_emptied_timestamp": time.time() - 10000,
|
||||
"recent_average_consume_time": 1,
|
||||
},
|
||||
11,
|
||||
)
|
||||
self.assertEqual(result["status"], WARNING)
|
||||
self.assertIn("clearing the backlog", result["message"])
|
||||
|
||||
result = analyze_queue_stats(
|
||||
"name",
|
||||
{
|
||||
"update_time": time.time(),
|
||||
"queue_last_emptied_timestamp": time.time() - 10000,
|
||||
"recent_average_consume_time": 1,
|
||||
},
|
||||
9,
|
||||
)
|
||||
self.assertEqual(result["status"], OK)
|
||||
Reference in New Issue
Block a user