stressor package

stressor.run_manager module

class stressor.run_manager.RunManager[source]

Bases: object

Executes a run-configuration in parallel sessions.

CHANNELS = ('log', 'start_run', 'start_session', 'start_sequence', 'start_activity', 'end_activity', 'end_sequence', 'end_session', 'end_run')
CTRL_HANDLER_SET = None
CURRENT_RUN_MANAGER = None
DEFAULT_OPTS = {'log_summary': True, 'monitor': False}
STAGES = ('ready', 'running', 'done', 'waiting', 'stopping', 'stopped')
static _console_ctrl_handler(ctrl)[source]
_run_one(session_manager)[source]

Run inside a separate thread.

activity_map = {}
config_manager

ConfigManager used to load the configuration YAML

console_ctrl_handler(ctrl)[source]
Parameters

ctrl (int) – 0: CTRL_C_EVENT, 1: CTRL_BREAK_EVENT, 2: CTRL_CLOSE_EVENT

Returns

True if handled False if not handled, i.e. next registered handler will be called

get_cli_summary()[source]
get_run_time()[source]
get_status_info()[source]
has_errors(or_warnings=False)[source]
load_config(run_config_file)[source]

Load configuration file and set shortcuts.

log_info(*args, **kwargs)[source]
publish(channel, allow_cancel=False, *args, **kwargs)[source]

Notify all subscribed handlers.

run(options, extra_context=None)[source]

Run the current

Parameters
  • options (dict) – see RunManager.DEFAULT_OPTS

  • extra_context (dict, optional)

Returns

(int) Exit code 0 if no errors occurred

run_in_threads(user_list, context)[source]
static set_console_ctrl_handler()[source]
set_stage(stage)[source]
stats

StatisticManager object that containscurrent execution path

stop(graceful=2)[source]
stop_request

Set this event to shut down the app

stop_request_graceful

determines if a stop request is graceful or not True: Finalize the current sequence, then do ‘end’ sequence before stopping

Type

(bool)

Type

TODO

stop_request_monitor

determines if a stop request will keep the monitor running True: Finalize the current sequence, then do ‘end’ sequence before stopping?

Type

(bool)

Type

TODO

subscribe(channel, handler)[source]

stressor.context_stack module

class stressor.context_stack.ContextStack(name=None, context=None)[source]

Bases: object

The context manager Examples:

MAX_DEPTH = 100
_push(context)[source]
Raises

RuntimeError if queue length exceeds ContextStack.MAX_DEPTH

as_dict()[source]

Return the current aggregated context.

property context
enter(name, attributes=None)[source]
get_attr(key_path, context=None)[source]
level()[source]
path()[source]
peek(offset=1)[source]
Raises

IndexError if offset is invalid

pop()[source]
Raises

IndexError if queue is empty

push(name, attributes=None, copy_data=False)[source]

Push name to the stack and optionally update or copy context. :Parameters: name (str)

Raises

RuntimeError if queue length exceeds ContextStack.MAX_DEPTH

set_last_part(name)[source]
class stressor.context_stack.RunContext(parent, name, update_attributes=None, copy_data=False)[source]

Bases: object

Basically a dict, holding context variables as key/value pairs.

The ContextStack organizes instances of this class as stack, so we can have a scope-dependant context.

Values may contain $… macros.

parent

The stack frame parent or None if this is the root.

Type

RunContext

name

A short name for this context. The context manager uses it to concatenate a path string for the current scope.

Type

str

own_attributes

A dict of attributes that are explicitly defined by this instance.

Type

dict

all_attributes

The aggregated context, created by overloading the parent’s context with our own attributes

Type

dict

stressor.config_manager module

class stressor.config_manager.ConfigManager(stats_manager)[source]

Bases: object

Define and validate a run-configuration. Also reads and compiles YAML files.

FILE_VERSION = 0

Currently supportted syntax version. (Incremented when incompatible changes are introduced.)

_compile(value, parent=None, parent_key=None, stack=None)[source]

Apply load-time conversions after a config file was read.

  • Replace activity definitions with instances of ActvityBase

  • Resolve load-time macros (partly by replacing them with activites)

Note: Some makros, especially $(CONTEXT.VAR) are not resolved here, because this needs to be done at run-time.

property config

Shortcut to config_all[“run_config”].

config_all

(dict) The complete parsed YAML file as dict

property context

Shortcut to config_all[“context”].

