From 1c2c03c95ba7ccb3fe650ebc9acd4394d9e872a5 Mon Sep 17 00:00:00 2001 From: ananyabalagere <abalagere@gmail.com> Date: Thu, 13 Mar 2025 22:05:50 -0700 Subject: [PATCH] test 2 for proxy --- tests/proxy/basic_proxy.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/proxy/basic_proxy.py b/tests/proxy/basic_proxy.py index e2a8762..8180f83 100644 --- a/tests/proxy/basic_proxy.py +++ b/tests/proxy/basic_proxy.py @@ -34,14 +34,30 @@ def basic_proxy(conductor: ClusterConductor, dir, log: Logger): return True, "ok" -def partitioned_shards(conductor: ClusterConductor, dir, log: Logger): +def basic_proxy_partitioned_shards(conductor: ClusterConductor, dir, log: Logger, timeout= 5*DEFAULT_TIMEOUT): with KVSTestFixture(conductor, dir, log, node_count=4) as fx: + c = KVSMultiClient(fx.clients, "client", log) + conductor.add_shard("shard1", conductor.get_nodes([0, 1])) + conductor.add_shard("shard2", conductor.get_nodes([2, 3])) + conductor.create_partition([2,3], "secondshard") + fx.broadcast_view(conductor.get_shard_view()) + + helper(c, timeout=timeout) + return True, "ok" + +def helper(c: KVSMultiClient, timeout= 5*DEFAULT_TIMEOUT): ### # test 2 # partition the shards # put a bunch of keys # we MUST probablistically encounter some hanging there. # have a time out where if it doesnt hang after like 50 keys, then its just wrong. - return True, "ok" + node_to_put = 0 + base_key = "key" + for i in range(0, 50): + r = c.put(node_to_put, f"{base_key}{i}", f"{i}", timeout=10) + assert r.ok or r.status_code == 408, f"expected ok for new key, got {r.status_code}" + node_to_put += 1 + node_to_put = node_to_put % 4 -PROXY_TESTS = [TestCase("basic_proxy", basic_proxy)] \ No newline at end of file +PROXY_TESTS = [TestCase("basic_proxy", basic_proxy), TestCase("basic_proxy_partitioned_shards", basic_proxy_partitioned_shards)] \ No newline at end of file -- GitLab