65 service_config, service_baseurl,
66) -> typing.Optional[str]:
68 Returns the service HTTP ping URL that is used by the testsuite to detect
69 that the service is ready to work. Returns None if there's no such URL.
71 By default attempts to find server::handlers::Ping component by
72 "handler-ping" name in static config. Override this fixture to change the
75 @ingroup userver_testsuite_fixtures
77 components = service_config[
'components_manager'][
'components']
78 ping_handler = components.get(
'handler-ping')
80 return url_util.join(service_baseurl, ping_handler[
'path'])
84@pytest.fixture(scope='session')
107 service_http_ping_url,
108 service_config_path_temp,
111 service_non_http_health_checks,
114 Configures the health checking to use service_http_ping_url fixture value
115 if it is not None; otherwise uses the service_non_http_health_checks info.
116 Starts the service daemon.
118 @ingroup userver_testsuite_fixtures
120 assert service_http_ping_url
or service_non_http_health_checks.tcp, (
121 '"service_http_ping_url" and "create_health_checker" fixtures '
122 'returned None. Testsuite is unable to detect if the service is ready '
123 'to accept requests.',
126 logger_testsuite.debug(
127 'userver fixture "service_daemon" would check for "%s"',
128 service_non_http_health_checks,
135 async def _checker(*, session, process) -> bool:
136 LocalCounters.attempts += 1
137 new_log_time = time.monotonic()
138 if new_log_time - LocalCounters.last_log_time > 1.0:
139 LocalCounters.last_log_time = new_log_time
140 logger_testsuite.debug(
141 'userver fixture "service_daemon" checking "%s", attempt %s',
142 service_non_http_health_checks,
143 LocalCounters.attempts,
146 return await net.check_availability(service_non_http_health_checks)
148 health_check = _checker
149 if service_http_ping_url:
152 async with create_daemon_scope(
153 args=[str(service_binary),
'--config', str(service_config_path_temp)],
154 ping_url=service_http_ping_url,
155 health_check=health_check,