file_version

(int) The file version, parsed from the filer_version#VERSION tag

get(key_path, default=<class 'stressor.util.NO_DEFAULT'>)[source]
has_errors(or_warnings=False)[source]
name

(str) Shortcut to self.run_config[“name”] (defaults to filename without extension)

path

(str) Absolute path of the YAML file

read(path, load_files=True)[source]

Read a YAML file into self.config_all.

Raises

ConfigurationError

report_error(msg, level='error', exc=None, stack=None)[source]

Called by activity and macro constructors to signal errors or warnings.

The compiler also calls this when a constructor raises an exception.

resolve_path(path, must_exist=True, check_root=True, default_ext=None)[source]

Return an absolute path, assuming relative to the original config file.

results

(dict) lists of compile errors and warnings

root_folder

(str) Absolute root folder of the YAML file

property scenario

Shortcut to config_all[“scenario”].

property sequences

Shortcut to config_all[“sequences”].

property sessions

Shortcut to config_all[“sessions”].

stack

(stressor.util.PathStack) Current compile location

stats_manager

(dict) The complete parsed YAML file as dict

update_config(extra_config, context_only=False)[source]

Override self.config (and self.context) with new items.

self.config was already copied to self.context, so normally we want to update both.

Parameters
  • extra_config (dict) – new values

  • context_only (bool) – pass true to only set the shadow-copy (i.e. context)

validate_config(cfg=None)[source]
Raises

ConfigurationError

Returns

(int) Current file format version as defined in file_version – stressor#N

exception stressor.config_manager.ConfigurationError[source]

Bases: StressorError

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

stressor.config_manager.replace_var_macros(value, context)[source]

Replace all macros of type $(CONTEXT.VAR.NAME).

stressor.statistic_manager module

class stressor.statistic_manager.StatisticManager[source]

Bases: object

Example:

