Skip to content
Snippets Groups Projects
Commit afa08146 authored by Alexander Aghili's avatar Alexander Aghili
Browse files

updated the view formatting

parent 9c0dfcd6
No related branches found
No related tags found
No related merge requests found
......@@ -4,26 +4,44 @@ from ...utils.util import Logger
from ..helper import KVSMultiClient, KVSTestFixture
from ...utils.kvs_api import DEFAULT_TIMEOUT
def basic_kv_view_accept(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, 2]))
fx.broadcast_view(conductor.get_shard_view())
r = c.put(0, "x", "1")
assert r.ok, f"expected ok for new key, got {r.status_code}"
r = c.put(1, "y", "2")
assert r.ok, f"expected ok for new key, got {r.status_code}"
r = c.get(0, "x")
assert r.ok, f"expected ok for get, got {r.status_code}"
assert r.json()["value"] == "1", f"wrong value returned: {r.json()}"
r = c.get(1, "x")
assert r.ok, f"expected ok for get, got {r.status_code}"
assert r.json()["value"] == "1", f"wrong value returned: {r.json()}"
r = c.get(0, "y")
assert r.ok, f"expected ok for get, got {r.status_code}"
assert r.json()["value"] == "2", f"wrong value returned: {r.json()}"
r = c.get(1, "y")
assert r.ok, f"expected ok for get, got {r.status_code}"
assert r.json()["value"] == "2", f"wrong value returned: {r.json()}"
return True, 0
def basic_kv_1(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, 2))
conductor.add_shard("shard1", conductor.get_nodes([0]))
conductor.add_shard("shard2", conductor.get_nodes([1]))
fx.broadcast_view(conductor.get_shard_view())
# examples of modifying shards
# conductor.add_shard("shard2", conductor.get_nodes(2, 3))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.add_node_to_shard("shard2", conductor.get_node(3))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.remove_node_from_shard("shard1", conductor.get_node(0))
# fx.broadcast_view(conductor.get_shard_view())
#
# conductor.remove_shard("shard1")
# fx.broadcast_view(conductor.get_shard_view())
r = c.put(0, "x", "1")
assert r.ok, f"expected ok for new key, got {r.status_code}"
......@@ -49,4 +67,4 @@ def basic_kv_1(conductor: ClusterConductor, dir, log: Logger):
return True, 0
BASIC_TESTS = [TestCase("basic_kv_1", basic_kv_1)]
BASIC_TESTS = [TestCase("basic_kv_1", basic_kv_1), TestCase("basic_kv_view_accept", basic_kv_view_accept)]
......@@ -463,8 +463,14 @@ class ClusterConductor:
def get_node(self, index):
return self.nodes[index]
def get_nodes(self, node_indexes: List[int]):
node_list = []
for i in node_indexes:
node_list.append(self.nodes[i])
return node_list
# from `start`` to `end`. Note that `end` is not inclusive
def get_nodes(self, start=0, end=None):
def get_nodes_seq(self, start=0, end=None):
if start < 0:
raise ValueError("Start index cannot be negative.")
if end is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment