stressor.yaml¶
Scenarios are defined in YAML-formatted configuration files. It can then be executed like so:
$ stressor run SCENARIO.yaml --monitor
Annotated Sample Configuration¶
1# ----------------------------------------------------------------------------
2# Stressor Scenario Definition
3# See
4# - https://stressor.readthedocs.io/
5# - https://stressor.readthedocs.io/en/latest/ug_reference.html
6# ----------------------------------------------------------------------------
7
8# File identifier, must be 'stressor#0'
9file_version: stressor#0
10
11# ----------------------------------------------------------------------------
12#: `config`: Global scenario settings.
13config:
14 #: Scenario name (defaults to name of this file without '.yaml' extension)
15 name: Test WebDAV
16
17 #: Optional multi-line string with additional info
18 details: |
19 This scenario runs some tests against a WebDAV server.
20 We use it to test stressor against a locally running WsgiDAV server:
21 - Open a terminal and run
22 $ wsgidav --root tests/fixtures/ --port 8082 --auth anonymous
23 - Open a second terminal and run
24 $ stressor run tests/fixtures/test_mock_server
25
26 # Optional string that describes the current run.
27 # May be used to display additional info about boundary conditions, etc.
28 # Example 'Test-Run STAGING nightly'
29 # (pass `-o "tag:MY TAG INFO"` to override)
30 tag:
31
32 #: (int) Output verbosity level [0..5], default: 3
33 verbose: 3
34 #: (str)
35 base_url: http://127.0.0.1:8082
36 #: (float) Default timeout on seconds for web requests (i.e. HTTP activities)
37 #: This value can be overridden with HTTP-Activity's `timeout` parameter
38 request_timeout: 1.0
39 #: (int) Max. total error count that is tolerated before stopping
40 #: Override with `--max-errors` argument.
41 #: Default: 0: don't stop on errors
42 max_errors: 0
43 #: (float) Max. run time in seconds before stopping (override with `--max-time`)
44 #: Default: 0.0: no time limit
45 max_time: 0.0
46
47# ----------------------------------------------------------------------------
48# `context`: Initial context value definitions.
49# Context values can be accessed using `$(NAME)` macros, e.g. `$(base_url)`.
50# The context is initialized with all values from the `config` section,
51# but we can add or override values here.
52# Values may also be defined or overridden using the the command line, e.g.
53# `--option "NAME:VALUE"`
54context:
55
56# ----------------------------------------------------------------------------
57# `sessions`: The run configuration defines how the `sequences` are executed
58# in parallel sessions.
59sessions:
60 #: (list) Defines a list of user dicts, with at least `name` and `pasword`
61 #: attributes. Often stored in a separate file and included like so:
62 users: $load(users.yaml)
63 #: (int) Number of sessions (virtual users). If greater than no. of users,
64 #: users will be re-used round robin.
65 #: Default: 1
66 count: 1
67 #: (float) max. run time in seconds, before the session stops. The current
68 #: and the 'end' sequences are completed.
69 #: Default: 0.0 means no time limit.
70 duration: 0.0
71 #: (bool) Pass true to enable HTTP basic authentication, using user's credentials
72 #: Default: false
73 basic_auth: false
74 #: (bool) Pass false to ignore SSL certificate errors. Default: true
75 verify_ssl: true
76 #: (float) Waiting time between starting distinct user sessions in seconds.
77 #: Default: 0.0 means start all session at once.
78 ramp_up_delay: 0.0
79
80# ----------------------------------------------------------------------------
81# `scenario`: Define the order and duration of sequences that every virtual
82# user session performs.
83# All sequence definitions that are referenced here, must also appear in the
84# following `sequences` section.
85scenario:
86 # 'init' is the reserved name for the set-up sequence, like logging-in.
87 # If errors occur here, all subsequent sequences (including 'end') are skipped.
88 - sequence: init
89 # Other sections can have arbitrary names and are excuted in order of appearance
90 - sequence: main
91 #: (float) This sequence is repeated in a loop, until `duration` seconds are
92 #: reached (always completing the full sequence).
93 #: Default: 0.0 means no time-based looping.
94 duration: 0.0
95 #: (int) This sequence is repeated in a loop, until `duration` seconds are
96 #: reached (always completing the full sequence).
97 #: Default: 0 (or 1) means no repeat.
98 repeat: 0
99 # 'end' is the reserved name for the tear-down sequence (e..g. log out).
100 # If errors occurred in the mainhere, all subsequent sequences are skipped.
101 - sequence: end
102
103# ----------------------------------------------------------------------------
104# `sequences`: List of named action sequences. Used as building blocks for
105# scenarios
106# Following some example activites. Please refer to the docs for details.
107sequences:
108 # 'init' is the reserved name for the set-up sequence.
109 init:
110 # Log-in
111 - activity: HTTPRequest
112 url: /
113 method: OPTIONS
114 assert_match_headers: ".*'DAV'.*"
115
116 - activity: GetRequest
117 # Use `base_url` by default:
118 url: mock_login_response.json
119 assert_json:
120 result.user_guid: "{abc123}"
121 store_json:
122 user_guid: "result.user_guid"
123
124 # - activity: $debug()
125
126 # Other sections can have arbitrary names and are excuted in order of appearance
127 main:
128 - activity: GetRequest
129 url: /
130 assert_match: ".*Index of /.*"
131 assert_html:
132 "//*[@class='logo']": true
133
134 # - activity: $debug()
135
136 - activity: PutRequest
137 url: /wsgidav_test_file~$(session_id).txt
138 data: "Test"
139 assert_max_time: 0.5
140 # debug: true
141 monitor: true
142
143 - activity: RunScript
144 script: |
145 new_val = "New URL:" + base_url
146
147 - activity: RunScript
148 name: "Print context"
149 script: |
150 from pprint import pprint
151 pprint(locals())
152
153 - activity: $sleep(0.3)
154
155 - activity: GetRequest
156 url: /wsgidav_test_file~$(session_id).txt
157 assert_match: "Test"
158
159 - activity: $sleep(0.3)
160
161 # - activity: $debug()
162
163 # - activity: RunScript
164 # path: script_1.py
165
166 # - activity: RunScript
167 # script: |
168 # temp = Fabulist.quote("${verb}")
169 # PutRequest(url="hurz")
170
171 # 'end' is the reserved name for the tear-down sequence
172 end:
173 - activity: $sleep(0.1)
174
175 - activity: DeleteRequest
176 url: /wsgidav_test_file~$(session_id).txt