Skip to content

Commit

Permalink
add tests that we can switch from legacy to new node registration and…
Browse files Browse the repository at this point in the history
… back (#2181)

* add tests that we can switch from legacy to new node registration and back

* update
  • Loading branch information
yegorskii authored Oct 1, 2024
1 parent 68969fc commit e5e2d54
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 46 deletions.
7 changes: 4 additions & 3 deletions cloud/blockstore/tests/python/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

class NbsConfigurator:

def __init__(self, ydb, node_type=None, pm=None, ssl_registration=False):
def __init__(self, ydb, node_type=None, pm=None, ssl_registration=False, ic_port=None):
assert ydb.config

self.__pm = PortManager() if pm is None else pm
self.__ydb = ydb
self.__node_type = node_type

self.ic_port = None
self.ic_port = ic_port
self.mon_port = None
self.server_port = None
self.data_port = None
Expand Down Expand Up @@ -63,7 +63,8 @@ def params(self):
def generate_default_nbs_configs(self):
self.node_broker_addr = f"localhost:{self.ydb_port}"

self.ic_port = self.__pm.get_port()
if self.ic_port is None:
self.ic_port = self.__pm.get_port()
self.mon_port = self.__pm.get_port()
self.server_port = self.__pm.get_port()
self.data_port = self.__pm.get_port()
Expand Down
52 changes: 50 additions & 2 deletions cloud/blockstore/tests/registration/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ def setup_cms_configs(ydb_client):
update_cms_config(ydb_client, 'StorageServiceConfig', storage, '')


def prepare(ydb, kikimr_ssl, blockstore_ssl, node_type):
nbs_configurator = NbsConfigurator(ydb, ssl_registration=blockstore_ssl)
def prepare(ydb, kikimr_ssl, blockstore_ssl, node_type, ic_port=None):
nbs_configurator = NbsConfigurator(
ydb,
ssl_registration=blockstore_ssl,
ic_port=ic_port)
nbs_configurator.generate_default_nbs_configs()

if blockstore_ssl and kikimr_ssl:
Expand Down Expand Up @@ -117,6 +120,43 @@ def setup_and_run_test_for_da(kikimr_ssl, blockstore_ssl):
return True


def setup_and_run_registration_migration_server():
ydb = start_ydb(grpc_ssl_enable=True)
setup_cms_configs(ydb.client)

ic_port = None
for setting in (False, True, False):
configurator = prepare(ydb, setting, setting, 'nbs', ic_port)
nbs = start_nbs(configurator)
if ic_port is not None:
assert configurator.ic_port == ic_port
else:
ic_port = configurator.ic_port

nbs.kill()


def setup_and_run_registration_migration_da():
ydb = start_ydb(grpc_ssl_enable=True)
setup_cms_configs(ydb.client)

nbs = start_nbs(prepare(ydb, False, False, 'nbs_control'))

ic_port = None
for setting in (False, True, False):
configurator = prepare(ydb, setting, setting, 'disk-agent', ic_port)
configurator.files["disk-agent"] = generate_disk_agent_txt(agent_id='')
da = start_disk_agent(configurator)
if ic_port is not None:
assert configurator.ic_port == ic_port
else:
ic_port = configurator.ic_port

da.kill()

nbs.kill()


TestCase = namedtuple('TestCase', 'SecureKikimr SecureBlockstore Result')
Scenarios = [
TestCase(SecureKikimr=False, SecureBlockstore=False, Result=True),
Expand All @@ -137,3 +177,11 @@ def test_server_registration(kikimr_ssl, blockstore_ssl, result):
@pytest.mark.parametrize('kikimr_ssl, blockstore_ssl, result', Scenarios)
def test_da_registration(kikimr_ssl, blockstore_ssl, result):
assert setup_and_run_test_for_da(kikimr_ssl, blockstore_ssl) == result


def test_server_registration_migration():
setup_and_run_registration_migration_server()


def test_da_registration_migration():
setup_and_run_registration_migration_da()
11 changes: 10 additions & 1 deletion cloud/filestore/tests/python/lib/daemon_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(
use_secure_registration=False,
secure=False,
access_service_type=AccessService,
ic_port=None,
):
self.__binary_path = binary_path
self.__working_dir, self.__configs_dir = get_directories()
Expand All @@ -79,7 +80,7 @@ def __init__(
self._port_manager = yatest_common.PortManager()
self.__port = self._port_manager.get_port()
self.__mon_port = self._port_manager.get_port()
self.__ic_port = self._port_manager.get_port()
self.__ic_port = self._port_manager.get_port() if ic_port is None else ic_port
self.__access_service_type = access_service_type
self.__access_service_port = access_service_port

Expand Down Expand Up @@ -114,6 +115,10 @@ def working_dir(self):
def configs_dir(self):
return self.__configs_dir

@property
def ic_port(self):
return self.__ic_port

def __generate_domains_txt(self, domains_txt):
config = TDomainsConfig()
if domains_txt is not None:
Expand Down Expand Up @@ -384,6 +389,7 @@ def __init__(
use_secure_registration=False,
secure=False,
access_service_type=AccessService,
ic_port=None,
):
super().__init__(
binary_path,
Expand All @@ -402,6 +408,7 @@ def __init__(
use_secure_registration=use_secure_registration,
secure=secure,
access_service_type=access_service_type,
ic_port=ic_port
)


Expand All @@ -419,6 +426,7 @@ def __init__(
access_service_port=0,
storage_config=None,
use_secure_registration=False,
ic_port=None,
):
super().__init__(
binary_path,
Expand All @@ -435,6 +443,7 @@ def __init__(
access_service_port=access_service_port,
storage_config=storage_config,
use_secure_registration=use_secure_registration,
ic_port=ic_port
)

self.__local_service_port = self._port_manager.get_port()
Expand Down
Loading

0 comments on commit e5e2d54

Please sign in to comment.