{'act_count': 4485,
'act_time': 404.5604224205017,
'act_time_avg': 0.09020299273589781,
'act_time_max': 0.3416469097137451,
'act_time_min': 0.00455021858215332,
'errors': 0,
'monitored': {'/config/sequences/main/2/activity': {'act_count': 889,
                                                    'act_time': 37.441248655319214,
                                                    'act_time_avg': 0.04211614021970665,
                                                    'act_time_max': 0.1545419692993164,
                                                    'act_time_min': 0.006118059158325195}},
'net_act_count': 3586,
'net_act_time': 132.06326842308044,
'net_act_time_avg': 0.03682745912523158,
'net_act_time_max': 0.1629331111907959,
'net_act_time_min': 0.00455021858215332,
'seq_count': 909,
'seq_time': 405.6781575679779,
'seq_time_avg': 0.4462906023850142,
'seq_time_max': 0.6640150547027588,
'seq_time_min': 0.04558515548706055,
'sequence_stats': {'end': {'act_count': 20,
                            'act_time': 1.2047512531280518,
                            'act_time_avg': 0.060237562656402587,
                            'act_time_max': 0.10723018646240234,
                            'act_time_min': 0.0059051513671875,
                            'errors': 0,
                            'net_act_count': 10,
                            'net_act_time': 0.17910146713256836,
                            'net_act_time_avg': 0.017910146713256837,
                            'net_act_time_max': 0.042352914810180664,
                            'net_act_time_min': 0.0059051513671875,
                            'seq_count': 10,
                            'seq_time': 1.2114121913909912,
                            'seq_time_avg': 0.12114121913909912,
                            'seq_time_max': 0.14590692520141602,
                            'seq_time_min': 0.1082160472869873,
                            'warnings': 0},
                    'init': ...
'sessions': {'t1': {'act_count': 454,
                    'act_time': 40.14628767967224,
                    'act_time_avg': 0.08842794643099612,
                    'act_time_max': 0.3342282772064209,
                    'act_time_min': 0.00455021858215332,
                    'errors': 0,
                    'net_act_count': 363,
                    'net_act_time': 12.54139757156372,
                    'net_act_time_avg': 0.034549304604858735,
                    'net_act_time_max': 0.11727690696716309,
                    'net_act_time_min': 0.00455021858215332,
                    'path': '/h1/p1/t1',
                    'seq_count': 92,
                    'seq_time': 40.26065945625305,
                    'seq_time_avg': 0.4376158636549245,
                    'seq_time_max': 0.6443750858306885,
                    'seq_time_min': 0.05200076103210449,
                    'user': 'User_1',
                    'warnings': 0},
            't2': {'act_count': 449,
            ...
'stage': None,
'warnings': 0}
_add_error(d, error)[source]
_add_timing(d, key_prefix, elap, is_net=None)[source]
_report(mode, session, sequence, activity, path=None, error=None)[source]
error_count(or_warnings=False)[source]
format_result()[source]
get_error_info(args)[source]
get_monitor_info(config_all)[source]
has_errors(or_warnings=False)[source]
register_activity(activity)[source]

Called by compiler.

register_sequence(name)[source]

Called by compiler.

register_session(session)[source]

Called by run_manager.

report_end(session, sequence, activity)[source]
report_error(session, sequence, activity, error)[source]
report_limit_violation(msg)[source]

Register ‘limit reached’ error (not more than once).

report_start(session, sequence, activity, path=None)[source]

stressor.session_manager module

class stressor.session_manager.SessionHelper(session)[source]

Bases: object

Passed to script activities.

property browser
class stressor.session_manager.SessionManager(run_manager, context, session_id, user)[source]

Bases: object

Run a scenario in a single session.

_evaluate_macros(kwargs, context)[source]
_process_activity_result(activity, activity_args, result, elap)[source]

Perform common checks.

Raises

ActivityAssertionError

property browser_session

Return a requests.Session instance for this session.

check_run_limits(seq_name)[source]

Check if current time or number of errors exceeds the configured limits.

Parameters

seq_name (str) – current sequence name. Used to determine if a stopping session should still execute the ‘end’ sequence if the limit was reached during a main sequence.

Returns

(bool) false if the current operation should be skipped.

property context
context_stack

The ContextStack object that reflects the current execution path

data

(dict) Activities can store per-session data here. Note that the activity objects are instintiated only once and shared by all sessions.

dry_run

only simulate activities

Type

(bool) True

get_config(dotted_key=None, default=<class 'stressor.util.NO_DEFAULT'>)[source]
get_context(dotted_key=None, default=<class 'stressor.util.NO_DEFAULT'>)[source]
has_errors(or_warnings=False)[source]
log_info(*args)[source]
make_session_helper()[source]

Return a SessionHelper instance for this session.

max_errors

(int) Stop session if global error count > X Passing –max-errors will override this.

max_time

(float) Stop session if total run time > X seconds. Passing –max-time will override this.

publish(channel, *args, **kwargs)[source]
report_activity_error(sequence, activity, activity_args, exc)[source]

Called session runner when activity execute() or assertions raise an error.

report_activity_result(sequence, activity, activity_args, result, elap)[source]

Called session runner when activity execute() completes.

report_activity_start(sequence, activity)[source]

Called by session runner before activities is executed.

run()[source]
run_manager

The RunManager object that holds global settings and definitions

run_sequence(seq_name, sequence)[source]
property sess_stats
session_id

(str) Unique ID string for this session

sessions

(dict) Copy of run_config.sessions configuration

stats

StatisticManager object that containscurrent execution path

stop_request

(threading.Event)

user

The User object that is assigned to this session

verbose

(int) Verbosity 0..5

exception stressor.session_manager.SkippedError[source]

Bases: StressorError

Raised when an activity is skipped due to max_errors or max_time.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception stressor.session_manager.StoppedError[source]

Bases: StressorError

Raised when an activity stops due because the stop_request is set.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class stressor.session_manager.User(name, password, **kwargs)[source]

Bases: object

property auth

Return (name, password) tuple or None.

stressor.util module

class stressor.util.NO_DEFAULT[source]

Bases: object

Used as default parameter to distinguish from None.

class stressor.util.PathStack(root_name=None, delimiter='/')[source]

Bases: object

Examples:

path = PathStack()
with path.enter("level_1"):
    print("Current location: {}".format(path))
enter(name, ignore=False)[source]
get_path(skip_segs=0, last_seg=None)[source]
level()[source]
pop()[source]
push(name)[source]
stressor.util.RE_YAML_KEYWORD = re.compile('^[a-zA-Z_]+\\w*$')

Check if a a string may be used as YAML dictionary key without using quotes. NOTE: YAML evaluates 0_ as “0” and 0_1_ as “1”, so we don’t accept leading numbers

exception stressor.util.StressorError[source]

Bases: RuntimeError

Base class for all exception that we deliberatly throw.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class stressor.util._VOID_SEGMENT[source]

Bases: object

Used internally.

stressor.util._check_arg(argument, types, condition, accept_none)[source]
stressor.util.assert_always(condition, msg=None)[source]

assert even in production code.

stressor.util.base_url(url)[source]
stressor.util.check_arg(argument, allowed_types, condition=<class 'stressor.util.NO_DEFAULT'>, or_none=False)[source]

Check if argument has the expected type and value.

Note: the exception’s traceback is manipulated, so that the back frame points to the check_arg() line, instead of the actual raise.

Parameters
  • argument (any) – value of the argument to check

  • allowed_types (type or tuple of types)

  • condition (bool, optional) – additional condition that must be true

  • or_none (bool, optional) – defaults to false

Returns

None

Raises
  • TypeError – if argument is of an unexpected type

  • ValueError – if argument does not fulfill the optional condition

  • AssertionError – if check_arg was called with a wrong syntax, i.e. allowed_types does not contain types, e.g. if 1 was passed instead of int.

Examples:

def foo(name, amount, options=None):
    check_arg(name, str)
    check_arg(amount, (int, float), amount > 0)
    check_arg(options, dict, or_none=True)
stressor.util.check_cli_verbose(default=3)[source]

Check for presence of –verbose/–quiet or -v/-q without using argparse.

stressor.util.coerce_str(s)[source]

Return s converted to float, int, or str.

stressor.util.datetime_to_iso(dt=None, microseconds=False)[source]

Return current UTC datetime as ISO formatted string.

stressor.util.format_elap(seconds, count=None, unit='items', high_prec=False)[source]

Return elapsed time as H:M:S.h string with reasonable precision.

stressor.util.format_num(num)[source]

Return num rounded to reasonable precision (promille).

stressor.util.format_rate(count, time, unit=None, high_prec=False)[source]

Return count / time with reasonable precision.

stressor.util.get_dict_attr(d, key_path, default=<class 'stressor.util.NO_DEFAULT'>)[source]

Return the value of a nested dict using dot-notation path.

Parameters
  • d (dict)

  • key_path (str)

Raises
  • KeyError

  • ValueError

  • IndexError

Examples:

...

Todo

  • k[1] instead of k.[1]

  • default arg

stressor.util.get_random_number(num_or_tuple)[source]
stressor.util.init_logging(verbose=3, path=None)[source]

CLI calls this.

stressor.util.is_relative_url(url)[source]

Return true if url is relative to the server.

stressor.util.is_yaml_keyword(s)[source]

Return true if s is a JSON compatible key.

stressor.util.iso_to_datetime(iso)[source]

Convert as ISO formatted datetime string to datetime.

stressor.util.iso_to_stamp(iso)[source]

Convert as ISO formatted datetime string to datetime.

stressor.util.log_important(self, message, *args, **kws)[source]
stressor.util.lstrip_string(s, prefix, ignore_case=False)[source]

Remove leading string from s.

Note: This is different than s.lstrip(‘bar’) which would remove all leading ‘a’, ‘b’, and ‘r’ chars.

stressor.util.parse_args_from_str(arg_str, arg_defs)[source]
Parameters
  • args_str (str) – argument string, optionally comma-separated

  • arg_defs (tuple) – list of argument definitions

  • context (dict, optional) – When passed, the arguments are parsed for $(var_name) macros, to lookup values from that dict.

Returns

(dict) keyword args

Raises
  • TypeError – if argument is of an unexpected type

  • ValueError – if argument does not fulfill the optional condition

  • AssertionError – if parse_args_from_str was called with a wrong syntax, i.e. arg_defs is not well-formed.

Examples:

arg_defs = (
    ("name", str),
    ("amount", float),
    ("options", dict, {}),
)
def order(raw_arg_string):
    kwargs = parse_args_from_str(arg_defs)
    assert isisnstance(kwargs["name"], str)
    assert type(kwargs["amount"]) is float
    assert isisnstance(kwargs["options"], dict)
stressor.util.parse_option_args(opt_list, coerce_values=True)[source]

Evaluate –option args.

Parameters
  • opt_list (list) – List of option definitions of the form “OPT_NAME:OPT_VALUE”

  • coerce_values (bool=true)

Returns

Dict of {opt_name – opt_value, …}

stressor.util.resolve_url(root, url)[source]

Convert relative URL to absolute, using root as default.

stressor.util.set_console_ctrl_handler(ctrl_handler, do_ctrl_c=True, do_ctrl_break=False, do_ctrl_close=False)[source]

The do_ctrl_* functions could simply be sys.exit(1), which will ensure that atexit handlers get called. See https://bugs.python.org/issue35935

Raises

ctypes.WinError

Returns

False if not on Windows or could not register the handler.

stressor.util.shorten_string(long_string, max_chars, min_tail_chars=0, place_holder='[...]')[source]

Return string, shortened to max_chars characters.

long_string = “This is a long string, that will be truncated.” trunacated_string = truncate_string(long_string, max_chars=26, min_tail_chars=11, place_holder=”[…]”) print trunacated_string >> This is a […] truncated.

@param long_string: string to be truncated @param max_chars: max chars of returned string @param min_tail_chars: minimum of tailing chars @param place_holder: place holder for striped content @return: truncated string

stressor.util.timetag(seconds=True, ms=False)[source]

Return a time stamp string that can be used as (part of a) filename (also sorts well).

stressor.log module

stressor.plugins package

stressor.plugins.base module

exception stressor.plugins.base.ActivityAssertionError(assertion_list)[source]

Bases: ActivityError

Assertion failed (e.g. assert_match argument, …).

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class stressor.plugins.base.ActivityBase(config_manager, **activity_args)[source]

Bases: ABC

Common base class for all activities.

New activity plugins can be created by deriving from this class, importing it, and then calling register_activity_plugins().

Names of derived classes should end with ‘…Activity’. Classes which names that begin with an underscore (‘_’) are ignored.

__repr__()

Provide nicer display for pprint(), etc.

__str__()[source]

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

_info_args = None

(tuple|None) List of argument names that will be displayed in path strings

_known_args = None

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = None

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

abstract execute(session, **expanded_args)[source]

Called by the SessionManager, after $(context.var) macros have been resolved if any. A derived class MUST implement this method.

The session manager calls this methods for every activity instance:

  1. prepare_execute()

  2. get_info()

  3. execute()

  • Call session.log_warning()

  • raise ActivityError() for errors that a user can ignore by –force flag

  • Honor session.stop_request

  • Honor session.dry_run

Parameters
  • session (SessionManager)

  • expanded_args (dict) – current global vars

Raises
  • ActivityError

  • Exception – all other exceptions are considered a fatal error

Returns

nothing

get_info(info_args=True, expanded_args=None, session=None)[source]

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()[source]
prepare_execute(session, expanded_args)[source]

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

exception stressor.plugins.base.ActivityCompileError[source]

Bases: ActivityError

Raised when activity constructor fails.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception stressor.plugins.base.ActivityError[source]

Bases: StressorError

Base for all errors that are explicitly raised by activities.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception stressor.plugins.base.ActivityTimeoutError[source]

Bases: ActivityError

Activity timed out.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class stressor.plugins.base.MacroBase(**macro_args)[source]

Bases: ABC

Common base class for all load-time script macros of the form $NAME(ARGS).

These macros are applied at load time to the nested dict that was read from a YAML file. Typically they replace the value of that dict element (parent[parent_key]) with new content.

For example

  • $load(PATH) replaces the element with a parsed YAML content or the text content of a python file.

  • $sleep(DURATION) replaces the element with a SleepActivity definition

Note that context variable expansions of the form $(CONTEXT.VAR.NAME) are not handled by this kind of macro, because this has to be dealt with at run time.

TODO: This means that ARGS cannot be dynamic, so for example $load($(my_file_name)) will not work.

Custom macro plugins can be defined by deriving from this class, importing it, and then calling register_macro_plugins().

_abc_impl = <_abc_data object>
_args_def = None

List of tuples that define the supported positional arguments and optional default values. See stressor.util.parse_args_from_str() for syntax. If None, the raw cotent inside the brackets is passed as single string .

_regex = None

Regular expression that extracts ‘$NAME(ARGS)’ Defaults to …

_script_name = None

Name for use in scripts. Defaults to lowercase class name without trailing …Macro, e.g. ‘LoadMacro’ is exposed as $load(...)

abstract apply(context_reader, parent, parent_key, args_str)[source]
Parameters
  • context_reader (ConfigManager)

  • parent (dict|list)

  • parent_key (str|int)

  • args_str (str|**kwargs)

Returns

(any) The result that was produced (and stored into parent[parent_key])

classmethod get_regex()[source]
classmethod get_script_name()[source]
match_apply(context_reader, parent, parent_key)[source]

Parse current value and call self.apply() if the macro matches.

This default implementation supports :returns: (bool, any) (handled, )

run_time_eval = False

Allow late evaluation (e.g. $stamp) TODO: Not yet implemented

exception stressor.plugins.base.ScriptActivityError[source]

Bases: ActivityError

Raised when a ScriptActivity fails.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

stressor.plugins.base.common_args = {'activity', 'assert_match', 'assert_max_time', 'debug', 'mock_result', 'monitor', 'name'}

(set) all activities accept these arguments

stressor.plugins.common module

class stressor.plugins.common.DebugMacro(**macro_args)[source]

Bases: MacroBase

Implement $debug() macro, which dumps information at run-time.

_abc_impl = <_abc_data object>
_args_def = None

List of tuples that define the supported positional arguments and optional default values. See stressor.util.parse_args_from_str() for syntax. If None, the raw cotent inside the brackets is passed as single string .

_regex = None

Regular expression that extracts ‘$NAME(ARGS)’ Defaults to …

_script_name = None

Name for use in scripts. Defaults to lowercase class name without trailing …Macro, e.g. ‘LoadMacro’ is exposed as $load(...)

apply(config_manager, parent, parent_key, var_name)[source]
Parameters
  • context_reader (ConfigManager)

  • parent (dict|list)

  • parent_key (str|int)

  • args_str (str|**kwargs)

Returns

(any) The result that was produced (and stored into parent[parent_key])

classmethod get_regex()
classmethod get_script_name()
match_apply(context_reader, parent, parent_key)

Parse current value and call self.apply() if the macro matches.

This default implementation supports :returns: (bool, any) (handled, )

run_time_eval = False

Allow late evaluation (e.g. $stamp) TODO: Not yet implemented

class stressor.plugins.common.EnvMacro(**macro_args)[source]

Bases: MacroBase

Implement $env(var_name) macro, which resolves an environment variable at load-time.

_abc_impl = <_abc_data object>
_args_def = None

List of tuples that define the supported positional arguments and optional default values. See stressor.util.parse_args_from_str() for syntax. If None, the raw cotent inside the brackets is passed as single string .

_regex = None

Regular expression that extracts ‘$NAME(ARGS)’ Defaults to …

_script_name = None

Name for use in scripts. Defaults to lowercase class name without trailing …Macro, e.g. ‘LoadMacro’ is exposed as $load(...)

apply(config_manager, parent, parent_key, var_name)[source]
Parameters
  • context_reader (ConfigManager)

  • parent (dict|list)

  • parent_key (str|int)

  • args_str (str|**kwargs)

Returns

(any) The result that was produced (and stored into parent[parent_key])

classmethod get_regex()
classmethod get_script_name()
match_apply(context_reader, parent, parent_key)

Parse current value and call self.apply() if the macro matches.

This default implementation supports :returns: (bool, any) (handled, )

run_time_eval = False

Allow late evaluation (e.g. $stamp) TODO: Not yet implemented

class stressor.plugins.common.LoadMacro(**macro_args)[source]

Bases: MacroBase

Implement $load(path) macro.

_abc_impl = <_abc_data object>
_args_def = None

List of tuples that define the supported positional arguments and optional default values. See stressor.util.parse_args_from_str() for syntax. If None, the raw cotent inside the brackets is passed as single string .

_regex = None

Regular expression that extracts ‘$NAME(ARGS)’ Defaults to …

_script_name = None

Name for use in scripts. Defaults to lowercase class name without trailing …Macro, e.g. ‘LoadMacro’ is exposed as $load(...)

apply(config_manager, parent, parent_key, path)[source]
Parameters
  • context_reader (ConfigManager)

  • parent (dict|list)

  • parent_key (str|int)

  • args_str (str|**kwargs)

Returns

(any) The result that was produced (and stored into parent[parent_key])

classmethod get_regex()
classmethod get_script_name()
match_apply(context_reader, parent, parent_key)

Parse current value and call self.apply() if the macro matches.

This default implementation supports :returns: (bool, any) (handled, )

run_time_eval = False

Allow late evaluation (e.g. $stamp) TODO: Not yet implemented

class stressor.plugins.common.SleepActivity(config_manager, **activity_args)[source]

Bases: ActivityBase

Parameters

duration (float) – sleep duration in seconds

Examples:

sequences:
  main:
    - activity: Sleep
      duration: 0.5
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = True

Sleep activities are ignorable by default

_default_monitor = False

(bool)

_info_args = ('name', 'duration', 'duration_2')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'duration', 'duration_2'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'duration'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)[source]

Called by the SessionManager, after $(context.var) macros have been resolved if any. A derived class MUST implement this method.

The session manager calls this methods for every activity instance:

  1. prepare_execute()

  2. get_info()

  3. execute()

  • Call session.log_warning()

  • raise ActivityError() for errors that a user can ignore by –force flag

  • Honor session.stop_request

  • Honor session.dry_run

Parameters
  • session (SessionManager)

  • expanded_args (dict) – current global vars

Raises
  • ActivityError

  • Exception – all other exceptions are considered a fatal error

Returns

nothing

get_info(info_args=True, expanded_args=None, session=None)[source]

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)[source]

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.common.SleepMacro(**macro_args)[source]

Bases: MacroBase

Implement $sleep(duration) macro, which is a shortcut to :class`SleepActivity`.

_abc_impl = <_abc_data object>
_args_def = (('min', <class 'float'>), ('max', <class 'float'>, None))

List of tuples that define the supported positional arguments and optional default values. See stressor.util.parse_args_from_str() for syntax. If None, the raw cotent inside the brackets is passed as single string .

_regex = None

Regular expression that extracts ‘$NAME(ARGS)’ Defaults to …

_script_name = None

Name for use in scripts. Defaults to lowercase class name without trailing …Macro, e.g. ‘LoadMacro’ is exposed as $load(...)

apply(config_manager, parent, parent_key, min, max)[source]
Parameters
  • context_reader (ConfigManager)

  • parent (dict|list)

  • parent_key (str|int)

  • args_str (str|**kwargs)

Returns

(any) The result that was produced (and stored into parent[parent_key])

classmethod get_regex()
classmethod get_script_name()
match_apply(context_reader, parent, parent_key)

Parse current value and call self.apply() if the macro matches.

This default implementation supports :returns: (bool, any) (handled, )

run_time_eval = False

Allow late evaluation (e.g. $stamp) TODO: Not yet implemented

stressor.plugins.http_activities module

class stressor.plugins.http_activities.DeleteRequestActivity(config_manager, **activity_args)[source]

Bases: HTTPRequestActivity

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.GetRequestActivity(config_manager, **activity_args)[source]

Bases: HTTPRequestActivity

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.HTTPRequestActivity(config_manager, **activity_args)[source]

Bases: ActivityBase

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)[source]
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)[source]
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)[source]
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)[source]

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.PollRequestActivity(config_manager, **activity_args)[source]

