add test_encrypted_disk integration test

This commit is contained in:
Alexandra 2021-05-23 00:18:59 +00:00
parent 928c8bf1de
commit 9029ca8c36
3 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,58 @@
<?xml version="1.0"?>
<yandex>
<storage_configuration>
<disks>
<disk_s3>
<type>s3</type>
<endpoint>http://minio1:9001/root/data/</endpoint>
<access_key_id>minio</access_key_id>
<secret_access_key>minio123</secret_access_key>
</disk_s3>
<disk_memory>
<type>memory</type>
</disk_memory>
<disk_local>
<type>local</type>
<path>/disk/</path>
</disk_local>
<disk_s3_encrypted>
<type>encrypted</type>
<disk>disk_s3</disk>
<path>encrypted/</path>
<key>1234567812345678</key>
</disk_s3_encrypted>
<disk_local_encrypted>
<type>encrypted</type>
<disk>disk_local</disk>
<path>encrypted/</path>
<key>abcdefghijklmnop</key>
</disk_local_encrypted>
</disks>
<policies>
<encrypted_policy>
<volumes>
<main>
<disk>disk_local_encrypted</disk>
</main>
</volumes>
</encrypted_policy>
<local_policy>
<volumes>
<main>
<disk>disk_local</disk>
</main>
<external>
<disk>disk_local_encrypted</disk>
</external>
</volumes>
</local_policy>
<s3_policy>
<volumes>
<main>
<disk>disk_s3</disk>
</main>
</volumes>
</s3_policy>
</policies>
</storage_configuration>
</yandex>

View File

@ -0,0 +1,68 @@
import pytest
from helpers.cluster import ClickHouseCluster
@pytest.fixture(scope="module")
def cluster():
try:
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node",
main_configs=["configs/storage.xml"],
tmpfs=["/disk:size=100M"],
with_minio=True)
cluster.start()
yield cluster
finally:
cluster.shutdown()
@pytest.mark.parametrize("policy", ["encrypted_policy", "local_policy", "s3_policy"])
def test_encrypted_disk(cluster, policy):
node = cluster.instances["node"]
node.query(
"""
CREATE TABLE encrypted_test (
id Int64,
data String
) ENGINE=MergeTree()
ORDER BY id
SETTINGS storage_policy='{}'
""".format(policy)
)
node.query("INSERT INTO encrypted_test VALUES (0,'data'),(1,'data')")
select_query = "SELECT * FROM encrypted_test ORDER BY id FORMAT Values"
assert node.query(select_query) == "(0,'data'),(1,'data')"
node.query("INSERT INTO encrypted_test VALUES (2,'data'),(3,'data')")
node.query("OPTIMIZE TABLE encrypted_test FINAL")
assert node.query(select_query) == "(0,'data'),(1,'data'),(2,'data'),(3,'data')"
node.query("DROP TABLE IF EXISTS encrypted_test NO DELAY")
@pytest.mark.parametrize("policy,disk,encrypted_disk", [("local_policy", "disk_local", "disk_local_encrypted"), ('s3_policy', 'disk_s3', 'disk_s3_encrypted')])
def test_part_move(cluster, policy, disk, encrypted_disk):
node = cluster.instances["node"]
node.query(
"""
CREATE TABLE encrypted_test (
id Int64,
data String
) ENGINE=MergeTree()
ORDER BY id
SETTINGS storage_policy='{}'
""".format(policy)
)
node.query("INSERT INTO encrypted_test VALUES (0,'data'),(1,'data')")
select_query = "SELECT * FROM encrypted_test ORDER BY id FORMAT Values"
assert node.query(select_query) == "(0,'data'),(1,'data')"
node.query("ALTER TABLE encrypted_test MOVE PART 'all_1_1_0' TO DISK '{}'".format(encrypted_disk))
assert node.query(select_query) == "(0,'data'),(1,'data')"
node.query("ALTER TABLE encrypted_test MOVE PART 'all_1_1_0' TO DISK '{}'".format(disk))
assert node.query(select_query) == "(0,'data'),(1,'data')"
node.query("DROP TABLE IF EXISTS encrypted_test NO DELAY")