Skip to content

Commit

Permalink
Refactored service registry creation in core tests
Browse files Browse the repository at this point in the history
  • Loading branch information
altvod committed Nov 14, 2023
1 parent aa9a2ad commit 878fd83
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def conn_sync_service_registry(
conn_bi_context: RequestContextInfo,
task_processor_factory: TaskProcessorFactory,
) -> ServicesRegistry:
return self.service_registry_factory(
return self.make_service_registry(
conn_exec_factory_async_env=False,
conn_bi_context=conn_bi_context,
task_processor_factory=task_processor_factory,
Expand All @@ -122,7 +122,7 @@ def conn_async_service_registry(
conn_bi_context: RequestContextInfo,
task_processor_factory: TaskProcessorFactory,
) -> ServicesRegistry:
return self.service_registry_factory(
return self.make_service_registry(
conn_exec_factory_async_env=True,
conn_bi_context=conn_bi_context,
task_processor_factory=task_processor_factory,
Expand Down
37 changes: 34 additions & 3 deletions lib/dl_core_testing/dl_core_testing/testcases/service_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
from dl_constants.enums import ConnectionType
from dl_core.connections_security.base import InsecureConnectionSecurityManager
from dl_core.services_registry.conn_executor_factory import DefaultConnExecutorFactory
from dl_core.services_registry.env_manager_factory import InsecureEnvManagerFactory
from dl_core.services_registry.inst_specific_sr import InstallationSpecificServiceRegistryFactory
from dl_core.services_registry.sr_factories import (
DefaultSRFactory,
SRFactory,
)
from dl_core.services_registry.top_level import (
DefaultServicesRegistry,
ServicesRegistry,
Expand Down Expand Up @@ -69,7 +74,33 @@ def conn_bi_context(self) -> RequestContextInfo:
def conn_exec_factory_async_env(self) -> bool:
return False

def service_registry_factory(
def make_service_registry_factory(self, async_env: bool) -> SRFactory:
return DefaultSRFactory(
async_env=async_env,
rqe_config=RQEConfig.get_default(), # Not used because RQE is disabled
connectors_settings={self.conn_type: self.connection_settings} if self.connection_settings else {},
inst_specific_sr_factory=self.inst_specific_sr_factory,
env_manager_factory=InsecureEnvManagerFactory(),
force_non_rqe_mode=True,
)

def make_service_registry(
self,
conn_exec_factory_async_env: bool,
conn_bi_context: RequestContextInfo,
**kwargs: Any,
) -> ServicesRegistry:
sr_factory = self.make_service_registry_factory(async_env=conn_exec_factory_async_env)
return sr_factory.make_service_registry(
request_context_info=conn_bi_context,
mutations_cache_factory=DefaultUSEntryMutationCacheFactory(),
reporting_registry=DefaultReportingRegistry(
rci=conn_bi_context,
),
**kwargs,
)

def make_service_registry_legacy(
self,
conn_exec_factory_async_env: bool,
conn_bi_context: RequestContextInfo,
Expand Down Expand Up @@ -106,7 +137,7 @@ def conn_sync_service_registry(
self,
conn_bi_context: RequestContextInfo,
) -> ServicesRegistry:
return self.service_registry_factory(
return self.make_service_registry(
conn_exec_factory_async_env=False,
conn_bi_context=conn_bi_context,
)
Expand All @@ -116,7 +147,7 @@ def conn_async_service_registry(
self,
conn_bi_context: RequestContextInfo,
) -> ServicesRegistry:
return self.service_registry_factory(
return self.make_service_registry(
conn_exec_factory_async_env=True,
conn_bi_context=conn_bi_context,
)
Expand Down

0 comments on commit 878fd83

Please sign in to comment.