diff --git a/tests/proxy/basic_proxy.py b/tests/proxy/basic_proxy.py index e2a87627e78dd5a27723a5c0ca759a4e234c1815..8180f830bf43282dda26184a03fbf2a24d312b61 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