Bases: HTTPRequestActivity

TODO: This activity simulates a peridodical request to a single URL.

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.PostRequestActivity(config_manager, **activity_args)[source]

Bases: HTTPRequestActivity

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.PutRequestActivity(config_manager, **activity_args)[source]

Bases: HTTPRequestActivity

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

classmethod _format_response(resp, short=False, add_headers=False, ruler=True)
_info_args = ('name', 'method', 'url')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_html', 'assert_json', 'assert_match_headers', 'assert_status', 'auth', 'data', 'headers', 'json', 'method', 'params', 'store_json', 'timeout', 'url', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'method', 'url'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

classmethod _raise_assertion(cause, resp)
_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)
Raises
  • ActivityAssertionError

  • requests.exceptions.ConnectionError – ‘Connection refused’, etc.

  • requests.exceptions.HTTPError – On 404, 500, etc.

get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

class stressor.plugins.http_activities.StaticRequestsActivity(config_manager, **activity_args)[source]

Bases: ActivityBase

This activity recieves a list of URLs (JavaScript, Html, CSS, Images, …) and loads them, using max. ~5 threads, as a browser would.

REQUEST_ARGS = {'auth', 'data', 'headers', 'json', 'params', 'timeout', 'verify'}
__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

_info_args = ('name', 'method', 'thread_count')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'assert_status', 'auth', 'data', 'headers', 'json', 'params', 'thread_count', 'timeout', 'url_list', 'verify'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = {'url_list'}

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)[source]
get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

