testplan.testing.multitest.driver.fix package¶
Submodules¶
testplan.testing.multitest.driver.fix.client module¶
FixClient driver classes.
-
class
testplan.testing.multitest.driver.fix.client.
FixClient
(name: str, msgclass: type, codec: testplan.common.utils.sockets.codec.Codec, host: Union[str, testplan.common.utils.context.ContextValue], port: Union[int, testplan.common.utils.context.ContextValue], sender: str, target: str, version: str = 'FIX.4.2', sendersub: str = None, interface: Tuple[str, int] = None, connect_at_start: bool = True, logon_at_start: bool = True, logoff_at_stop: bool = True, custom_logon_tags: testplan.common.utils.testing.FixMessage = None, receive_timeout: Union[int, float] = 30, logon_timeout: Union[int, float] = 10, logoff_timeout: Union[int, float] = 3, tls_config: Optional[testplan.common.utils.sockets.tls.TLSConfig] = None, **options)[source]¶ Bases:
testplan.testing.multitest.driver.base.Driver
Fix client driver.
This is built on top of the
testplan.common.utils.sockets.fix.client.Client
class, which provides equivalent functionality and may be used outside of MultiTest.{emphasized_members_docs}
Parameters: - name (
str
) – Name of FixClient. - msgclass (
type
) – Type used to construct logon, logoff and received FIX messages. - codec (a
Codec
instance) – A Codec to use to encode and decode FIX messages. - host (
str
) – Target host name. This can be aContextValue
and will be expanded on runtime. - port (
int
) – Target port number. This can be aContextValue
and will be expanded on runtime. - sender (
str
) – FIX SenderCompID. - target (
str
) – FIX TargetCompID. - version (
Optional[TLSConfig]
) – FIX version, defaults to “FIX.4.2”. - sendersub (
str
) – FIX SenderSubID. - interface (
tuple``(``str, ``int
)) – Interface to bind to. - connect_at_start (
bool
) – Connect to server on start. Default: True - logon_at_start (
bool
) – Attempt FIX logon if connected at start. - logoff_at_stop (
bool
) – Attempt FIX logoff when stop. - custom_logon_tags (
FixMessage
) – Custom logon tags to be merged into the35=A
message. - receive_timeout (
int
orfloat
) – Timeout in seconds while receiving from socket. - logon_timeout (
int
orfloat
) – Timeout in seconds to wait for logon response. - logoff_timeout (
int
orfloat
) – Timeout in seconds to wait for logoff response. - tls_config – If provided the connection will be encrypted
Also inherits all
Driver
options.-
CONFIG
¶ alias of
FixClientConfig
-
STATUS
¶
-
abort
()¶ Default abort policy. First abort all dependencies and then itself.
-
abort_dependencies
()¶ Returns an empty generator.
-
aborted
¶ Returns if entity was aborted.
-
active
¶ Entity not aborting/aborted.
-
async_start
¶ Overrides the default async_start value in config.
-
auto_start
¶ If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
-
cfg
¶ Configuration object.
-
context
¶ Key/value pair information of a Resource.
-
context_input
(exclude: list = None) → Dict[str, Any]¶ All attr of self in a dict for context resolution
-
define_runpath
()¶ Define runpath directory based on parent object and configuration.
-
errpath
¶ Path for stderr file regexp matching.
-
extract_driver_metadata
() → testplan.testing.multitest.driver.base.DriverMetadata¶ Extracts driver metadata as described in the extractor function.
Returns: driver metadata
-
extract_values
() → Union[bool, testplan.common.entity.base.FailedAction]¶ Extract matching values from input regex configuration options.
-
failover
() → None¶ API to create the failover resource, to be implemented in derived class
-
fetch_error_log
() → List[str]¶ Fetch error message from the log files of driver, at first we can try self.errpath, if it does not exist, try self.logpath. Typically, several lines from the tail of file will be selected.
Returns: text from log file
-
classmethod
filter_locals
(local_vars)¶ Filter out init params of None value, they will take default value defined in its ConfigOption object; also filter out special vars that are not init params from local_vars.
Parameters: local_vars –
-
flush
(timeout=0)[source]¶ Flush all inbound messages.
Parameters: timeout ( int
) – Message receive timeout in seconds. Default: 0
-
force_started
()¶ Change the status to STARTED (e.g. exception raised).
-
force_stopped
()¶ Change the status to STOPPED (e.g. exception raised).
-
host
¶ Target host name.
-
install_files
() → None¶ Installs the files specified in the install_files parameter at the install target.
-
is_alive
¶ Called to periodically poll the resource health. Default implementation assumes the resource is always healthy.
-
logger
¶ logger object
-
logpath
¶ Path for log regexp matching.
-
make_runpath_dirs
()¶ Creates runpath related directories.
-
name
¶ Driver name.
-
outpath
¶ Path for stdout file regexp matching.
-
pause
()¶ Pauses entity execution.
-
pausing
()¶ Pause the resource.
-
pending_work
()¶ Resource has pending work.
-
port
¶ Client port number assigned.
-
post_start
()¶ Steps to be executed right after resource is started.
-
post_stop
()¶ Steps to be executed right after resource is stopped.
-
pre_start
() → None¶ Steps to be executed right before resource starts.
-
pre_stop
()¶ Steps to be executed right before resource stops.
-
receive
(timeout=None)[source]¶ Receive message.
Parameters: timeout ( int
) – Timeout in seconds.Returns: received FixMessage
objectReturn type: FixMessage
-
reconnect
()[source]¶ Starts a stopped FixClient instance reconnecting to the original host and port as it was originally started with.
If host and port were specified as context values they will be resolved again at this point.
This is helpful in cases the dependent process has also restarted on a different port.
-
register_failover
(klass: testplan.common.entity.base.Entity, params: dict) → None¶ Register a failover class to instantiate if resource start fails.
Parameters: - klass – failover class
- params – parameters for failover class __init__ method
-
restart
()¶ Stop and start the resource.
-
resume
()¶ Resumes entity execution.
-
resuming
()¶ Resume the resource.
-
runpath
¶ Path to be used for temp/output files by entity.
-
scratch
¶ Path to be used for temp files by entity.
-
send
(msg)[source]¶ Send message.
Parameters: msg ( FixMessage
) – Message to be sent.Returns: msg Return type: FixMessage
-
send_tsp
(msg)[source]¶ Send message.
Parameters: msg ( FixMessage
) – Message to be sent.Returns: Timestamp when msg sent (in microseconds from epoch) and msg. Return type: tuple
oflong
andFixMessage
-
sender
¶ FIX SenderCompID.
-
sendersub
¶ FIX SenderSubID.
-
start
()¶ Triggers the start logic of a Resource by executing :py:meth: Resource.starting <testplan.common.entity.base.Resource.starting> method.
-
started_check
() → Union[bool, testplan.common.entity.base.FailedAction][source]¶ Predicate indicating whether driver has fully started.
Default implementation tests whether certain pattern exists in driver loggings, always returns True if no pattern is required.
-
started_check_interval
¶ Driver started check interval. In practice this value is lower-bounded by 0.1 seconds.
-
starting
() → None¶ Triggers driver start.
-
status
¶ Status object.
-
stop
()¶ Triggers the stop logic of a Resource by executing :py:meth: Resource.stopping <testplan.common.entity.base.Resource.stopping> method.
-
stopped_check
() → Union[bool, testplan.common.entity.base.FailedAction]¶ Predicate indicating whether driver has fully stopped.
Default implementation immediately returns True.
-
stopped_check_interval
¶ Driver stopped check interval.
-
target
¶ FIX TargetCompID.
-
uid
() → str¶ Driver uid.
-
wait
(target_status, timeout=None)¶ Wait until objects status becomes target status.
Parameters: - target_status (
str
) – expected status - timeout (
int
orNoneType
) – timeout in seconds
- target_status (
- name (
-
class
testplan.testing.multitest.driver.fix.client.
FixClientConfig
(**options)[source]¶ Bases:
testplan.testing.multitest.driver.base.DriverConfig
Configuration object for
FixClient
driver.-
classmethod
build_schema
()¶ Build a validation schema using the config options defined in this class and its parent classes.
-
static
default_metadata_extractor
(driver) → testplan.testing.multitest.driver.base.DriverMetadata¶
-
denormalize
()¶ Create new config object that inherits all explicit attributes from its parents as well.
-
get_local
(name, default=None)¶ Returns a local config setting (not from container)
-
ignore_extra_keys
= False¶
-
parent
¶ Returns the parent configuration.
-
set_local
(name, value)¶ set without any check
-
classmethod
testplan.testing.multitest.driver.fix.server module¶
FixServer driver classes.
-
class
testplan.testing.multitest.driver.fix.server.
FixServer
(name: str, msgclass: type, codec: testplan.common.utils.sockets.codec.Codec, host: str = 'localhost', port: int = 0, version: str = 'FIX.4.2', tls_config: Optional[testplan.common.utils.sockets.tls.TLSConfig] = None, **options)[source]¶ Bases:
testplan.testing.multitest.driver.base.Driver
Driver for a server that can send and receive FIX messages over the session protocol.
Supports multiple connections. The server stamps every outgoing message with the senderCompID and targetCompID for the corresponding connection.
This is built on top of the
testplan.common.utils.sockets.fix.server.Server
class, which provides equivalent functionality and may be used outside of MultiTest.NOTE: FixServer requires select.poll(), which is not implemented on all operating systems - typically it is available on POSIX systems but not on Windows.
{emphasized_members_docs}
Parameters: - name (
str
) – Name of FixServer. - msgclass (
type
) – Type used to send and receive FIX messages. - codec (a
Codec
instance) – A Codec to use to encode and decode FIX messages. - host (
str
) – Host name to bind to. Default: ‘localhost’ - port (
int
) – Port number to bind to. Default: 0 (Random port) - version (
Optional[TLSConfig]
) – FIX version, defaults to “FIX.4.2”. This string is used as the contents of tag 8 (BeginString). - tls_config – If provided the connection will be encrypted
Also inherits all
Driver
options.-
CONFIG
¶ alias of
FixServerConfig
-
STATUS
¶
-
abort
()¶ Default abort policy. First abort all dependencies and then itself.
-
abort_dependencies
()¶ Returns an empty generator.
-
aborted
¶ Returns if entity was aborted.
-
active
¶ Entity not aborting/aborted.
-
active_connections
()[source]¶ Returns a list of currently active connections
Returns: List of active connection names (each a tuple of sender and target) Return type: list
oftuple
ofstr
andstr
-
async_start
¶ Overrides the default async_start value in config.
-
auto_start
¶ If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
-
cfg
¶ Configuration object.
-
context
¶ Key/value pair information of a Resource.
-
context_input
(exclude: list = None) → Dict[str, Any]¶ All attr of self in a dict for context resolution
-
define_runpath
()¶ Define runpath directory based on parent object and configuration.
-
errpath
¶ Path for stderr file regexp matching.
-
extract_driver_metadata
() → testplan.testing.multitest.driver.base.DriverMetadata¶ Extracts driver metadata as described in the extractor function.
Returns: driver metadata
-
extract_values
() → Union[bool, testplan.common.entity.base.FailedAction]¶ Extract matching values from input regex configuration options.
-
failover
() → None¶ API to create the failover resource, to be implemented in derived class
-
fetch_error_log
() → List[str]¶ Fetch error message from the log files of driver, at first we can try self.errpath, if it does not exist, try self.logpath. Typically, several lines from the tail of file will be selected.
Returns: text from log file
-
classmethod
filter_locals
(local_vars)¶ Filter out init params of None value, they will take default value defined in its ConfigOption object; also filter out special vars that are not init params from local_vars.
Parameters: local_vars –
-
force_started
()¶ Change the status to STARTED (e.g. exception raised).
-
force_stopped
()¶ Change the status to STOPPED (e.g. exception raised).
-
host
¶ Input host provided.
-
install_files
() → None¶ Installs the files specified in the install_files parameter at the install target.
-
is_alive
¶ Called to periodically poll the resource health. Default implementation assumes the resource is always healthy.
-
is_connection_active
(conn_name)[source]¶ Checks whether the given connection is currently active.
Parameters: conn_name ( tuple
ofstr
andstr
) – Connection name to be checked if activeReturns: True
if the given connection is active.False
otherwiseReturn type: bool
-
logger
¶ logger object
-
logpath
¶ Path for log regexp matching.
-
make_runpath_dirs
()¶ Creates runpath related directories.
-
name
¶ Driver name.
-
outpath
¶ Path for stdout file regexp matching.
-
pause
()¶ Pauses entity execution.
-
pausing
()¶ Pause the resource.
-
pending_work
()¶ Resource has pending work.
-
port
¶ Port retrieved after binding.
-
post_start
()¶ Steps to be executed right after resource is started.
-
post_stop
()¶ Steps to be executed right after resource is stopped.
-
pre_start
() → None¶ Steps to be executed right before resource starts.
-
pre_stop
()¶ Steps to be executed right before resource stops.
-
receive
(conn_name=(None, None), timeout=60)[source]¶ Receive a FIX message from the given connection.
The connection name defaults to
(None, None)
. In this case, the server will try to find the one and only available connection. This will fail if there are more connections available or if the initial connection is no longer active.Parameters: - conn_name (
tuple
ofstr
andstr
) – Connection name (sender and target ids) to receive message from. - timeout (
int
orNoneType
) –timeout in seconds or
None
- Specifying
None
as timeout will turn receive into a non-blocking call. In such case, if no message is immediately available,None
is returned and no exception is raised. - Specifying a numeric value will make receive a blocking call. If no message is received within the timeframe, a TimeoutException is raised.
- Specifying
Returns: received FixMessage object
Return type: FixMessage
- conn_name (
-
register_failover
(klass: testplan.common.entity.base.Entity, params: dict) → None¶ Register a failover class to instantiate if resource start fails.
Parameters: - klass – failover class
- params – parameters for failover class __init__ method
-
restart
()¶ Stop and start the resource.
-
resume
()¶ Resumes entity execution.
-
resuming
()¶ Resume the resource.
-
runpath
¶ Path to be used for temp/output files by entity.
-
scratch
¶ Path to be used for temp files by entity.
-
send
(msg, conn_name=(None, None))[source]¶ Send the given Fix message through the given connection.
The message will be enriched with session tags and sequence numbers. The connection name - (sender, target) - defaults to (None, None). In this case, the server will try to find the one and only available connection. This will fail if there are more connections available or if the initial connection is no longer active.
Parameters: - msg (
FixMessage
) – Message to be sent. - conn_name (
tuple
ofstr
andstr
) – Connection name to send message to. This is the tuple (sender id, target id)
Returns: Fix message sent
Return type: FixMessage
- msg (
-
start
()¶ Triggers the start logic of a Resource by executing :py:meth: Resource.starting <testplan.common.entity.base.Resource.starting> method.
-
started_check
() → Union[bool, testplan.common.entity.base.FailedAction]¶ Predicate indicating whether driver has fully started.
Default implementation tests whether certain pattern exists in driver loggings, always returns True if no pattern is required.
-
started_check_interval
¶ Driver started check interval. In practice this value is lower-bounded by 0.1 seconds.
-
status
¶ Status object.
-
stop
()¶ Triggers the stop logic of a Resource by executing :py:meth: Resource.stopping <testplan.common.entity.base.Resource.stopping> method.
-
stopped_check
() → Union[bool, testplan.common.entity.base.FailedAction]¶ Predicate indicating whether driver has fully stopped.
Default implementation immediately returns True.
-
stopped_check_interval
¶ Driver stopped check interval.
-
uid
() → str¶ Driver uid.
-
wait
(target_status, timeout=None)¶ Wait until objects status becomes target status.
Parameters: - target_status (
str
) – expected status - timeout (
int
orNoneType
) – timeout in seconds
- target_status (
- name (
-
class
testplan.testing.multitest.driver.fix.server.
FixServerConfig
(**options)[source]¶ Bases:
testplan.testing.multitest.driver.base.DriverConfig
Configuration object for
FixServer
driver.-
classmethod
build_schema
()¶ Build a validation schema using the config options defined in this class and its parent classes.
-
static
default_metadata_extractor
(driver) → testplan.testing.multitest.driver.base.DriverMetadata¶
-
denormalize
()¶ Create new config object that inherits all explicit attributes from its parents as well.
-
get_local
(name, default=None)¶ Returns a local config setting (not from container)
-
ignore_extra_keys
= False¶
-
parent
¶ Returns the parent configuration.
-
set_local
(name, value)¶ set without any check
-
classmethod
Module contents¶
FIX communication protocol drivers.