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: Codec, host: str | ContextValue, port: int | 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: FixMessage = None, receive_timeout: int | float = 30, logon_timeout: int | float = 10, logoff_timeout: int | float = 3, tls_config: TLSConfig | None = None, **options)[source]
Bases:
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: Truelogon_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
- EXTRACTORS: List[BaseConnectionExtractor] = [<testplan.testing.multitest.driver.connection.connection_extractor.ConnectionExtractor object>]
- STATUS
alias of
ResourceStatus
- abort()
Default abort policy. First abort all dependencies and then itself.
- abort_dependencies()
Returns an empty generator.
- property aborted
Returns if entity was aborted.
- property active
Entity not aborting/aborted.
- property async_start: bool
Overrides the default async_start value in config.
- property auto_start
If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
- property cfg
Configuration object.
- property connection_identifier
- property 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.
- property errpath
Path for stderr file regexp matching.
- extract_values() bool | 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_stop()
Change the status to STOPPED (e.g. exception raised).
- get_connections() List[BaseConnectionInfo]
- property host
Target host name.
- install_files() None
Installs the files specified in the install_files parameter at the install target.
- property is_alive
Called to periodically poll the resource health. Default implementation assumes the resource is always healthy.
- property local_host
- property local_port
- property logger: TestplanLogger
logger object
- property logpath
Path for log regexp matching.
- make_runpath_dirs()
Creates runpath related directories.
- property name: str
Driver name.
- property outpath
Path for stdout file regexp matching.
- pause()
Pauses entity execution.
- pausing()
Pause the resource.
- pending_work()
Resource has pending work.
- property 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
object- Return 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: 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
- property report
A handle to access the report via recursive parent
- restart()
Stop and start the resource.
- resume()
Resumes entity execution.
- resuming()
Resume the resource.
- property runpath
Path to be used for temp/output files by entity.
- property 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
- property sender: str
FIX SenderCompID.
- property sendersub: str
FIX SenderSubID.
- start()
Triggers the start logic of a Resource by executing :py:meth: Resource.starting <testplan.common.entity.base.Resource.starting> method.
- property start_timeout: float
- started_check() bool | 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.
- property started_check_interval: float | Tuple[float, float]
Driver started check interval. In practice this value is lower-bounded by 0.1 seconds.
- starting() None
Triggers driver start.
- property status
Status object.
- stop()
Triggers the stop logic of a Resource by executing :py:meth: Resource.stopping <testplan.common.entity.base.Resource.stopping> method.
- property stop_timeout: float
- stopped_check() bool | FailedAction
Predicate indicating whether driver has fully stopped.
Default implementation immediately returns True.
- property stopped_check_interval: float | Tuple[float, float]
Driver stopped check interval.
- stopped_check_with_watch(watch) bool | FailedAction
- property target: str
FIX TargetCompID.
- property timer
- uid() str
Driver uid.
- wait(target_status, timeout=None)
Wait until objects status becomes target status.
- Parameters:
target_status (
str
) – expected statustimeout (
int
orNoneType
) – timeout in seconds
- class testplan.testing.multitest.driver.fix.client.FixClientConfig(**options)[source]
Bases:
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.
- 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
- property parent
Returns the parent configuration.
- set_local(name, value)
set without any check
testplan.testing.multitest.driver.fix.server module
FixServer driver classes.
- class testplan.testing.multitest.driver.fix.server.FixServer(name: str, msgclass: type, codec: Codec, host: str = 'localhost', port: int = 0, version: str = 'FIX.4.2', tls_config: TLSConfig | None = None, **options)[source]
Bases:
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
- EXTRACTORS: List[BaseConnectionExtractor] = [<testplan.testing.multitest.driver.connection.connection_extractor.ConnectionExtractor object>]
- STATUS
alias of
ResourceStatus
- abort()
Default abort policy. First abort all dependencies and then itself.
- abort_dependencies()
Returns an empty generator.
- property aborted
Returns if entity was aborted.
- property 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
- property async_start: bool
Overrides the default async_start value in config.
- property auto_start
If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
- property cfg
Configuration object.
- property connection_identifier
- property 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.
- property errpath
Path for stderr file regexp matching.
- extract_values() bool | 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_stop()
Change the status to STOPPED (e.g. exception raised).
- get_connections() List[BaseConnectionInfo]
- property host
Input host provided.
- install_files() None
Installs the files specified in the install_files parameter at the install target.
- property 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 active- Returns:
True
if the given connection is active.False
otherwise- Return type:
bool
- property local_host
- property local_port
- property logger: TestplanLogger
logger object
- property logpath
Path for log regexp matching.
- make_runpath_dirs()
Creates runpath related directories.
- property name: str
Driver name.
- property outpath
Path for stdout file regexp matching.
- pause()
Pauses entity execution.
- pausing()
Pause the resource.
- pending_work()
Resource has pending work.
- property 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.
- Returns:
received FixMessage object
- Return type:
FixMessage
- register_failover(klass: 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
- property report
A handle to access the report via recursive parent
- restart()
Stop and start the resource.
- resume()
Resumes entity execution.
- resuming()
Resume the resource.
- property runpath
Path to be used for temp/output files by entity.
- property 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
- start()
Triggers the start logic of a Resource by executing :py:meth: Resource.starting <testplan.common.entity.base.Resource.starting> method.
- property start_timeout: float
- started_check() bool | 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.
- property started_check_interval: float | Tuple[float, float]
Driver started check interval. In practice this value is lower-bounded by 0.1 seconds.
- property status
Status object.
- stop()
Triggers the stop logic of a Resource by executing :py:meth: Resource.stopping <testplan.common.entity.base.Resource.stopping> method.
- property stop_timeout: float
- stopped_check() bool | FailedAction
Predicate indicating whether driver has fully stopped.
Default implementation immediately returns True.
- property stopped_check_interval: float | Tuple[float, float]
Driver stopped check interval.
- stopped_check_with_watch(watch) bool | FailedAction
- property timer
- uid() str
Driver uid.
- wait(target_status, timeout=None)
Wait until objects status becomes target status.
- Parameters:
target_status (
str
) – expected statustimeout (
int
orNoneType
) – timeout in seconds
- class testplan.testing.multitest.driver.fix.server.FixServerConfig(**options)[source]
Bases:
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.
- 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
- property parent
Returns the parent configuration.
- set_local(name, value)
set without any check
Module contents
FIX communication protocol drivers.