From 8421eff8c7d7ba2c9f38483805c2bc6dc7851933 Mon Sep 17 00:00:00 2001 From: themilchenko Date: Wed, 31 Jul 2024 11:54:11 +0300 Subject: [PATCH] cluster: use tcs api calls in tests 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. --- .../cluster/test_cluster_publish.py | 28 +++++++++---------- test/integration/cluster/test_cluster_show.py | 22 ++++----------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/test/integration/cluster/test_cluster_publish.py b/test/integration/cluster/test_cluster_publish.py index 0be0e8413..f87417208 100644 --- a/test/integration/cluster/test_cluster_publish.py +++ b/test/integration/cluster/test_cluster_publish.py @@ -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() @@ -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 @@ -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 @@ -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: diff --git a/test/integration/cluster/test_cluster_show.py b/test/integration/cluster/test_cluster_show.py index 39302178a..702023ed4 100644 --- a/test/integration/cluster/test_cluster_show.py +++ b/test/integration/cluster/test_cluster_show.py @@ -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() @@ -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" @@ -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" @@ -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" @@ -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"