Загрузка данных


==================================== ERRORS ====================================
_ ERROR at setup of TestOutputSignalImitation.test_imitate_leak[OutputSignalImitation_tn3] _
self = <_UnixSelectorEventLoop running=False closed=False debug=False>
protocol_factory = <bound method UaClient._make_protocol of <asyncua.client.ua_client.UaClient object at 0x7f6e9ea94040>>
host = '...', port = ...
    async def create_connection(
            self, protocol_factory, host=None, port=None,
            *, ssl=None, family=0,
            proto=0, flags=0, sock=None,
            local_addr=None, server_hostname=None,
            ssl_handshake_timeout=None,
            happy_eyeballs_delay=None, interleave=None):
        """Connect to a TCP server.
    
        Create a streaming transport connection to a given internet host and
        port: socket family AF_INET or socket.AF_INET6 depending on host (or
        family if specified), socket type SOCK_STREAM. protocol_factory must be
        a callable returning a protocol instance.
    
        This method is a coroutine which will try to establish the connection
        in the background.  When successful, the coroutine returns a
        (transport, protocol) pair.
        """
        if server_hostname is not None and not ssl:
            raise ValueError('server_hostname is only meaningful with ssl')
    
        if server_hostname is None and ssl:
            # Use host as default for server_hostname.  It is an error
            # if host is empty or not set, e.g. when an
            # already-connected socket was passed or when only a port
            # is given.  To avoid this error, you can pass
            # server_hostname='' -- this will bypass the hostname
            # check.  (This also means that if host is a numeric
            # IP/IPv6 address, we will attempt to verify that exact
            # address; this will probably fail, but it is possible to
            # create a certificate for a specific IP address, so we
            # don't judge it here.)
            if not host:
                raise ValueError('You must set server_hostname '
                                 'when using ssl without a host')
            server_hostname = host
    
        if ssl_handshake_timeout is not None and not ssl:
            raise ValueError(
                'ssl_handshake_timeout is only meaningful with ssl')
    
        if sock is not None:
            _check_ssl_socket(sock)
    
        if happy_eyeballs_delay is not None and interleave is None:
            # If using happy eyeballs, default to interleave addresses by family
            interleave = 1
    
        if host is not None or port is not None:
            if sock is not None:
                raise ValueError(
                    'host/port and sock can not be specified at the same time')
    
            infos = await self._ensure_resolved(
                (host, port), family=family,
                type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self)
            if not infos:
                raise OSError('getaddrinfo() returned empty list')
    
            if local_addr is not None:
                laddr_infos = await self._ensure_resolved(
                    local_addr, family=family,
                    type=socket.SOCK_STREAM, proto=proto,
                    flags=flags, loop=self)
                if not laddr_infos:
                    raise OSError('getaddrinfo() returned empty list')
            else:
                laddr_infos = None
    
            if interleave:
                infos = _interleave_addrinfos(infos, interleave)
    
            exceptions = []
            if happy_eyeballs_delay is None:
                # not using happy eyeballs
                for addrinfo in infos:
                    try:
>                       sock = await self._connect_sock(
                            exceptions, addrinfo, laddr_infos)
/usr/local/lib/python3.10/asyncio/base_events.py:1060: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.10/asyncio/base_events.py:969: in _connect_sock
    await self.sock_connect(sock, address)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <_UnixSelectorEventLoop running=False closed=False debug=False>
sock = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
address = ('10.7.49.210', 10521)
    async def sock_connect(self, sock, address):
        """Connect to a remote socket at address.
    
        This method is a coroutine.
        """
        base_events._check_ssl_socket(sock)
        if self._debug and sock.gettimeout() != 0:
            raise ValueError("the socket must be non-blocking")
    
        if sock.family == socket.AF_INET or (
                base_events._HAS_IPv6 and sock.family == socket.AF_INET6):
            resolved = await self._ensure_resolved(
                address, family=sock.family, type=sock.type, proto=sock.proto,
                loop=self,
            )
            _, _, _, _, address = resolved[0]
    
        fut = self.create_future()
        self._sock_connect(fut, sock, address)
        try:
>           return await fut
E           asyncio.exceptions.CancelledError
/usr/local/lib/python3.10/asyncio/selector_events.py:501: CancelledError
During handling of the above exception, another exception occurred:
fut = <Task cancelled name='Task-7' coro=<BaseEventLoop.create_connection() done, defined at /usr/local/lib/python3.10/asyncio/base_events.py:983>>
timeout = 5.0
    async def wait_for(fut, timeout):
        """Wait for the single Future or coroutine to complete, with timeout.
    
        Coroutine will be wrapped in Task.
    
        Returns result of the Future or coroutine.  When a timeout occurs,
        it cancels the task and raises TimeoutError.  To avoid the task
        cancellation, wrap it in shield().
    
        If the wait is cancelled, the task is also cancelled.
    
        This function is a coroutine.
        """
        loop = events.get_running_loop()
    
        if timeout is None:
            return await fut
    
        if timeout <= 0:
            fut = ensure_future(fut, loop=loop)
    
            if fut.done():
                return fut.result()
    
            await _cancel_and_wait(fut, loop=loop)
            try:
                return fut.result()
            except exceptions.CancelledError as exc:
                raise exceptions.TimeoutError() from exc
    
        waiter = loop.create_future()
        timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
        cb = functools.partial(_release_waiter, waiter)
    
        fut = ensure_future(fut, loop=loop)
        fut.add_done_callback(cb)
    
        try:
            # wait until the future completes or the timeout
            try:
                await waiter
            except exceptions.CancelledError:
                if fut.done():
                    return fut.result()
                else:
                    fut.remove_done_callback(cb)
                    # We must ensure that the task is not running
                    # after wait_for() returns.
                    # See https://bugs.python.org/issue32751
                    await _cancel_and_wait(fut, loop=loop)
                    raise
    
            if fut.done():
                return fut.result()
            else:
                fut.remove_done_callback(cb)
                # We must ensure that the task is not running
                # after wait_for() returns.
                # See https://bugs.python.org/issue32751
                await _cancel_and_wait(fut, loop=loop)
                # In case task cancellation failed with some
                # exception, we should re-raise it
                # See https://bugs.python.org/issue40607
                try:
>                   return fut.result()
E                   asyncio.exceptions.CancelledError
/usr/local/lib/python3.10/asyncio/tasks.py:456: CancelledError
The above exception was the direct cause of the following exception:
self = <clients.opc_ua_client.OpcUaClient object at 0x7f6e9e553700>
attempts = 6
    async def connect(self, attempts: int = OpcConst.RECONNECT_ATTEMPTS) -> None:
        """Подключается к OPC UA серверу с ограниченным числом попыток."""
        last_error: Optional[Exception] = None
        for attempt in range(1, attempts + 1):
            try:
                self._client = Client(url=self._url, timeout=self._timeout)
>               await self._client.connect()
clients/opc_ua_client.py:75: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv/lib/python3.10/site-packages/asyncua/client/client.py:457: in connect
    await self._connect_sequence()
.venv/lib/python3.10/site-packages/asyncua/client/client.py:469: in _connect_sequence
    await self.connect_socket()
.venv/lib/python3.10/site-packages/asyncua/client/client.py:647: in connect_socket
    await self.uaclient.connect_socket(self.server_url.hostname, self.server_url.port)
