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 = None, interface: Tuple[str, int] | None = None, connect_at_start: bool = True, logon_at_start: bool = True, logoff_at_stop: bool = True, custom_logon_tags: FixMessage | None = None, receive_timeout: int | float = 30, logon_timeout: int | float = 10, logoff_timeout: int | float = 3, tls_config: TLSConfig | None = None, **options: Any)[source]
Bases:
DriverFix client driver.
This is built on top of the
testplan.common.utils.sockets.fix.client.Clientclass, 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
Codecinstance) – A Codec to use to encode and decode FIX messages.host (
str) – Target host name. This can be aContextValueand will be expanded on runtime.port (
int) – Target port number. This can be aContextValueand 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=Amessage.receive_timeout (
intorfloat) – Timeout in seconds while receiving from socket.logon_timeout (
intorfloat) – Timeout in seconds to wait for logon response.logoff_timeout (
intorfloat) – Timeout in seconds to wait for logoff response.tls_config – If provided the connection will be encrypted
Also inherits all
Driveroptions.- CONFIG
alias of
FixClientConfig
- EXTRACTORS: List[BaseConnectionExtractor] = [<testplan.testing.multitest.driver.connection.connection_extractor.ConnectionExtractor object>]
- STATUS
alias of
ResourceStatus
- abort() None
Default abort policy. First abort all dependencies and then itself.
- property aborted: bool
Returns if entity was aborted.
- property active: bool
Entity not aborting/aborted.
- property async_start: bool
Overrides the default async_start value in config.
- property auto_start: bool
If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
- property connection_identifier: int | None
- property context: Environment | None
Key/value pair information of a Resource.
- context_input(exclude: list | None = None) Dict[str, Any]
All attr of self in a dict for context resolution
- define_runpath() None
Define runpath directory based on parent object and configuration.
- property errpath: str | None
Path for stderr file regexp matching.
- extract_values() bool | FailedAction
Extract matching values from input regex configuration options.
- extracts: Dict[str, str]
- 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: Dict[str, Any]) Dict[str, Any]
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: int | float = 0) None[source]
Flush all inbound messages.
- Parameters:
timeout (
int) – Message receive timeout in seconds. Default: 0
- force_started() None
Change the status to STARTED (e.g. exception raised).
- force_stop() None
Change the status to STOPPED (e.g. exception raised).
- get_connections() List[BaseConnectionInfo]
- property host: str | None
Target host name.
- install_files() None
Installs the files specified in the install_files parameter at the install target.
- property is_alive: bool
Called to periodically poll the resource health. Default implementation assumes the resource is always healthy.
- property local_host: str | None
- property local_port: int | None
- property logger: TestplanLogger
logger object
- property logpath: str | None
Path for log regexp matching.
- make_runpath_dirs() None
Creates runpath related directories.
- property name: str
Driver name.
- property outpath: str | None
Path for stdout file regexp matching.
- pause() None
Pauses entity execution.
- pausing() None
Pause the resource.
- pending_work() bool
Resource has pending work.
- property port: int | None
Client port number assigned.
- post_start() None
Steps to be executed right after resource is started.
- post_stop() None
Steps to be executed right after resource is stopped.
- pre_start() None
Steps to be executed right before resource starts.
- pre_stop() None
Steps to be executed right before resource stops.
- receive(timeout: int | float | None = None) FixMessage[source]
Receive message.
- Parameters:
timeout (
int) – Timeout in seconds.- Returns:
received
FixMessageobject- Return type:
FixMessage
- reconnect() None[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: Type[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: ReportLink
A handle to access the report via recursive parent
- restart() None
Stop and start the resource.
- resume() None
Resumes entity execution.
- resuming() None
Resume the resource.
- property runpath: str
Path to be used for temp/output files by entity.
- property scratch: str
Path to be used for temp files by entity.
- send(msg: FixMessage) FixMessage[source]
Send message.
- Parameters:
msg (
FixMessage) – Message to be sent.- Returns:
msg
- Return type:
FixMessage
- send_tsp(msg: FixMessage) Tuple[float, FixMessage][source]
Send message.
- Parameters:
msg (
FixMessage) – Message to be sent.- Returns:
Timestamp when msg sent (in microseconds from epoch) and msg.
- Return type:
tupleoflongandFixMessage
- property sender: str
FIX SenderCompID.
- property sendersub: str
FIX SenderSubID.
- start() None
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: EntityStatus
Status object.
- stop() None
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: Any) bool | FailedAction
- property target: str
FIX TargetCompID.
- uid() str
Driver uid.
- wait(target_status: str | None, timeout: int | None = None) None
Wait until objects status becomes target status.
- Parameters:
target_status (
str) – expected statustimeout (
intorNoneType) – timeout in seconds
- class testplan.testing.multitest.driver.fix.client.FixClientConfig(**options: Any)[source]
Bases:
DriverConfigConfiguration object for
FixClientdriver.- classmethod build_schema() Schema
Build a validation schema using the config options defined in this class and its parent classes.
- denormalize() Config
Create new config object that inherits all explicit attributes from its parents as well.
- get_local(name: str, default: Any = None) Any
Returns a local config setting (not from container)
- classmethod get_options() Dict[Any, Any][source]
Schema for options validation and assignment of default values.
- ignore_extra_keys = False
- set_local(name: str, value: Any) None
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: Any)[source]
Bases:
DriverDriver 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.Serverclass, 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
Codecinstance) – 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
Driveroptions.- CONFIG
alias of
FixServerConfig
- EXTRACTORS: List[BaseConnectionExtractor] = [<testplan.testing.multitest.driver.connection.connection_extractor.ConnectionExtractor object>]
- STATUS
alias of
ResourceStatus
- abort() None
Default abort policy. First abort all dependencies and then itself.
- property aborted: bool
Returns if entity was aborted.
- property active: bool
Entity not aborting/aborted.
- active_connections() Any[source]
Returns a list of currently active connections
- Returns:
List of active connection names (each a tuple of sender and target)
- Return type:
listoftupleofstrandstr
- property async_start: bool
Overrides the default async_start value in config.
- property auto_start: bool
If False, the resource will not be automatically started by its parent (generally, a Environment object) while the parent is starting.
- property connection_identifier: int | None
- property context: Environment | None
Key/value pair information of a Resource.
- context_input(exclude: list | None = None) Dict[str, Any]
All attr of self in a dict for context resolution
- define_runpath() None
Define runpath directory based on parent object and configuration.
- property errpath: str | None
Path for stderr file regexp matching.
- extract_values() bool | FailedAction
Extract matching values from input regex configuration options.
- extracts: Dict[str, str]
- 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: Dict[str, Any]) Dict[str, Any]
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() None
Change the status to STARTED (e.g. exception raised).
- force_stop() None
Change the status to STOPPED (e.g. exception raised).
- get_connections() List[BaseConnectionInfo]
- property host: str | None
Input host provided.
- install_files() None
Installs the files specified in the install_files parameter at the install target.
- property is_alive: bool
Called to periodically poll the resource health. Default implementation assumes the resource is always healthy.
- is_connection_active(conn_name: Tuple[str | None, str | None]) bool[source]
Checks whether the given connection is currently active.
- Parameters:
conn_name (
tupleofstrandstr) – Connection name to be checked if active- Returns:
Trueif the given connection is active.Falseotherwise- Return type:
bool
- property local_host: str | None
- property local_port: int | None
- property logger: TestplanLogger
logger object
- property logpath: str | None
Path for log regexp matching.
- make_runpath_dirs() None
Creates runpath related directories.
- property name: str
Driver name.
- property outpath: str | None
Path for stdout file regexp matching.
- pause() None
Pauses entity execution.
- pausing() None
Pause the resource.
- pending_work() bool
Resource has pending work.
- property port: int | None
Port retrieved after binding.
- post_start() None
Steps to be executed right after resource is started.
- post_stop() None
Steps to be executed right after resource is stopped.
- pre_start() None
Steps to be executed right before resource starts.
- pre_stop() None
Steps to be executed right before resource stops.
- receive(conn_name: Tuple[str | None, str | None] = (None, None), timeout: int | None = 60) Any[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 (
tupleofstrandstr) – Connection name (sender and target ids) to receive message from.timeout (
intorNoneType) –timeout in seconds or
NoneSpecifying
Noneas timeout will turn receive into a non-blocking call. In such case, if no message is immediately available,Noneis 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: Type[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: ReportLink
A handle to access the report via recursive parent
- restart() None
Stop and start the resource.
- resume() None
Resumes entity execution.
- resuming() None
Resume the resource.
- property runpath: str
Path to be used for temp/output files by entity.
- property scratch: str
Path to be used for temp files by entity.
- send(msg: Any, conn_name: Tuple[str | None, str | None] = (None, None)) Any[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 (
tupleofstrandstr) – Connection name to send message to. This is the tuple (sender id, target id)
- Returns:
Fix message sent
- Return type:
FixMessage
- start() None
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: EntityStatus
Status object.
- stop() None
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: Any) bool | FailedAction
- uid() str
Driver uid.
- wait(target_status: str | None, timeout: int | None = None) None
Wait until objects status becomes target status.
- Parameters:
target_status (
str) – expected statustimeout (
intorNoneType) – timeout in seconds
- class testplan.testing.multitest.driver.fix.server.FixServerConfig(**options: Any)[source]
Bases:
DriverConfigConfiguration object for
FixServerdriver.- classmethod build_schema() Schema
Build a validation schema using the config options defined in this class and its parent classes.
- denormalize() Config
Create new config object that inherits all explicit attributes from its parents as well.
- get_local(name: str, default: Any = None) Any
Returns a local config setting (not from container)
- classmethod get_options() Dict[Any, Any][source]
Schema for options validation and assignment of default values.
- ignore_extra_keys = False
- set_local(name: str, value: Any) None
set without any check
Module contents
FIX communication protocol drivers.