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