.venv/lib/python3.10/site-packages/asyncua/client/ua_client.py:543: in connect_socket
    await asyncio.wait_for(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
fut = <Task cancelled name='Task-7' coro=<BaseEventLoop.create_connection() done, defined at /usr/local/lib/python3.10/asyncio/base_events.py:983>>
timeout = 5.0
    async def wait_for(fut, timeout):
        """Wait for the single Future or coroutine to complete, with timeout.
    
        Coroutine will be wrapped in Task.
    
        Returns result of the Future or coroutine.  When a timeout occurs,
        it cancels the task and raises TimeoutError.  To avoid the task
        cancellation, wrap it in shield().
    
        If the wait is cancelled, the task is also cancelled.
    
        This function is a coroutine.
        """
        loop = events.get_running_loop()
    
        if timeout is None:
            return await fut
    
        if timeout <= 0:
            fut = ensure_future(fut, loop=loop)
    
            if fut.done():
                return fut.result()
    
            await _cancel_and_wait(fut, loop=loop)
            try:
                return fut.result()
            except exceptions.CancelledError as exc:
                raise exceptions.TimeoutError() from exc
    
        waiter = loop.create_future()
        timeout_handle = loop.call_later(timeout, _release_waiter, waiter)
        cb = functools.partial(_release_waiter, waiter)
    
        fut = ensure_future(fut, loop=loop)
        fut.add_done_callback(cb)
    
        try:
            # wait until the future completes or the timeout
            try:
                await waiter
            except exceptions.CancelledError:
                if fut.done():
                    return fut.result()
                else:
                    fut.remove_done_callback(cb)
                    # We must ensure that the task is not running
                    # after wait_for() returns.
                    # See https://bugs.python.org/issue32751
                    await _cancel_and_wait(fut, loop=loop)
                    raise
    
            if fut.done():
                return fut.result()
            else:
                fut.remove_done_callback(cb)
                # We must ensure that the task is not running
                # after wait_for() returns.
                # See https://bugs.python.org/issue32751
                await _cancel_and_wait(fut, loop=loop)
                # In case task cancellation failed with some
                # exception, we should re-raise it
                # See https://bugs.python.org/issue40607
                try:
                    return fut.result()
                except exceptions.CancelledError as exc:
>                   raise exceptions.TimeoutError() from exc
E                   asyncio.exceptions.TimeoutError
/usr/local/lib/python3.10/asyncio/tasks.py:458: TimeoutError
The above exception was the direct cause of the following exception:
request = <SubRequest 'opc_client' for <Coroutine test_imitate_leak[OutputSignalImitation_tn3]>>
    @pytest_asyncio.fixture
    async def opc_client(request):
        """
        Фикстура OPC UA клиента для чтения выходных сигналов СОУ.
    
        Подключается к серверу, указанному в OPC_URL (opc.tcp://host:port).
        """
        from clients.opc_ua_client import OpcUaClient
    
        stand_manager = request.config.group_state.get("stand_manager")
        opc_url = stand_manager.opc_tunnel_url if stand_manager else None
        if not opc_url:
            opc_url = os.environ.get(EnvKeyConstants.OPC_URL)
        if not opc_url:
            pytest.fail("OPC_URL не задан в переменных окружения")
    
        client = OpcUaClient(opc_url)
        try:
>           await client.connect()
conftest.py:949: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <clients.opc_ua_client.OpcUaClient object at 0x7f6e9e553700>
attempts = 6
    async def connect(self, attempts: int = OpcConst.RECONNECT_ATTEMPTS) -> None:
        """Подключается к OPC UA серверу с ограниченным числом попыток."""
        last_error: Optional[Exception] = None
        for attempt in range(1, attempts + 1):
            try:
                self._client = Client(url=self._url, timeout=self._timeout)
                await self._client.connect()
                logger.info("[OPC] [OK] Подключено к %s", self._url)
                return
            except Exception as error:
                last_error = error
                logger.warning("[OPC] [WARNING] Подключение не удалось (попытка %s/%s): %s", attempt, attempts, error)
                if attempt < attempts:
                    await asyncio.sleep(OpcConst.RECONNECT_INTERVAL_S)
>       raise ConnectionError(
            f"[OPC] [ERROR] Не удалось подключиться к OPC UA серверу {self._url}: {last_error}"
        ) from last_error
E       ConnectionError: [OPC] [ERROR] Не удалось подключиться к OPC UA серверу opc.tcp://...:...:
clients/opc_ua_client.py:83: ConnectionError
During handling of the above exception, another exception occurred:
request = <SubRequest 'opc_client' for <Coroutine test_imitate_leak[OutputSignalImitation_tn3]>>
kwargs = {}, func = <function opc_client at 0x7f6e9ee43c70>
event_loop_fixture_id = 'event_loop'
setup = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup at 0x7f6e9e174f70>
setup_task = <Task finished name='Task-1' coro=<_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup() done, de....TNGRP.RU:10521): [OPC] [ERROR] Не удалось подключиться к OPC UA серверу opc.tcp://...:...: >
    @functools.wraps(fixture)
    def _asyncgen_fixture_wrapper(request: FixtureRequest, **kwargs: Any):
        func = _perhaps_rebind_fixture_func(fixture, request.instance)
        event_loop_fixture_id = _get_event_loop_fixture_id_for_async_fixture(
            request, func
        )
        event_loop = request.getfixturevalue(event_loop_fixture_id)
        kwargs.pop(event_loop_fixture_id, None)
        gen_obj = func(**_add_kwargs(func, kwargs, event_loop, request))
    
        async def setup():
            res = await gen_obj.__anext__()  # type: ignore[union-attr]
            return res
    
        context = contextvars.copy_context()
        setup_task = _create_task_in_context(event_loop, setup(), context)
>       result = event_loop.run_until_complete(setup_task)
.venv/lib/python3.10/site-packages/pytest_asyncio/plugin.py:345: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.10/asyncio/base_events.py:649: in run_until_complete
    return future.result()
.venv/lib/python3.10/site-packages/pytest_asyncio/plugin.py:340: in setup
    res = await gen_obj.__anext__()  # type: ignore[union-attr]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
request = <SubRequest 'opc_client' for <Coroutine test_imitate_leak[OutputSignalImitation_tn3]>>
    @pytest_asyncio.fixture
    async def opc_client(request):
        """
        Фикстура OPC UA клиента для чтения выходных сигналов СОУ.
    
        Подключается к серверу, указанному в OPC_URL (opc.tcp://host:port).
        """
        from clients.opc_ua_client import OpcUaClient
    
        stand_manager = request.config.group_state.get("stand_manager")
        opc_url = stand_manager.opc_tunnel_url if stand_manager else None
        if not opc_url:
            opc_url = os.environ.get(EnvKeyConstants.OPC_URL)
        if not opc_url:
            pytest.fail("OPC_URL не задан в переменных окружения")
    
        client = OpcUaClient(opc_url)
        try:
            await client.connect()
        except Exception as error:
>           pytest.fail(f"Не удалось подключиться к OPC UA серверу ({opc_url}): {error}")
E           Failed: Не удалось подключиться к OPC UA серверу (opc.tcp://...:...): [OPC] [ERROR] Не удалось подключиться к OPC UA серверу opc.tcp://....:...:
conftest.py:951: Failed