66 service_config, service_baseurl,
67) -> typing.Optional[str]:
69 Returns the service HTTP ping URL that is used by the testsuite to detect
70 that the service is ready to work. Returns None if there's no such URL.
72 By default attempts to find server::handlers::Ping component by
73 "handler-ping" name in static config. Override this fixture to change the
76 @ingroup userver_testsuite_fixtures
78 components = service_config[
'components_manager'][
'components']
79 ping_handler = components.get(
'handler-ping')
81 return url_util.join(service_baseurl, ping_handler[
'path'])
85@pytest.fixture(scope='session')
108 service_http_ping_url,
109 service_config_path_temp,
112 service_non_http_health_checks,
115 Configures the health checking to use service_http_ping_url fixture value
116 if it is not None; otherwise uses the service_non_http_health_checks info.
117 Starts the service daemon.
119 @ingroup userver_testsuite_fixtures
121 assert service_http_ping_url
or service_non_http_health_checks.tcp, (
122 '"service_http_ping_url" and "create_health_checker" fixtures '
123 'returned None. Testsuite is unable to detect if the service is ready '
124 'to accept requests.',
127 logger_testsuite.debug(
128 'userver fixture "service_daemon" would check for "%s"',
129 service_non_http_health_checks,
136 async def _checker(*, session, process) -> bool:
137 LocalCounters.attempts += 1
138 new_log_time = time.monotonic()
139 if new_log_time - LocalCounters.last_log_time > 1.0:
140 LocalCounters.last_log_time = new_log_time
141 logger_testsuite.debug(
142 'userver fixture "service_daemon" checking "%s", attempt %s',
143 service_non_http_health_checks,
144 LocalCounters.attempts,
147 return await net.check_availability(service_non_http_health_checks)
149 health_check = _checker
150 if service_http_ping_url:
153 async with create_daemon_scope(
157 str(service_config_path_temp),
159 ping_url=service_http_ping_url,
160 health_check=health_check,