diff --git a/tests/proxy/basic_proxy.py b/tests/proxy/basic_proxy.py new file mode 100644 index 0000000000000000000000000000000000000000..3dd87d3fa06d9fad19b432b129ee340bcec4827f --- /dev/null +++ b/tests/proxy/basic_proxy.py @@ -0,0 +1,43 @@ +from ...utils.containers import ClusterConductor +from ...utils.testcase import TestCase +from ...utils.util import Logger +from ..helper import KVSMultiClient, KVSTestFixture +from ...utils.kvs_api import DEFAULT_TIMEOUT + +def basic_proxy(conductor: ClusterConductor, dir, log: Logger): + 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])) + fx.broadcast_view(conductor.get_shard_view()) + # test 1 + # put 50 keys (at least one proxy expected here) + # get_all() on one shard + # then ask the other shard for that key (proxy MUST happen here) + + node_to_put = 0 + base_key = "key" + for i in range(0, 51): + r = c.put(node_to_put, f"{base_key}{i}", f"{i}", timeout=10) + assert r.ok, f"expected ok for new key, got {r.status_code}" + node_to_put += 1 + node_to_put = node_to_put % 4 + + r = c.get_all(0, timeout=10) # should get all of shard 1's keys + assert r.ok, f"expected ok for get, got {r.status_code}" + res = r.json()["items"] + print("res-- {}", res) + + return True, "ok" + +def partitioned_shards(conductor: ClusterConductor, dir, log: Logger): + with KVSTestFixture(conductor, dir, log, node_count=4) as fx: + ### + # 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" + +PROXY_TESTS = [TestCase("basic_proxy", basic_proxy)] \ No newline at end of file