userver: pytest_userver.chaos.TcpGate Class Reference
Loading...
Searching...
No Matches
pytest_userver.chaos.TcpGate Class Reference

Detailed Description

Implements TCP chaos-proxy logic such as accepting incoming tcp client connections.

On each new connection new tcp client connects to server (host_to_server, port_to_server).

See also
Chaos Testing

Definition at line 839 of file chaos.py.

+ Inheritance diagram for pytest_userver.chaos.TcpGate:

Public Member Functions

None __init__ (self, GateRoute route, EvLoop|None loop=None)
 
int connections_count (self)
 Returns maximal amount of connections going through the gate at the moment.
 
None wait_for_connections (self, *count=1, timeout=0.0)
 Wait for at least count connections going through the gate.
 

Protected Member Functions

list[Socket] _create_accepting_sockets (self)
 
 _connect_to_server (self)
 
None _do_accept (self, Socket accept_sock)
 This task should wait for connections and create SocketPair.
 

Protected Attributes

 _connected_event
 
 _sockets
 
 _loop
 
 _to_server_intercept
 
 _to_client_intercept
 

Constructor & Destructor Documentation

◆ __init__()

None pytest_userver.chaos.TcpGate.__init__ (   self,
GateRoute  route,
EvLoop | None   loop = None 
)

Reimplemented from pytest_userver.chaos.BaseGate.

Definition at line 850 of file chaos.py.

Member Function Documentation

◆ _connect_to_server()

pytest_userver.chaos.TcpGate._connect_to_server (   self)
protected

Definition at line 905 of file chaos.py.

◆ _create_accepting_sockets()

list[Socket] pytest_userver.chaos.TcpGate._create_accepting_sockets (   self)
protected

Reimplemented from pytest_userver.chaos.BaseGate.

Definition at line 886 of file chaos.py.

◆ _do_accept()

None pytest_userver.chaos.TcpGate._do_accept (   self,
Socket  accept_sock 
)
protected

This task should wait for connections and create SocketPair.

Reimplemented from pytest_userver.chaos.BaseGate.

Definition at line 922 of file chaos.py.

◆ connections_count()

int pytest_userver.chaos.TcpGate.connections_count (   self)

Returns maximal amount of connections going through the gate at the moment.

Warning
Some of the connections could be closing, or could be opened right before the function starts. Use with caution!

Definition at line 854 of file chaos.py.

◆ wait_for_connections()

None pytest_userver.chaos.TcpGate.wait_for_connections (   self,
count = 1,
  timeout = 0.0 
)

Wait for at least count connections going through the gate.

Exceptions
asyncio.TimeoutErrorexception if failed to get the required amount of connections in time.

Definition at line 864 of file chaos.py.

Member Data Documentation

◆ _connected_event

pytest_userver.chaos.TcpGate._connected_event
protected

Definition at line 851 of file chaos.py.

◆ _loop

pytest_userver.chaos.TcpGate._loop
protected

Definition at line 932 of file chaos.py.

◆ _sockets

pytest_userver.chaos.TcpGate._sockets
protected

Definition at line 862 of file chaos.py.

◆ _to_client_intercept

pytest_userver.chaos.TcpGate._to_client_intercept
protected

Definition at line 936 of file chaos.py.

◆ _to_server_intercept

pytest_userver.chaos.TcpGate._to_server_intercept
protected

Definition at line 935 of file chaos.py.


The documentation for this class was generated from the following file: