From 3a66896635eba09e3a96671e1211e7e64143d339 Mon Sep 17 00:00:00 2001 From: zphrs <z@zephiris.dev> Date: Fri, 14 Mar 2025 22:11:39 -0700 Subject: [PATCH] formatting --- tests/proxy/basic_proxy.py | 52 +++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/tests/proxy/basic_proxy.py b/tests/proxy/basic_proxy.py index 6366192..f0cf16a 100644 --- a/tests/proxy/basic_proxy.py +++ b/tests/proxy/basic_proxy.py @@ -4,6 +4,7 @@ from ...utils.util import Logger from ..helper import KVSMultiClient, KVSTestFixture from ...utils.kvs_api import DEFAULT_TIMEOUT + def basic_proxy_one_client(conductor: ClusterConductor, dir, log: Logger): with KVSTestFixture(conductor, dir, log, node_count=4) as fx: c = KVSMultiClient(fx.clients, "client", log) @@ -56,7 +57,7 @@ def basic_proxy_many_clients(conductor: ClusterConductor, dir, log: Logger): node_to_put += 1 node_to_put = node_to_put % 7 - r = c.get_all(0, timeout=None) # should get all of shard 1's keys + r = c.get_all(0, timeout=None) # should get all of shard 1's keys assert r.ok, f"expected ok for get, got {r.status_code}" items = r.json()["items"] keys = items.keys() @@ -66,31 +67,42 @@ def basic_proxy_many_clients(conductor: ClusterConductor, dir, log: Logger): assert r.json()["value"] == items[key], f"wrong value returned: {r.json()}" return True, "ok" - -def basic_proxy_partitioned_shards(conductor: ClusterConductor, dir, log: Logger, timeout= 5*DEFAULT_TIMEOUT): + + +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") + 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. - 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_one_client", basic_proxy_one_client), TestCase("basic_proxy_many_clients", basic_proxy_many_clients), TestCase("basic_proxy_partitioned_shards", basic_proxy_partitioned_shards)] +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. + 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_one_client", basic_proxy_one_client), + TestCase("basic_proxy_many_clients", basic_proxy_many_clients), + TestCase("basic_proxy_partitioned_shards", basic_proxy_partitioned_shards), +] -- GitLab