stressor.plugins.http_activities.match_value(pattern, value, info)[source]

Return .

stressor.plugins.script_activities module

class stressor.plugins.script_activities.RunScriptActivity(config_manager, **activity_args)[source]

Bases: ActivityBase

__repr__()

Return a descriptive string.

__str__()

Return a descriptive string.

_abc_impl = <_abc_data object>
_all_known_args = None

(set) Internal use only!

_default_ignore_timing = False

(bool)

_default_monitor = False

(bool)

_info_args = ('name', 'path')

(tuple|None) List of argument names that will be displayed in path strings

_known_args = {'export', 'path', 'script'}

(set) If defined, the default implementation of compile() will raise an error if other args are passed to the constructor.

_mandatory_args = None

(set) If defined, the default implementation of compile() will raise an error if any of those args is not passed.

_script_name = None

(str) Name by which the actvity can be used in YAML configurations. Defaults to class name without trailing …Activity, e.g. ‘SleepActivity’ is called as activity: Sleep

execute(session, **expanded_args)[source]
get_info(info_args=True, expanded_args=None, session=None)

Return a descriptive string (optionally using expanded args).

This method can be called with or without the additional context of the current session and expanded argument macros.

Parameters
  • info_args (tuple|bool) – List of argument names that should be added to display string. True: default to self._info_args (see None by default) False: don’t add arguments None: all arguments

  • expanded_args (dict, optional) – optional argment dict (defaults to self.raw_args)

  • session (SessionManager, optional) – Running session context

