userver: pytest_userver.chaos.TcpGate Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts

Your opinion will help to improve our service

Leave a feedback >

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 837 of file chaos.py.

+ Inheritance diagram for pytest_userver.chaos.TcpGate:

Public Member Functions

None __init__ (self, GateRoute route, typing.Optional[EvLoop] 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

typing.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,
typing.Optional[EvLoop]   loop = None 
)

Reimplemented from pytest_userver.chaos.BaseGate.

Definition at line 848 of file chaos.py.

Member Function Documentation

◆ _connect_to_server()

pytest_userver.chaos.TcpGate._connect_to_server (   self)
protected

Definition at line 903 of file chaos.py.

◆ _create_accepting_sockets()

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

Reimplemented from pytest_userver.chaos.BaseGate.

Definition at line 884 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 920 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 852 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 862 of file chaos.py.

Member Data Documentation

◆ _connected_event

pytest_userver.chaos.TcpGate._connected_event
protected

Definition at line 849 of file chaos.py.

◆ _loop

pytest_userver.chaos.TcpGate._loop
protected

Definition at line 930 of file chaos.py.

◆ _sockets

pytest_userver.chaos.TcpGate._sockets
protected

Definition at line 860 of file chaos.py.

◆ _to_client_intercept

pytest_userver.chaos.TcpGate._to_client_intercept
protected

Definition at line 934 of file chaos.py.

◆ _to_server_intercept

pytest_userver.chaos.TcpGate._to_server_intercept
protected

Definition at line 933 of file chaos.py.


The documentation for this class was generated from the following file:
  • /data/code/userver/testsuite/pytest_plugins/pytest_userver/chaos.py