Skip to content

Commit c6a1f20

Browse files
committed
Parametrize tests with pools encryption
1 parent 33f5bfa commit c6a1f20

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

ydb/tests/functional/tenants/test_auth_system_views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def ydb_cluster_configuration():
5757

5858

5959
@pytest.fixture(scope='module')
60-
def ydb_configurator(ydb_cluster_configuration):
61-
config_generator = KikimrConfigGenerator(**ydb_cluster_configuration)
60+
def ydb_configurator(ydb_cluster_configuration_with_encryption_parametrized):
61+
config_generator = KikimrConfigGenerator(**ydb_cluster_configuration_with_encryption_parametrized)
6262
config_generator.yaml_config['auth_config'] = {
6363
'domain_login_only': False,
6464
}

ydb/tests/library/fixtures/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,21 @@ def stop_pool():
167167
# with Driver(DriverConfig(ydb_endpoint, database_path)) as driver:
168168
# with SessionPool(driver) as pool:
169169
# yield database_path, pool
170+
171+
172+
@pytest.fixture(scope='module', params=[True, False], ids=["encryption_enabled", "encryption_disabled"])
173+
def encryption_enabled(request):
174+
"""
175+
Parametrized fixture that runs tests with both encryption enabled and disabled.
176+
"""
177+
return request.param
178+
179+
180+
@pytest.fixture(scope='module')
181+
def ydb_cluster_configuration_with_encryption_parametrized(ydb_cluster_configuration, encryption_enabled):
182+
"""
183+
Extended cluster configuration that includes encryption settings based on the parametrized fixture.
184+
"""
185+
config = ydb_cluster_configuration.copy()
186+
config['enable_pool_encryption'] = encryption_enabled
187+
return config

ydb/tests/library/harness/kikimr_config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ def __init__(
190190
cms_config=None,
191191
explicit_statestorage_config=None,
192192
system_tablets=None,
193-
protected_mode=False,
193+
protected_mode=False, # Authentication
194+
enable_pool_encryption=False,
194195
tiny_mode=False,
195196
module=None,
196197
):
@@ -222,6 +223,7 @@ def __init__(
222223
erasure = Erasure.NONE if erasure is None else erasure
223224
self.system_tablets = system_tablets
224225
self.protected_mode = protected_mode
226+
self.enable_pool_encryption = enable_pool_encryption
225227
self.module = module
226228
self.__grpc_ssl_enable = grpc_ssl_enable or protected_mode
227229
self.__grpc_tls_data_path = None
@@ -684,6 +686,7 @@ def grpc_tls_ca(self):
684686
@property
685687
def domains_txt(self):
686688
app_config = config_pb2.TAppConfig()
689+
assert not self.enable_pool_encryption, "pool encryption isn't addressed in domains.txt"
687690
Parse(read_binary(__name__, "resources/default_domains.txt"), app_config.DomainsConfig)
688691
return app_config.DomainsConfig
689692

@@ -947,3 +950,8 @@ def __build(self):
947950
self._add_state_storage_config()
948951
if not self.use_self_management and not self.explicit_hosts_and_host_configs:
949952
self._initialize_pdisks_info()
953+
954+
if self.enable_pool_encryption:
955+
for domain in self.yaml_config['domains_config']['domain']:
956+
for pool_type in domain['storage_pool_types']:
957+
pool_type['pool_config']['encryption_mode'] = 1

ydb/tests/library/harness/kikimr_runner.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,18 @@ def __register_slot(self, tenant_affiliation=None, encryption_key=None, seed_nod
641641
self.nodes[1].grpc_ssl_port if self.__configurator.grpc_ssl_enable
642642
else self.nodes[1].grpc_port
643643
)
644+
645+
if encryption_key is None and self.__configurator.enable_pool_encryption:
646+
workdir = os.path.join(self.__configurator.working_dir, self.__cluster_name)
647+
slug = tenant_affiliation.replace('/', '_')
648+
secret_path = os.path.join(workdir, slug + "_secret.txt")
649+
with open(secret_path, "w") as writer:
650+
writer.write("fake_secret_data_for_%s" % slug)
651+
keyfile_path = os.path.join(workdir, slug + "_key.txt")
652+
with open(keyfile_path, "w") as writer:
653+
writer.write('Keys { ContainerPath: "%s" Pin: "" Id: "%s" Version: 1 } ' % (secret_path, slug))
654+
encryption_key = keyfile_path
655+
644656
self._slots[slot_index] = KiKiMRNode(
645657
node_id=slot_index,
646658
config_path=self.config_path,

0 commit comments

Comments
 (0)