From 498ab7275cef524fc034366d445f8391601b7df9 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Thu, 18 May 2023 13:20:47 +0300
Subject: [PATCH] test: use create_space api in tests

---
 test/int/test_ddl.py | 34 ++++++++++++----------------------
 test/int/test_dml.py | 16 +++++++---------
 2 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/test/int/test_ddl.py b/test/int/test_ddl.py
index 2c60202653..94dbb2200b 100644
--- a/test/int/test_ddl.py
+++ b/test/int/test_ddl.py
@@ -95,21 +95,16 @@ def test_ddl_create_space_bulky(cluster: Cluster):
     ############################################################################
     # Propose a space creation which will succeed
 
-    commit_index = i1.propose_create_space(
+    cluster.create_space(
         dict(
             id=space_id,
             name="stuff",
             format=[dict(name="id", type="unsigned", is_nullable=False)],
-            primary_key=[dict(field="id")],
-            distribution=dict(kind="global"),
+            primary_key=["id"],
+            distribution="global",
         ),
     )
 
-    i1.call(".proc_sync_raft", commit_index, (3, 0))
-    i2.call(".proc_sync_raft", commit_index, (3, 0))
-    i3.call(".proc_sync_raft", commit_index, (3, 0))
-    i4.call(".proc_sync_raft", commit_index, (3, 0))
-
     # This time schema version did change
     assert i1.call("box.space._pico_property:get", "current_schema_version")[1] == 2
     assert i2.call("box.space._pico_property:get", "current_schema_version")[1] == 2
@@ -210,7 +205,7 @@ def test_ddl_create_sharded_space(cluster: Cluster):
     # Propose a space creation which will succeed
     schema_version = i1.next_schema_version()
     space_id = 679
-    index = i1.propose_create_space(
+    cluster.create_space(
         dict(
             id=space_id,
             name="stuff",
@@ -219,14 +214,11 @@ def test_ddl_create_sharded_space(cluster: Cluster):
                 dict(name="foo", type="integer", is_nullable=False),
                 dict(name="bar", type="string", is_nullable=False),
             ],
-            primary_key=[dict(field="id")],
-            distribution=dict(kind="sharded_implicitly", sharding_key=["foo", "bar"]),
+            primary_key=["id"],
+            distribution=dict(sharding_key=["foo", "bar"], sharding_fn="murmur3"),
         ),
     )
 
-    i1.call(".proc_sync_raft", index, (3, 0))
-    i2.call(".proc_sync_raft", index, (3, 0))
-
     ############################################################################
     # Space was created and is operable
     pico_space_def = [
@@ -381,10 +373,10 @@ def test_successful_wakeup_after_ddl(cluster: Cluster):
         id=space_id,
         name="space_name_conflict",
         format=[dict(name="id", type="unsigned", is_nullable=False)],
-        primary_key=[dict(field="id")],
-        distribution=dict(kind="global"),
+        primary_key=["id"],
+        distribution="global",
     )
-    index = i1.propose_create_space(space_def)
+    index = i1.create_space(space_def)
 
     i2.call(".proc_sync_raft", index, (3, 0))
     i3.call(".proc_sync_raft", index, (3, 0))
@@ -416,18 +408,16 @@ def test_ddl_from_snapshot(cluster: Cluster):
     # TODO: check other ddl operations
     # Propose a space creation which will succeed
     space_id = 632
-    index = i1.propose_create_space(
+    cluster.create_space(
         dict(
             id=space_id,
             name="stuff",
             format=[dict(name="id", type="unsigned", is_nullable=False)],
-            primary_key=[dict(field="id")],
-            distribution=dict(kind="sharded_implicitly", sharding_key=["id"]),
+            primary_key=["id"],
+            distribution=dict(sharding_key=["id"], sharding_fn="murmur3"),
         ),
     )
 
-    i2.call(".proc_sync_raft", index, (3, 0))
-
     tt_space_def = [
         space_id,
         1,
diff --git a/test/int/test_dml.py b/test/int/test_dml.py
index bf948c5bbf..fd7020434f 100644
--- a/test/int/test_dml.py
+++ b/test/int/test_dml.py
@@ -13,7 +13,7 @@ def test_global_space_dml_catchup_by_log(cluster: Cluster):
     # Catcher-upper replicaset follower
     i5 = cluster.add_instance(wait_online=True, replicaset_id="r2")
 
-    index = i1.ddl_create_space(
+    cluster.create_space(
         dict(
             id=812,
             name="candy",
@@ -22,11 +22,10 @@ def test_global_space_dml_catchup_by_log(cluster: Cluster):
                 dict(name="kind", type="string", is_nullable=False),
                 dict(name="kilos", type="number", is_nullable=False),
             ],
-            primary_key=[dict(field="id")],
-            distribution=dict(kind="global"),
+            primary_key=["id"],
+            distribution="global",
         ),
     )
-    i2.raft_wait_index(index, 3)
 
     # Some dml
     index = i1.cas("insert", "candy", [1, "marshmallow", 2.7])
@@ -103,7 +102,7 @@ def test_global_space_dml_catchup_by_snapshot(cluster: Cluster):
     # Catcher-upper replicaset follower
     i5 = cluster.add_instance(wait_online=True, replicaset_id="r2")
 
-    index = i1.ddl_create_space(
+    cluster.create_space(
         dict(
             id=812,
             name="candy",
@@ -112,11 +111,10 @@ def test_global_space_dml_catchup_by_snapshot(cluster: Cluster):
                 dict(name="kind", type="string", is_nullable=False),
                 dict(name="kilos", type="number", is_nullable=False),
             ],
-            primary_key=[dict(field="id")],
-            distribution=dict(kind="global"),
-        ),
+            primary_key=["id"],
+            distribution="global",
+        )
     )
-    i2.raft_wait_index(index, 3)
 
     # Some dml
     index = i1.cas("insert", "candy", [1, "marshmallow", 2.7])
-- 
GitLab