summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniil Cherednik <[email protected]>2024-09-20 16:36:55 +0200
committerGitHub <[email protected]>2024-09-20 16:36:55 +0200
commit314943f12cc633839785fdf334cad3a4d372a9ac (patch)
tree7be0ade302d4b0393dfca512f32b62795c318cd3
parent813afddbbc5dc3a95c285c4e18d082f86fe7ba0c (diff)
Test to check running additional grpc servers (#9570)
-rw-r--r--ydb/tests/functional/api/test_discovery.py41
-rw-r--r--ydb/tests/library/harness/kikimr_config.py12
-rw-r--r--ydb/tests/library/harness/kikimr_port_allocator.py6
3 files changed, 59 insertions, 0 deletions
diff --git a/ydb/tests/functional/api/test_discovery.py b/ydb/tests/functional/api/test_discovery.py
index fc5839c8b28..0988fc5e29d 100644
--- a/ydb/tests/functional/api/test_discovery.py
+++ b/ydb/tests/functional/api/test_discovery.py
@@ -15,6 +15,47 @@ from ydb.tests.oss.ydb_sdk_import import ydb
logger = logging.getLogger(__name__)
+class TestDiscoveryExtEndpoint(object):
+ @classmethod
+ def setup_class(cls):
+ conf = KikimrConfigGenerator()
+ cls.ext_port = conf.port_allocator.get_node_port_allocator(0).ext_port
+ conf.clone_grpc_as_ext_endpoint(cls.ext_port)
+ cls.cluster = kikimr_cluster_factory(
+ configurator=conf
+ )
+ cls.cluster.start()
+ cls.database_name = '/Root/database'
+ cls.logger = logger.getChild(cls.__name__)
+ cls.cluster.create_database(
+ cls.database_name,
+ storage_pool_units_count={
+ 'hdd': 1
+ }
+ )
+ cls.cluster.register_and_start_slots(cls.database_name, count=2)
+ cls.cluster.wait_tenant_up(cls.database_name)
+
+ @classmethod
+ def teardown_class(cls):
+ if hasattr(cls, 'cluster'):
+ cls.cluster.stop()
+
+ def test_scenario(self):
+ ext_port = TestDiscoveryExtEndpoint.ext_port
+ driver_config = ydb.DriverConfig(
+ "%s:%s" % (self.cluster.nodes[1].host, ext_port), self.database_name)
+ resolver = ydb.DiscoveryEndpointsResolver(driver_config)
+ driver = ydb.Driver(driver_config)
+ driver.wait(timeout=10)
+
+ endpoint_ports = [endpoint.port for endpoint in resolver.resolve().endpoints]
+
+ for slot in self.cluster.slots.values():
+ assert_that(slot.grpc_port in endpoint_ports)
+ assert_that(slot.grpc_port != ext_port)
+
+
@six.add_metaclass(abc.ABCMeta)
class AbstractTestDiscoveryFaultInjection(object):
@classmethod
diff --git a/ydb/tests/library/harness/kikimr_config.py b/ydb/tests/library/harness/kikimr_config.py
index a084d60afc3..38e27aca27c 100644
--- a/ydb/tests/library/harness/kikimr_config.py
+++ b/ydb/tests/library/harness/kikimr_config.py
@@ -546,6 +546,18 @@ class KikimrConfigGenerator(object):
with open(os.path.join(configs_path, "config.yaml"), "w") as writer:
writer.write(yaml.safe_dump(self.yaml_config))
+ def clone_grpc_as_ext_endpoint(self, port):
+ cur_grpc_config = copy.deepcopy(self.yaml_config['grpc_config'])
+ if 'ext_endpoints' in cur_grpc_config:
+ del cur_grpc_config['ext_endpoints']
+
+ cur_grpc_config['port'] = port
+
+ if 'ext_endpoints' not in self.yaml_config['grpc_config']:
+ self.yaml_config['grpc_config']['ext_endpoints'] = []
+
+ self.yaml_config['grpc_config']['ext_endpoints'].append(cur_grpc_config)
+
def get_yql_udfs_to_load(self):
if not self.__load_udfs:
return []
diff --git a/ydb/tests/library/harness/kikimr_port_allocator.py b/ydb/tests/library/harness/kikimr_port_allocator.py
index 71015f4d425..9ff0f9cbad4 100644
--- a/ydb/tests/library/harness/kikimr_port_allocator.py
+++ b/ydb/tests/library/harness/kikimr_port_allocator.py
@@ -130,6 +130,12 @@ class KikimrPortManagerNodePortAllocator(KikimrNodePortAllocatorInterface):
self.__public_http_port = self.__port_manager.get_port()
return self.__public_http_port
+ @property
+ def ext_port(self):
+ if self.__ext_port is None:
+ self.__ext_port = self.__port_manager.get_port()
+ return self.__ext_port
+
class KikimrPortManagerPortAllocator(KikimrPortAllocatorInterface):
def __init__(self, port_manager=None):