userver: samples/tcp_service/tests/conftest.py
Loading...
Searching...
No Matches
samples/tcp_service/tests/conftest.py
1# /// [service_non_http_health_checker]
2import pytest
3from pytest_userver.utils import net
4
5pytest_plugins = ['pytest_userver.plugins.core']
6
7
8@pytest.fixture(name='tcp_service_port', scope='session')
9def _tcp_service_port(service_config) -> int:
10 components = service_config['components_manager']['components']
11 tcp_hello = components.get('tcp-hello')
12 assert tcp_hello, 'No "tcp-hello" component found'
13 return int(tcp_hello['port'])
14
15
16@pytest.fixture(scope='session')
17def service_non_http_health_checks(
18 service_config, tcp_service_port,
19) -> net.HealthChecks:
20 checks = net.get_health_checks_info(service_config)
21 checks.tcp.append(net.HostPort(host='localhost', port=tcp_service_port))
22 return checks
23 # /// [service_non_http_health_checker]