classmethod get_script_name()
prepare_execute(session, expanded_args)

Allow an activity to prepare the next execution.

The session manager calls this for every activity instance, directly before get_info() and execute(). Normally this method does not need to be implemented. (One exception is SleepActivity, that calculates the next random duration per session, so it can be displayed by get_info(…, session).)

script
source

Store a shortened code snippet for debug output

stressor.convert package

stressor.convert.har_converter module

https://w3c.github.io/web-performance/specs/HAR/Overview.html

class stressor.convert.har_converter.HarConverter(opts)[source]

Bases: object

Convert HAR file to YAML scenario.

DEFAULT_OPTS = {'base_url': True, 'collate_max_duration': 1.0, 'collate_max_len': 100, 'collate_max_pause': 0.2, 'collate_thread_count': 5, 'force': False, 'fspec': None, 'skip_errors': True, 'skip_externals': True, 'statics_types': (re.compile('image/.*', re.IGNORECASE), re.compile('.*/css', re.IGNORECASE), re.compile('.*/javascript', re.IGNORECASE)), 'target_folder': None}

Defaults for optional –opts paramter.

_add_entry(har_entry)[source]

Store the most important properties of an HAR entry.

_calc_request_time(har_entry)[source]
_copy_template(tmpl_name, target_path, kwargs)[source]
_init_from_templates(target_folder)[source]
_is_static(entry)[source]
_parse(fspec)[source]
_postprocess()[source]
_time_names = ('blocked', 'dns', 'connect', 'send', 'wait', 'receive')
_write_args(lines, name, data)[source]
Parameters
  • lines (list)

  • name (str)

  • data (list) – a ‘params’ list of {name: …, value: …} objects

