Skip to content

Commit

Permalink
cluster: use tcs api calls in tests
Browse files Browse the repository at this point in the history
It was CRUD requests to the config_storage space in integration tests
for `tt cluster publish/show`.

After the patch these tests use tcs API calls.
  • Loading branch information
themilchenko authored and oleg-jukovec committed Aug 1, 2024
1 parent 62e6855 commit 8421eff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
28 changes: 14 additions & 14 deletions test/integration/cluster/test_cluster_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,19 +804,17 @@ def test_cluster_publish_cluster(tt_cmd,
if auth and instance_name == "etcd":
instance.disable_auth()
conn = instance.conn()
get_response = ""
content = ""
if instance_name == "etcd":
etcd_content, _ = conn.get("/prefix/config/all")
get_response = etcd_content.decode("utf-8")
content, _ = conn.get("/prefix/config/all")
content = content.decode("utf-8")
else:
tcs_content = conn.select(
space_name="config_storage", key="/prefix/config/all"
)
content = conn.call("config.storage.get", "/prefix/config/all")
# We need first selected value with field 'value' which is 1st index.
if len(tcs_content) > 0:
get_response = tcs_content[0][1]
if len(content) > 0:
content = content[0]["data"][0]["value"]
assert "" == publish_output
assert valid_cluster_cfg == get_response
assert valid_cluster_cfg == content
finally:
if instance_name == "etcd":
instance.disable_auth()
Expand Down Expand Up @@ -884,9 +882,9 @@ def test_cluster_publish_instance(tt_cmd, tmpdir_with_cfg, instance_name, reques
content, _ = conn.get("/prefix/config/all")
content = content.decode("utf-8")
else:
content = conn.select(space_name="config_storage", key="/prefix/config/all")
content = conn.call("config.storage.get", "/prefix/config/all")
if len(content) > 0:
content = content[0][1]
content = content[0]["data"][0]["value"]

assert "" == publish_output
assert valid_cluster_cfg.replace("3301", "3303") == content
Expand Down Expand Up @@ -955,9 +953,9 @@ def test_cluster_publish_key(tt_cmd, tmpdir_with_cfg, instance_name, request, fi
content, _ = conn.get("/prefix/config/anykey")
content = content.decode("utf-8")
else:
content = conn.select(space_name="config_storage", key="/prefix/config/anykey")
content = conn.call("config.storage.get", "/prefix/config/anykey")
if len(content) > 0:
content = content[0][1]
content = content[0]["data"][0]["value"]

assert "" == publish_output
assert valid_cluster_cfg.replace("3301", "3303") == content
Expand Down Expand Up @@ -1041,7 +1039,9 @@ def test_cluster_publish_instance_not_exist(
content, _ = conn.get("/prefix/config/all")
content = content.decode("utf-8")
else:
content = conn.select(space_name="config_storage", key="/prefix/config/all")
content = conn.call("config.storage.get", "/prefix/config/all")
if len(content) > 0:
content = content[0]["data"][0]["value"]
assert (
"""groups:
group-001:
Expand Down
22 changes: 6 additions & 16 deletions test/integration/cluster/test_cluster_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,7 @@ def test_cluster_show_config_cluster(
if instance_name == "etcd":
conn.put("/prefix/config/all", config)
else:
conn.insert(
space_name="config_storage", values=["/prefix/config/all", config, 2]
)
conn.call("config.storage.put", "/prefix/config/all", config)

if auth and instance_name == "etcd":
instance.enable_auth()
Expand Down Expand Up @@ -530,9 +528,7 @@ def test_cluster_show_config_instance(tt_cmd,
if instance_name == "etcd":
conn.put("/prefix/config/", config)
else:
conn.insert(
space_name="config_storage", values=["/prefix/config/all", config, 2]
)
conn.call("config.storage.put", "/prefix/config/all", config)
creds = (
f"{instance.connection_username}:{instance.connection_password}@"
if instance_name == "tcs"
Expand Down Expand Up @@ -577,10 +573,7 @@ def test_cluster_show_config_key(tt_cmd, tmpdir_with_cfg, instance_name, request
if instance_name == "etcd":
conn.put("/prefix/config/anykey", valid_cluster_cfg)
else:
conn.insert(
space_name="config_storage",
values=["/prefix/config/anykey", valid_cluster_cfg, 2],
)
conn.call("config.storage.put", "/prefix/config/anykey", valid_cluster_cfg)
creds = (
f"{instance.connection_username}:{instance.connection_password}@"
if instance_name == "tcs"
Expand Down Expand Up @@ -622,10 +615,7 @@ def test_cluster_show_config_key_instance(
if instance_name == "etcd":
conn.put("/prefix/config/anykey", valid_cluster_cfg)
else:
conn.insert(
space_name="config_storage",
values=["/prefix/config/anykey", valid_cluster_cfg, 2],
)
conn.call("config.storage.put", "/prefix/config/anykey", valid_cluster_cfg)
creds = (
f"{instance.connection_username}:{instance.connection_password}@"
if instance_name == "tcs"
Expand Down Expand Up @@ -676,9 +666,9 @@ def test_cluster_show_config_no_instance(
instances:
"""
if instance_name == "etcd":
conn.put("/prefix/config/", config)
conn.put("/prefix/config/all", config)
else:
conn.insert(space_name="config_storage", values=["/prefix/config/", config, 2])
conn.call("config.storage.put", "/prefix/config/all", config)
creds = (
f"{instance.connection_username}:{instance.connection_password}@"
if instance_name == "tcs"
Expand Down

0 comments on commit 8421eff

Please sign in to comment.