61 service_config, service_baseurl,
62) -> typing.Optional[str]:
64 Returns the service HTTP ping URL that is used by the testsuite to detect
65 that the service is ready to work. Returns None if there's no such URL.
67 By default attempts to find server::handlers::Ping component by
68 "handler-ping" name in static config. Override this fixture to change the
71 @ingroup userver_testsuite_fixtures
73 components = service_config[
'components_manager'][
'components']
74 ping_handler = components.get(
'handler-ping')
76 return url_util.join(service_baseurl, ping_handler[
'path'])
80@pytest.fixture(scope='session')
103 service_http_ping_url,
104 service_config_path_temp,
107 service_non_http_health_checks,
111 Configures the health checking to use service_http_ping_url fixture value
112 if it is not None; otherwise uses the service_non_http_health_checks info.
113 Starts the service daemon.
115 @ingroup userver_testsuite_fixtures
117 assert service_http_ping_url
or service_non_http_health_checks.tcp, (
118 '"service_http_ping_url" and "create_health_checker" fixtures '
119 'returned None. Testsuite is unable to detect if the service is ready '
120 'to accept requests.',
123 logger_testsuite.debug(
124 'userver fixture "service_daemon" would check for "%s"',
125 service_non_http_health_checks,
132 async def _checker(*, session, process) -> bool:
133 LocalCounters.attempts += 1
134 new_log_time = time.monotonic()
135 if new_log_time - LocalCounters.last_log_time > 1.0:
136 LocalCounters.last_log_time = new_log_time
137 logger_testsuite.debug(
138 'userver fixture "service_daemon" checking "%s", attempt %s',
139 service_non_http_health_checks,
140 LocalCounters.attempts,
143 return await net.check_availability(service_non_http_health_checks)
145 health_check = _checker
146 if service_http_ping_url:
149 async with create_daemon_scope(
153 str(service_config_path_temp),
155 ping_url=service_http_ping_url,
156 health_check=health_check,