_write_entry(fp, entry)[source]
_write_sequence(fspec)[source]
activity_map = {'DELETE': 'DeleteRequest', 'GET': 'GetRequest', 'POST': 'PostRequest', 'PUT': 'PutRequest'}
base_url

(str) Available after self._parse()

run()[source]

stressor.monitor package

stressor.monitor.server module

class stressor.monitor.server.Handler(*args, **kwargs)[source]

Bases: SimpleHTTPRequestHandler

DIRECTORY = None
_return_json(body, status=HTTPStatus.OK)[source]
do_GET()[source]

Serve a GET request.

log_error(format, *args)[source]

Log an error.

This is called when a request cannot be fulfilled. By default it passes the message on to log_message().

Arguments are the same as for log_message().

XXX This should go to the separate error log.

log_message(format, *args)[source]

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

log_request(code='-', size='-')[source]

Log an accepted request.

This is called by send_response().

on_getErrorInfo(args)[source]
on_getStats(args)[source]
on_stopManager(args)[source]
run_manager = None
server_version = 'stressor/0.5.2 SimpleHTTP/0.6'
class stressor.monitor.server.MonitorServer(run_manager, bind='', port=8081)[source]

Bases: Thread

Run a web server in a separate thread, so it does not block

open_browser()[source]
run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

shutdown()[source]