diff --git a/tests/integration/test_s3_plain_rewritable/__init__.py b/tests/integration/test_s3_plain_rewritable/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/integration/test_s3_plain_rewritable/configs/storage_conf.xml b/tests/integration/test_s3_plain_rewritable/configs/storage_conf.xml new file mode 100644 index 00000000000..1e4641fc8b2 --- /dev/null +++ b/tests/integration/test_s3_plain_rewritable/configs/storage_conf.xml @@ -0,0 +1,21 @@ + + + + + s3_plain_rewritable + http://minio1:9001/root/data/ + minio + minio123 + + + + + +
+ disk_s3_plain_rewritable +
+
+
+
+
+
diff --git a/tests/integration/test_s3_plain_rewritable/test.py b/tests/integration/test_s3_plain_rewritable/test.py new file mode 100644 index 00000000000..ac35da01897 --- /dev/null +++ b/tests/integration/test_s3_plain_rewritable/test.py @@ -0,0 +1,78 @@ +import pytest +import random +import string + +from helpers.cluster import ClickHouseCluster + +cluster = ClickHouseCluster(__file__) +node = cluster.add_instance( + "node", + main_configs=["configs/storage_conf.xml"], + with_minio=True, + stay_alive=True, +) + +insert_values = [ + "(0,'data'),(1,'data')", + ",".join( + f"({i},'{''.join(random.choices(string.ascii_lowercase, k=5))}')" + for i in range(10) + ), +] + + +@pytest.fixture(scope="module", autouse=True) +def start_cluster(): + try: + cluster.start() + yield cluster + finally: + cluster.shutdown() + + +def test_insert(): + for index, value in enumerate(insert_values): + node.query( + """ + CREATE TABLE test_{} ( + id Int64, + data String + ) ENGINE=MergeTree() + ORDER BY id + SETTINGS storage_policy='s3_plain_rewritable' + """.format( + index + ) + ) + + node.query("INSERT INTO test_{} VALUES {}".format(index, value)) + assert ( + node.query("SELECT * FROM test_{} ORDER BY id FORMAT Values".format(index)) + == value + ) + + +def test_restart(): + for index, value in enumerate(insert_values): + assert ( + node.query("SELECT * FROM test_{} ORDER BY id FORMAT Values".format(index)) + == value + ) + node.restart_clickhouse() + + for index, value in enumerate(insert_values): + assert ( + node.query("SELECT * FROM test_{} ORDER BY id FORMAT Values".format(index)) + == value + ) + + +def test_drop(): + for index, value in enumerate(insert_values): + node.query("DROP TABLE IF EXISTS test_{} SYNC".format(index)) + + it = cluster.minio_client.list_objects( + cluster.minio_bucket, "data/", recursive=True + ) + + assert len(list(it)) == 0