Reformat the previously added test with black

This commit is contained in:
Илья Коргун 2023-07-30 09:42:42 +03:00
parent 9c5b96e26c
commit 7725c53408

View File

@ -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)
@ -78,20 +78,19 @@ 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"
@ -99,24 +98,34 @@ def test_create_alter_drop_on_cluster(cluster):
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()):
@ -126,8 +135,12 @@ def test_create_alter_drop_on_cluster(cluster):
# 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()):