Skip to content

Commit

Permalink
Reformat the previously added test with black
Browse files Browse the repository at this point in the history
  • Loading branch information
alkorgun committed Jul 30, 2023
1 parent 9c5b96e commit 7725c53
Showing 1 changed file with 29 additions and 16 deletions.
Expand Up @@ -56,7 +56,7 @@ def cluster():
"configs/users.d/default.xml",
],
with_zookeeper=True,
stay_alive=True
stay_alive=True,
)
for name in [NODE01, NODE02, NODE03]:
cluster.add_instance(name, **common_kwargs)
Expand All @@ -78,45 +78,54 @@ def test_create_alter_drop_on_cluster(cluster):

def check_collections_empty():
for name, node in list(cluster.instances.items()):
assert "0" == node.query(q_count_collections).strip(), f"{SYSTEM_TABLE} is not empty on {name}"
assert (
"0" == node.query(q_count_collections).strip()
), f"{SYSTEM_TABLE} is not empty on {name}"

foobar_final_state = {
"name": "foobar",
"collection": {"a": "3"}
}
foobar_final_state = {"name": "foobar", "collection": {"a": "3"}}
collection_present_on_first_node_final_state = {
"name": "collection_present_on_first_node",
"collection": {"a": "1", "s": CHECK_STRING_VALUE, "x": "0", "y": "-1"}
"collection": {"a": "1", "s": CHECK_STRING_VALUE, "x": "0", "y": "-1"},
}
expected_state = {
NODE01: [foobar_final_state, collection_present_on_first_node_final_state],
NODE02: [foobar_final_state],
NODE03: [foobar_final_state]
NODE03: [foobar_final_state],
}

q_get_collections = f"select * from {SYSTEM_TABLE} order by name desc format JSON"

def check_state():
for name, node in list(cluster.instances.items()):
result = loads(node.query(q_get_collections))["data"]
logging.debug('%s ?= %s', dumps(result), dumps(expected_state[name]))
assert expected_state[name] == result, f"invalid {SYSTEM_TABLE} content on {name}: {result}"
logging.debug("%s ?= %s", dumps(result), dumps(expected_state[name]))
assert (
expected_state[name] == result
), f"invalid {SYSTEM_TABLE} content on {name}: {result}"

check_collections_empty()

# create executed on the first node
node = cluster.instances[NODE01]
node.query(f"{STMT_CREATE} foobar AS a=1, b=2")
node.query(f"{STMT_CREATE} IF NOT EXISTS foobar ON CLUSTER 'cluster' AS a=1, b=2, c=3")
node.query(f"{STMT_CREATE} collection_present_on_first_node AS a=1, b=2, s='{CHECK_STRING_VALUE}', x=0, y=-1")
node.query(
f"{STMT_CREATE} IF NOT EXISTS foobar ON CLUSTER 'cluster' AS a=1, b=2, c=3"
)
node.query(
f"{STMT_CREATE} collection_present_on_first_node AS a=1, b=2, s='{CHECK_STRING_VALUE}', x=0, y=-1"
)

# alter executed on the second node
node = cluster.instances[NODE02]
node.query(f"{STMT_ALTER} foobar ON CLUSTER 'cluster' SET a=2, c=3")
node.query(f"{STMT_ALTER} foobar ON CLUSTER 'cluster' DELETE b")
node.query(f"{STMT_ALTER} foobar ON CLUSTER 'cluster' SET a=3 DELETE c")
node.query(f"{STMT_ALTER} IF EXISTS collection_absent_ewerywhere ON CLUSTER 'cluster' DELETE b")
node.query(f"{STMT_ALTER} IF EXISTS collection_present_on_first_node ON CLUSTER 'cluster' DELETE b")
node.query(
f"{STMT_ALTER} IF EXISTS collection_absent_ewerywhere ON CLUSTER 'cluster' DELETE b"
)
node.query(
f"{STMT_ALTER} IF EXISTS collection_present_on_first_node ON CLUSTER 'cluster' DELETE b"
)

check_state()
for node in list(cluster.instances.values()):
Expand All @@ -126,8 +135,12 @@ def check_state():
# drop executed on the third node
node = cluster.instances[NODE03]
node.query(f"{STMT_DROP} foobar ON CLUSTER 'cluster'")
node.query(f"{STMT_DROP} IF EXISTS collection_absent_ewerywhere ON CLUSTER 'cluster'")
node.query(f"{STMT_DROP} IF EXISTS collection_present_on_first_node ON CLUSTER 'cluster'")
node.query(
f"{STMT_DROP} IF EXISTS collection_absent_ewerywhere ON CLUSTER 'cluster'"
)
node.query(
f"{STMT_DROP} IF EXISTS collection_present_on_first_node ON CLUSTER 'cluster'"
)

check_collections_empty()
for node in list(cluster.instances.values()):
Expand Down

0 comments on commit 7725c53

Please sign in to comment.