-
Notifications
You must be signed in to change notification settings - Fork 1
/
scenarios.py
270 lines (243 loc) · 9.24 KB
/
scenarios.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
from .model import ScenariosDict, Scenario, StepDelay, StepRequests, StepRequest
CADDYFILE = """
{
auto_https disable_redirects
}
(server) {
log {
output stdout
level ERROR
}
tls {{ certificates.server_cert }} {{ certificates.server_key }}
reverse_proxy {{ app.hostname }}:{{ app.port }}
encode zstd gzip
header {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff"
# Disallow the site to be rendered within a frame (clickjacking protection)
X-Frame-Options "SAMEORIGIN"
# X-Robots-Tag
X-Robots-Tag "noindex, noarchive, nofollow"
# CSP
Content-Security-Policy "default-src 'none'; style-src 'self' 'unsafe-inline'; form-action 'self'; frame-ancestors 'self'; base-uri 'self'; img-src 'self' data:; font-src 'self'; frame-src 'self'"
# No Cache
Cache-Control "no-cache, no-store"
Pragma "no-cache"
}
}
{% for port in ports %}
https://{{ hostname }}:{{ port }} {
import server
}
{% endfor %}
""" # noqa
SCENARIOS = ScenariosDict()
SCENARIOS += Scenario(
id="external_p6_t5_p6",
name="External requests: Two sequences of searx requests, 0.5s in between",
tries=10,
local_ca=False,
steps=[
StepRequests(
urls=[
"https://fr.wikiversity.org/w/api.php?action=query&list=search&srsearch=linux&format=json&sroffset=0&srlimit=5&srwhat=text", # noqa
"https://fr.wikipedia.org/w/api.php?action=query&format=json&titles=linux%7CLinux&prop=extracts%7Cpageimages%7Cpageprops&ppprop=disambiguation&exintro&explaintext&pithumbsize=300&redirects", # noqa
"https://fr.wikiquote.org/w/api.php?action=query&list=search&srsearch=linux&format=json&sroffset=0&srlimit=5&srwhat=text", # noqa
"https://www.wikidata.org/w/index.php?search=linux&ns0=1",
"https://www.etymonline.com/search?page=1&q=linux",
"https://api.duckduckgo.com/?q=time&format=json&pretty=0&no_redirect=1&d=1",
]
),
StepDelay(time=0.5),
StepRequests(
urls=[
"https://fr.wikiversity.org/w/api.php?action=query&list=search&srsearch=searx&format=json&sroffset=0&srlimit=5&srwhat=text", # noqa
"https://fr.wikipedia.org/w/api.php?action=query&format=json&titles=searx%7CLinux&prop=extracts%7Cpageimages%7Cpageprops&ppprop=disambiguation&exintro&explaintext&pithumbsize=300&redirects", # noqa
"https://fr.wikiquote.org/w/api.php?action=query&list=search&srsearch=searx&format=json&sroffset=0&srlimit=5&srwhat=text", # noqa
"https://www.wikidata.org/w/index.php?search=searx&ns0=1",
"https://www.etymonline.com/search?page=1&q=searx",
"https://api.duckduckgo.com/?q=searx&format=json&pretty=0&no_redirect=1&d=1",
]
),
],
)
SCENARIOS += Scenario(
id="p6-8-5_t5_p6-8-5",
name="Two sequences of 6 requests with a 8KB responses (various delays), 0.5s in between",
tries=10,
local_ca=True,
steps=[
StepRequests(
urls=[
"https://localhost:4001/800/8192",
"https://localhost:4002/900/8192",
"https://localhost:4003/400/8192",
"https://localhost:4004/500/8192",
"https://localhost:4005/600/8192",
"https://localhost:4006/300/8192",
]
),
StepDelay(time=0.5),
StepRequests(
urls=[
"https://localhost:4001/800/8192",
"https://localhost:4002/900/8192",
"https://localhost:4003/600/8192",
"https://localhost:4004/400/8192",
"https://localhost:4005/500/8192",
"https://localhost:4006/400/8192",
]
),
],
)
SCENARIOS += Scenario(
id="p6-400-5_t5_p6-400-5",
name="Two sequences of 6 requests with a 400KB responses (various delays), 0.5s in between",
tries=10,
local_ca=True,
steps=[
StepRequests(
urls=[
"https://localhost:4001/800/400000",
"https://localhost:4002/900/400000",
"https://localhost:4003/400/400000",
"https://localhost:4004/500/400000",
"https://localhost:4005/600/400000",
"https://localhost:4006/300/400000",
]
),
StepDelay(time=0.5),
StepRequests(
urls=[
"https://localhost:4001/800/400000",
"https://localhost:4002/900/400000",
"https://localhost:4003/600/400000",
"https://localhost:4004/400/400000",
"https://localhost:4005/500/400000",
"https://localhost:4006/400/400000",
]
),
],
)
SCENARIOS += Scenario(
id="p100-2-5_t5_p100-2-5",
name="Two sequences of 100 parallel requests (various delays), 0.5s in between",
tries=10,
local_ca=True,
steps=[
StepRequests(
urls=[
"https://localhost:4001/800/2048",
"https://localhost:4002/900/2048",
"https://localhost:4003/400/2048",
"https://localhost:4004/500/2048",
"https://localhost:4005/600/2048",
]
* 20
),
StepDelay(time=0.5),
StepRequests(
urls=[
"https://localhost:4001/800/2048",
"https://localhost:4002/900/2048",
"https://localhost:4003/600/2048",
"https://localhost:4004/400/2048",
"https://localhost:4005/500/2048",
]
* 20
),
],
)
SCENARIOS += Scenario(
id="s100_1_0",
name="100 sequential requests, 1 byte response, 0 delay",
tries=10,
local_ca=True,
steps=[StepRequest(url="https://localhost:4001/0/1")] * 100,
)
SCENARIOS += Scenario(
id="s100_2_0",
name="100 sequential requests, 2KB response, 0 delay",
tries=10,
local_ca=True,
steps=[StepRequest(url="https://localhost:4001/0/2048")] * 100,
)
SCENARIOS += Scenario(
id="s100_256_0",
name="100 sequential requests, 256KB response, 0 delay",
tries=10,
local_ca=True,
steps=[StepRequest(url="https://localhost:4001/0/262144")] * 100,
)
SCENARIOS += Scenario(
id="s100_1024_0",
name="100 sequential requests, 1MB response, 0 delay",
tries=10,
local_ca=True,
steps=[StepRequest(url="https://localhost:4001/0/1048576")] * 100,
)
SCENARIOS += Scenario(
id="s30_8_4",
name="30 sequential requests, 8KB response, 400ms delay",
tries=10,
local_ca=True,
steps=[StepRequest(url="https://localhost:4001/400/8192")] * 30,
)
SCENARIOS += Scenario(
id="s30_8_4",
name="One sequence of 30 requests, 8KB response, 400ms delay",
tries=10,
local_ca=True,
steps=[StepRequests(urls=["https://localhost:4001/400/8192"] * 30), ],
)
ONE_HUNDRED_REQUESTS = [
"https://localhost:4001/800/2048",
"https://localhost:4002/900/1048576",
"https://localhost:4003/600/65000",
"https://localhost:4004/400/8000",
"https://localhost:4005/500/1048576",
"https://localhost:4006/800/2048",
"https://localhost:4007/900/2097152",
"https://localhost:4008/600/4096",
"https://localhost:4009/400/1048576",
"https://localhost:4010/400/1048576",
"https://localhost:4001/800/700000",
"https://localhost:4002/900/1048576",
"https://localhost:4003/600/2048",
"https://localhost:4004/400/2048",
"https://localhost:4005/500/1048576",
"https://localhost:4006/800/2048",
"https://localhost:4007/900/2048",
"https://localhost:4008/600/1048576",
"https://localhost:4009/400/2048",
"https://localhost:4010/800/700000",
] * 5
SCENARIOS += Scenario(
id="p100_2048_5_t20_p100_2048_5",
name="2 sequences of 100 requests, between 2KB and 2MB responses (various delays), 2s in between",
tries=10,
local_ca=True,
steps=[StepRequests(urls=ONE_HUNDRED_REQUESTS), StepDelay(2.0), StepRequests(urls=ONE_HUNDRED_REQUESTS)]
)
SCENARIOS += Scenario(
id="p60_1024_5",
name="60 requests, 1MB response (various delays)",
tries=10,
local_ca=True,
steps=[StepRequests(urls=[
"https://localhost:4001/800/1048576",
"https://localhost:4002/900/1048576",
"https://localhost:4003/600/1048576",
"https://localhost:4004/400/1048576",
"https://localhost:4005/500/1048576",
"https://localhost:4006/800/1048576",
"https://localhost:4007/900/1048576",
"https://localhost:4008/600/1048576",
"https://localhost:4009/400/1048576",
"https://localhost:4010/400/1048576",
] * 6)]
)