Files
buzz/perf/test_relay_bus_scaling.py
+1 14fba21e57 Multi-tenant Buzz relay: community_id as a server-resolved key (comprehensive rewrite) (#1321)
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: npub17jjz49l9jjmhhk7cac63j8yt9z555n9cw8vk7v5jz4vzw4ppld5qgj57cc <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Mari <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Sami <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Quinn <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Dawn <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Co-authored-by: Sami <sami@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
2026-06-29 12:39:02 -04:00

66 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Unit tests for the relay bus scaling harness."""
from __future__ import annotations
import argparse
import unittest
import relay_bus_scaling as harness
class RelayBusScalingTests(unittest.TestCase):
def args(self, **overrides: object) -> argparse.Namespace:
defaults = dict(
mode="model",
pods="1,2,4",
communities=64,
events_per_community_per_sec=100.0,
subscribed_communities=1,
interested_pods_per_subscribed_community=0,
redis_url="redis://127.0.0.1:6379/0",
redis_timeout=1.0,
assert_scaling=True,
min_reduction_ratio=0.95,
max_scoped_irrelevant_pct=0.0,
)
defaults.update(overrides)
return argparse.Namespace(**defaults)
def test_scoped_global_channel_matches_relay_topic_shape(self) -> None:
community = "00000000-0000-0000-0000-000000000001"
self.assertEqual(
harness.scoped_global_channel(community),
"buzz:00000000-0000-0000-0000-000000000001:global",
)
def test_model_default_proves_sixty_four_x_reduction_for_one_two_four_pods(self) -> None:
args = self.args()
rows = harness.model_measurements(args, [1, 2, 4])
self.assertEqual([row.pods for row in rows], [1, 2, 4])
self.assertEqual([row.reduction for row in rows], [64.0, 64.0, 64.0])
self.assertEqual([row.new_irrelevant_pct for row in rows], [0.0, 0.0, 0.0])
harness.assert_scaling(args, rows)
def test_assertion_fails_when_scoped_bus_receives_irrelevant_messages(self) -> None:
args = self.args()
mutant_row = harness.Measurement(
pods=4,
old_cluster=25_600,
old_avg_pod=6_400,
old_irrelevant_pct=98.44,
new_cluster=25_600,
new_avg_pod=6_400,
new_irrelevant_pct=98.44,
reduction=1.0,
published=6_400,
)
with self.assertRaises(AssertionError):
harness.assert_scaling(args, [mutant_row])
if __name__ == "__main__":
unittest.main()