@gatling.io/core 3.11.7 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +5 -0
- package/package.json +3 -3
- package/src/assertions.ts +305 -0
- package/src/body.ts +211 -0
- package/src/checks/builder.ts +14 -0
- package/src/checks/captureGroup.ts +22 -0
- package/src/checks/condition.ts +24 -0
- package/src/checks/final.ts +31 -0
- package/src/checks/find.ts +23 -0
- package/src/checks/index.ts +540 -0
- package/src/checks/jsonOfTypeFind.ts +81 -0
- package/src/checks/jsonOfTypeMultipleFind.ts +84 -0
- package/src/checks/multipleFind.ts +87 -0
- package/src/checks/validate.ts +336 -0
- package/src/closedInjection.ts +182 -0
- package/src/common.ts +3 -0
- package/src/feeders.ts +279 -0
- package/src/filters.ts +49 -0
- package/src/gatlingJvm/app.ts +5 -0
- package/src/gatlingJvm/byteArrays.ts +14 -0
- package/src/gatlingJvm/collections.ts +28 -0
- package/src/globalStore.ts +104 -0
- package/src/index.test.ts +543 -0
- package/src/index.ts +158 -0
- package/src/openInjection.ts +286 -0
- package/src/parameters.ts +38 -0
- package/src/population.ts +105 -0
- package/src/protocol.ts +5 -0
- package/src/scenario.ts +37 -0
- package/src/session.ts +182 -0
- package/src/structure/asLongAs.ts +121 -0
- package/src/structure/asLongAsDuring.ts +337 -0
- package/src/structure/choices.ts +41 -0
- package/src/structure/doIf.ts +140 -0
- package/src/structure/doIfOrElse.ts +160 -0
- package/src/structure/doSwitch.ts +46 -0
- package/src/structure/doSwitchOrElse.ts +61 -0
- package/src/structure/doWhile.ts +53 -0
- package/src/structure/doWhileDuring.ts +337 -0
- package/src/structure/during.ts +182 -0
- package/src/structure/errors.ts +266 -0
- package/src/structure/execs.ts +66 -0
- package/src/structure/feeds.ts +62 -0
- package/src/structure/forEach.ts +68 -0
- package/src/structure/forever.ts +25 -0
- package/src/structure/groups.ts +23 -0
- package/src/structure/index.ts +130 -0
- package/src/structure/jvmStructureBuilder.ts +52 -0
- package/src/structure/on.ts +20 -0
- package/src/structure/paces.ts +156 -0
- package/src/structure/pauses.ts +211 -0
- package/src/structure/randomSwitch.ts +34 -0
- package/src/structure/randomSwitchOrElse.ts +45 -0
- package/src/structure/rendezVous.ts +23 -0
- package/src/structure/repeat.ts +64 -0
- package/src/structure/roundRobinSwitch.ts +34 -0
- package/src/structure/uniformRandomSwitch.ts +34 -0
- package/src/throttling.ts +67 -0
- package/src/utils/duration.ts +28 -0
- package/target/structure/errors.d.ts +70 -10
- package/target/structure/errors.js +29 -8
- package/target/structure/index.d.ts +4 -2
- package/target/structure/index.js +5 -3
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ByteArrayBody,
|
|
3
|
+
ElFileBody,
|
|
4
|
+
PebbleFileBody,
|
|
5
|
+
PebbleStringBody,
|
|
6
|
+
RawFileBody,
|
|
7
|
+
Session,
|
|
8
|
+
Simulation,
|
|
9
|
+
StringBody,
|
|
10
|
+
arrayFeeder,
|
|
11
|
+
atOnceUsers,
|
|
12
|
+
constantConcurrentUsers,
|
|
13
|
+
constantUsersPerSec,
|
|
14
|
+
csv,
|
|
15
|
+
details,
|
|
16
|
+
exec,
|
|
17
|
+
forAll,
|
|
18
|
+
global,
|
|
19
|
+
group,
|
|
20
|
+
holdFor,
|
|
21
|
+
incrementConcurrentUsers,
|
|
22
|
+
incrementUsersPerSec,
|
|
23
|
+
jsonFile,
|
|
24
|
+
jsonUrl,
|
|
25
|
+
jumpToRps,
|
|
26
|
+
nothingFor,
|
|
27
|
+
onCase,
|
|
28
|
+
pause,
|
|
29
|
+
percent,
|
|
30
|
+
rampConcurrentUsers,
|
|
31
|
+
rampUsers,
|
|
32
|
+
rampUsersPerSec,
|
|
33
|
+
reachRps,
|
|
34
|
+
repeat,
|
|
35
|
+
scenario,
|
|
36
|
+
separatedValues,
|
|
37
|
+
ssv,
|
|
38
|
+
stressPeakUsers,
|
|
39
|
+
tsv,
|
|
40
|
+
ProtocolBuilder,
|
|
41
|
+
GlobalStore
|
|
42
|
+
} from "./index";
|
|
43
|
+
|
|
44
|
+
const runSimulationMock = (_: Simulation): void => {};
|
|
45
|
+
|
|
46
|
+
// execs
|
|
47
|
+
const chain1 = exec((session: Session) => session);
|
|
48
|
+
const chain2 = exec(chain1, chain1).exec(chain1);
|
|
49
|
+
// pauses
|
|
50
|
+
const pause1 = pause(1);
|
|
51
|
+
// loops
|
|
52
|
+
const loop1 = repeat(1).on(chain1);
|
|
53
|
+
// groups
|
|
54
|
+
const group1 = group("group").on(chain1);
|
|
55
|
+
const group2 = group((session) => "group").on(chain1);
|
|
56
|
+
|
|
57
|
+
// bodies
|
|
58
|
+
const stringBody1 = StringBody("static #{dynamic} static");
|
|
59
|
+
const stringBody2 = StringBody((session) => "body");
|
|
60
|
+
const rawFileBody1 = RawFileBody("path");
|
|
61
|
+
const rawFileBody2 = RawFileBody((session) => "path");
|
|
62
|
+
const elFileBody1 = ElFileBody("path");
|
|
63
|
+
const elFileBody2 = ElFileBody((session) => "path");
|
|
64
|
+
const pebbleStringBody = PebbleStringBody("template string");
|
|
65
|
+
const pebbleFileBody1 = PebbleFileBody("path");
|
|
66
|
+
const pebbleFileBody2 = PebbleFileBody((session) => "path");
|
|
67
|
+
const byteArrayBody1 = ByteArrayBody([1]);
|
|
68
|
+
const byteArrayBody2 = ByteArrayBody((session) => [1]);
|
|
69
|
+
|
|
70
|
+
//const records = csv("foo").readRecords();
|
|
71
|
+
const recordsCount = csv("foo").recordsCount();
|
|
72
|
+
|
|
73
|
+
// global store
|
|
74
|
+
GlobalStore.getOrDefault<number>("key", 0);
|
|
75
|
+
GlobalStore.put<number>("key", 0);
|
|
76
|
+
GlobalStore.get<number>("key");
|
|
77
|
+
GlobalStore.containsKey("key");
|
|
78
|
+
GlobalStore.update<number>("key", (oldValue) => (oldValue === null ? 0 : oldValue + 1));
|
|
79
|
+
GlobalStore.remove<number>("key");
|
|
80
|
+
GlobalStore.clear();
|
|
81
|
+
|
|
82
|
+
// scenario
|
|
83
|
+
const scn = scenario("scenario")
|
|
84
|
+
// execs
|
|
85
|
+
.exec((session) => session)
|
|
86
|
+
.exec(chain1, chain2)
|
|
87
|
+
// groups
|
|
88
|
+
.group("group")
|
|
89
|
+
.on(chain1, chain2)
|
|
90
|
+
.group((session) => "group")
|
|
91
|
+
.on(chain1, chain2)
|
|
92
|
+
// feeds
|
|
93
|
+
.feed(csv("foo"))
|
|
94
|
+
.feed(csv("foo", '"'))
|
|
95
|
+
.feed(ssv("foo"))
|
|
96
|
+
.feed(ssv("foo", '"'))
|
|
97
|
+
.feed(tsv("foo"))
|
|
98
|
+
.feed(tsv("foo", '"'))
|
|
99
|
+
.feed(separatedValues("foo", "|"))
|
|
100
|
+
.feed(separatedValues("foo", "|", '"'))
|
|
101
|
+
.feed(jsonFile("foo"))
|
|
102
|
+
.feed(jsonUrl("foo"))
|
|
103
|
+
//.feed(
|
|
104
|
+
// Stream.iterate(0, i -> i + 1)
|
|
105
|
+
// .limit(10)
|
|
106
|
+
// .map(
|
|
107
|
+
// i -> {
|
|
108
|
+
// Map<String, Object> map = new HashMap<>();
|
|
109
|
+
// map.put("key", i);
|
|
110
|
+
// return map;
|
|
111
|
+
// })
|
|
112
|
+
// .iterator())
|
|
113
|
+
//.feed(
|
|
114
|
+
// () ->
|
|
115
|
+
// Stream.iterate(0, i -> i + 1)
|
|
116
|
+
// .limit(10)
|
|
117
|
+
// .map(
|
|
118
|
+
// i -> {
|
|
119
|
+
// Map<String, Object> map = new HashMap<>();
|
|
120
|
+
// map.put("key", i);
|
|
121
|
+
// return map;
|
|
122
|
+
// })
|
|
123
|
+
// .iterator())
|
|
124
|
+
.feed(arrayFeeder([{ foo: "foo1" }, { foo: "foo2" }]))
|
|
125
|
+
// pauses
|
|
126
|
+
.pause(1)
|
|
127
|
+
.pause({ amount: 100, unit: "milliseconds" })
|
|
128
|
+
.pause("#{pause}")
|
|
129
|
+
.pause((session) => 1)
|
|
130
|
+
.pause((session) => ({ amount: 100, unit: "milliseconds" }))
|
|
131
|
+
.pause(1, 2)
|
|
132
|
+
.pause({ amount: 100, unit: "milliseconds" }, { amount: 200, unit: "milliseconds" })
|
|
133
|
+
.pause("#{min}", "#{max}")
|
|
134
|
+
.pause(
|
|
135
|
+
(session) => 1,
|
|
136
|
+
(session) => 2
|
|
137
|
+
)
|
|
138
|
+
.pause(
|
|
139
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
140
|
+
(session) => ({ amount: 200, unit: "milliseconds" })
|
|
141
|
+
)
|
|
142
|
+
.pause(1, "Constant")
|
|
143
|
+
.pause({ amount: 100, unit: "milliseconds" }, "Constant")
|
|
144
|
+
.pause("#{pause}", "Constant")
|
|
145
|
+
.pause((session) => ({ amount: 100, unit: "milliseconds" }), "Constant")
|
|
146
|
+
.pause(1, 2, "Constant")
|
|
147
|
+
.pause({ amount: 100, unit: "milliseconds" }, { amount: 200, unit: "milliseconds" }, "Constant")
|
|
148
|
+
.pause("#{min}", "#{max}", "Constant")
|
|
149
|
+
.pause(
|
|
150
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
151
|
+
(session) => ({ amount: 200, unit: "milliseconds" }),
|
|
152
|
+
"Constant"
|
|
153
|
+
)
|
|
154
|
+
.pause(1, "Disabled")
|
|
155
|
+
.pause(1, "Exponential")
|
|
156
|
+
.pause(1, { type: "Custom", f: (session) => 1000 })
|
|
157
|
+
.pause(1, { type: "UniformPercentage", plusOrMinus: 30 })
|
|
158
|
+
.pause(1, { type: "UniformDuration", plusOrMinus: { amount: 50, unit: "milliseconds" } })
|
|
159
|
+
.pause(1, { type: "NormalWithPercentageDuration", stdDev: 30 })
|
|
160
|
+
.pause(1, { type: "NormalWithStdDevDuration", stdDev: { amount: 50, unit: "milliseconds" } })
|
|
161
|
+
// pace
|
|
162
|
+
.pace(1)
|
|
163
|
+
.pace(1, "counter")
|
|
164
|
+
.pace({ amount: 100, unit: "milliseconds" })
|
|
165
|
+
.pace({ amount: 100, unit: "milliseconds" }, "counter")
|
|
166
|
+
.pace("#{pace}")
|
|
167
|
+
.pace("#{pace}", "counter")
|
|
168
|
+
.pace((session) => ({ amount: 100, unit: "milliseconds" }))
|
|
169
|
+
.pace((session) => ({ amount: 100, unit: "milliseconds" }), "counter")
|
|
170
|
+
.pace(1, 2)
|
|
171
|
+
.pace(1, 2, "counter")
|
|
172
|
+
.pace({ amount: 100, unit: "milliseconds" }, { amount: 200, unit: "milliseconds" })
|
|
173
|
+
.pace({ amount: 100, unit: "milliseconds" }, { amount: 200, unit: "milliseconds" }, "counter")
|
|
174
|
+
.pace("#{min}", "#{max}", "counter")
|
|
175
|
+
.pace(
|
|
176
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
177
|
+
(session) => ({ amount: 200, unit: "milliseconds" })
|
|
178
|
+
)
|
|
179
|
+
.pace(
|
|
180
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
181
|
+
(session) => ({ amount: 200, unit: "milliseconds" }),
|
|
182
|
+
"counter"
|
|
183
|
+
)
|
|
184
|
+
// rendezVous
|
|
185
|
+
.rendezVous(5)
|
|
186
|
+
// repeat
|
|
187
|
+
.repeat(1)
|
|
188
|
+
.on(chain1, chain2)
|
|
189
|
+
.repeat(1, "counterName")
|
|
190
|
+
.on(chain1, chain2)
|
|
191
|
+
.repeat((session) => 1)
|
|
192
|
+
.on(chain1, chain2)
|
|
193
|
+
.repeat((session) => 1, "counterName")
|
|
194
|
+
.on(chain1, chain2)
|
|
195
|
+
// during
|
|
196
|
+
.during(1)
|
|
197
|
+
.on(chain1, chain2)
|
|
198
|
+
.during(1, "counterName")
|
|
199
|
+
.on(chain1, chain2)
|
|
200
|
+
.during(1, true)
|
|
201
|
+
.on(chain1, chain2)
|
|
202
|
+
.during(1, "counterName", true)
|
|
203
|
+
.on(chain1, chain2)
|
|
204
|
+
.during({ amount: 100, unit: "milliseconds" })
|
|
205
|
+
.on(chain1, chain2)
|
|
206
|
+
.during({ amount: 100, unit: "milliseconds" }, "counterName")
|
|
207
|
+
.on(chain1, chain2)
|
|
208
|
+
.during({ amount: 100, unit: "milliseconds" }, true)
|
|
209
|
+
.on(chain1, chain2)
|
|
210
|
+
.during({ amount: 100, unit: "milliseconds" }, "counterName", true)
|
|
211
|
+
.on(chain1, chain2)
|
|
212
|
+
.during("#{duration}")
|
|
213
|
+
.on(chain1, chain2)
|
|
214
|
+
.during("#{duration}", "counterName")
|
|
215
|
+
.on(chain1, chain2)
|
|
216
|
+
.during("#{duration}", true)
|
|
217
|
+
.on(chain1, chain2)
|
|
218
|
+
.during("#{duration}", "counterName", true)
|
|
219
|
+
.on(chain1, chain2)
|
|
220
|
+
.during((session) => ({ amount: 100, unit: "milliseconds" }))
|
|
221
|
+
.on(chain1, chain2)
|
|
222
|
+
.during((session) => ({ amount: 100, unit: "milliseconds" }), "counterName")
|
|
223
|
+
.on(chain1, chain2)
|
|
224
|
+
.during((session) => ({ amount: 100, unit: "milliseconds" }), true)
|
|
225
|
+
.on(chain1, chain2)
|
|
226
|
+
.during((session) => ({ amount: 100, unit: "milliseconds" }), "counterName", true)
|
|
227
|
+
.on(chain1, chain2)
|
|
228
|
+
// foreach
|
|
229
|
+
.foreach([1], "attributeName")
|
|
230
|
+
.on(chain1, chain2)
|
|
231
|
+
.foreach([1], "attributeName", "counterName")
|
|
232
|
+
.on(chain1, chain2)
|
|
233
|
+
.foreach("#{array}", "attributeName")
|
|
234
|
+
.on(chain1, chain2)
|
|
235
|
+
.foreach("#{array}", "attributeName", "counterName")
|
|
236
|
+
.on(chain1, chain2)
|
|
237
|
+
.foreach((session) => [1], "attributeName")
|
|
238
|
+
.on(chain1, chain2)
|
|
239
|
+
.foreach((session) => [1], "attributeName", "counterName")
|
|
240
|
+
.on(chain1, chain2)
|
|
241
|
+
// forever
|
|
242
|
+
.forever()
|
|
243
|
+
.on(chain1, chain2)
|
|
244
|
+
.forever("counterName")
|
|
245
|
+
.on(chain1, chain2)
|
|
246
|
+
// asLongAs
|
|
247
|
+
.asLongAs("#{condition}")
|
|
248
|
+
.on(chain1, chain2)
|
|
249
|
+
.asLongAs("#{condition}", "counterName")
|
|
250
|
+
.on(chain1, chain2)
|
|
251
|
+
.asLongAs("#{condition}", true)
|
|
252
|
+
.on(chain1, chain2)
|
|
253
|
+
.asLongAs("#{condition}", "counterName", true)
|
|
254
|
+
.on(chain1, chain2)
|
|
255
|
+
.asLongAs((session) => true)
|
|
256
|
+
.on(chain1, chain2)
|
|
257
|
+
.asLongAs((session) => true, "counterName")
|
|
258
|
+
.on(chain1, chain2)
|
|
259
|
+
.asLongAs((session) => true, true)
|
|
260
|
+
.on(chain1, chain2)
|
|
261
|
+
.asLongAs((session) => true, "counterName", true)
|
|
262
|
+
.on(chain1, chain2)
|
|
263
|
+
// doWhile
|
|
264
|
+
.doWhile("#{condition}")
|
|
265
|
+
.on(chain1, chain2)
|
|
266
|
+
.doWhile("#{condition}", "counterName")
|
|
267
|
+
.on(chain1, chain2)
|
|
268
|
+
.doWhile((session) => true)
|
|
269
|
+
.on(chain1, chain2)
|
|
270
|
+
.doWhile((session) => true, "counterName")
|
|
271
|
+
.on(chain1, chain2)
|
|
272
|
+
// asLongAsDuring
|
|
273
|
+
.asLongAsDuring("#{condition}", "#{duration}")
|
|
274
|
+
.on(chain1, chain2)
|
|
275
|
+
.asLongAsDuring("#{condition}", "#{duration}", "counterName")
|
|
276
|
+
.on(chain1, chain2)
|
|
277
|
+
.asLongAsDuring("#{condition}", "#{duration}", true)
|
|
278
|
+
.on(chain1, chain2)
|
|
279
|
+
.asLongAsDuring("#{condition}", "#{duration}", "counterName", true)
|
|
280
|
+
.on(chain1, chain2)
|
|
281
|
+
.asLongAsDuring(
|
|
282
|
+
(session) => true,
|
|
283
|
+
(session) => ({ amount: 100, unit: "milliseconds" })
|
|
284
|
+
)
|
|
285
|
+
.on(chain1, chain2)
|
|
286
|
+
.asLongAsDuring(
|
|
287
|
+
(session) => true,
|
|
288
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
289
|
+
"counterName"
|
|
290
|
+
)
|
|
291
|
+
.on(chain1, chain2)
|
|
292
|
+
.asLongAsDuring(
|
|
293
|
+
(session) => true,
|
|
294
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
295
|
+
true
|
|
296
|
+
)
|
|
297
|
+
.on(chain1, chain2)
|
|
298
|
+
.asLongAsDuring(
|
|
299
|
+
(session) => true,
|
|
300
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
301
|
+
"counterName",
|
|
302
|
+
true
|
|
303
|
+
)
|
|
304
|
+
.on(chain1, chain2)
|
|
305
|
+
.doWhileDuring("#{condition}", "#{duration}")
|
|
306
|
+
.on(chain1, chain2)
|
|
307
|
+
.doWhileDuring("#{condition}", "#{duration}", "counterName")
|
|
308
|
+
.on(chain1, chain2)
|
|
309
|
+
.doWhileDuring("#{condition}", "#{duration}", true)
|
|
310
|
+
.on(chain1, chain2)
|
|
311
|
+
.doWhileDuring("#{condition}", "#{duration}", "counterName", true)
|
|
312
|
+
.on(chain1, chain2)
|
|
313
|
+
.doWhileDuring(
|
|
314
|
+
(session) => true,
|
|
315
|
+
(session) => ({ amount: 100, unit: "milliseconds" })
|
|
316
|
+
)
|
|
317
|
+
.on(chain1, chain2)
|
|
318
|
+
.doWhileDuring(
|
|
319
|
+
(session) => true,
|
|
320
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
321
|
+
"counterName"
|
|
322
|
+
)
|
|
323
|
+
.on(chain1, chain2)
|
|
324
|
+
.doWhileDuring(
|
|
325
|
+
(session) => true,
|
|
326
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
327
|
+
true
|
|
328
|
+
)
|
|
329
|
+
.on(chain1, chain2)
|
|
330
|
+
.doWhileDuring(
|
|
331
|
+
(session) => true,
|
|
332
|
+
(session) => ({ amount: 100, unit: "milliseconds" }),
|
|
333
|
+
"counterName",
|
|
334
|
+
true
|
|
335
|
+
)
|
|
336
|
+
.on(chain1, chain2)
|
|
337
|
+
// doIf
|
|
338
|
+
.doIf("#{condition}")
|
|
339
|
+
.then(chain1, chain2)
|
|
340
|
+
.doIf((session) => true)
|
|
341
|
+
.then(chain1, chain2)
|
|
342
|
+
// doIfOrElse
|
|
343
|
+
.doIfOrElse("#{condition}")
|
|
344
|
+
.then(chain1, chain2)
|
|
345
|
+
.orElse(chain2, chain2)
|
|
346
|
+
.doIfOrElse((session) => true)
|
|
347
|
+
.then(chain1, chain2)
|
|
348
|
+
.orElse(chain2, chain2)
|
|
349
|
+
// doIfEquals
|
|
350
|
+
.doIfEquals("#{actual}", 1)
|
|
351
|
+
.then(chain1, chain2)
|
|
352
|
+
.doIfEquals("#{actual}", "#{expected}")
|
|
353
|
+
.then(chain1, chain2)
|
|
354
|
+
.doIfEquals("#{actual}", (session) => 1)
|
|
355
|
+
.then(chain1, chain2)
|
|
356
|
+
.doIfEquals((session) => "actual", 1)
|
|
357
|
+
.then(chain1, chain2)
|
|
358
|
+
.doIfEquals((session) => "actual", "#{expected}")
|
|
359
|
+
.then(chain1, chain2)
|
|
360
|
+
.doIfEquals(
|
|
361
|
+
(session) => "actual",
|
|
362
|
+
(session) => 1
|
|
363
|
+
)
|
|
364
|
+
.then(chain1, chain2)
|
|
365
|
+
// doIfEqualsOrElse
|
|
366
|
+
.doIfEqualsOrElse("#{actual}", 1)
|
|
367
|
+
.then(chain1, chain2)
|
|
368
|
+
.orElse(chain2, chain2)
|
|
369
|
+
.doIfEqualsOrElse("#{actual}", "#{expected}")
|
|
370
|
+
.then(chain1, chain2)
|
|
371
|
+
.orElse(chain2, chain2)
|
|
372
|
+
.doIfEqualsOrElse("#{actual}", (session) => 1)
|
|
373
|
+
.then(chain1, chain2)
|
|
374
|
+
.orElse(chain2, chain2)
|
|
375
|
+
.doIfEqualsOrElse((session) => "actual", 1)
|
|
376
|
+
.then(chain1, chain2)
|
|
377
|
+
.orElse(chain2, chain2)
|
|
378
|
+
.doIfEqualsOrElse((session) => "actual", "#{expected}")
|
|
379
|
+
.then(chain1, chain2)
|
|
380
|
+
.orElse(chain2, chain2)
|
|
381
|
+
.doIfEqualsOrElse(
|
|
382
|
+
(session) => "actual",
|
|
383
|
+
(session) => 1
|
|
384
|
+
)
|
|
385
|
+
.then(chain1, chain2)
|
|
386
|
+
.orElse(chain2, chain2)
|
|
387
|
+
// doSwitch
|
|
388
|
+
.doSwitch("#{value}")
|
|
389
|
+
.on(onCase("value1").then(chain1), onCase("value2").then(chain2))
|
|
390
|
+
.doSwitch((session) => "value")
|
|
391
|
+
.on(onCase("value1").then(chain1), onCase("value2").then(chain2))
|
|
392
|
+
// doSwitchOrElse
|
|
393
|
+
.doSwitchOrElse("#{value}")
|
|
394
|
+
.on(onCase("value1").then(chain1), onCase("value2").then(chain2))
|
|
395
|
+
.orElse(chain2)
|
|
396
|
+
.doSwitchOrElse((session) => "value")
|
|
397
|
+
.on(onCase("value1").then(chain1), onCase("value2").then(chain2))
|
|
398
|
+
.orElse(chain2)
|
|
399
|
+
// randomSwitch
|
|
400
|
+
.randomSwitch()
|
|
401
|
+
.on(percent(50.0).then(chain1), percent(50.0).then(chain2))
|
|
402
|
+
// randomSwitchOrElse
|
|
403
|
+
.randomSwitchOrElse()
|
|
404
|
+
.on(percent(50.0).then(chain1), percent(50.0).then(chain2))
|
|
405
|
+
.orElse(chain2)
|
|
406
|
+
// uniformRandomSwitch
|
|
407
|
+
.uniformRandomSwitch()
|
|
408
|
+
.on(chain1, chain2)
|
|
409
|
+
// roundRobinSwitch
|
|
410
|
+
.roundRobinSwitch()
|
|
411
|
+
.on(chain1, chain2)
|
|
412
|
+
// exitBlockOnFail
|
|
413
|
+
.exitBlockOnFail()
|
|
414
|
+
.on(chain1)
|
|
415
|
+
// tryMax
|
|
416
|
+
.tryMax(1)
|
|
417
|
+
.on(chain1)
|
|
418
|
+
.tryMax(1, "counterName")
|
|
419
|
+
.on(chain1)
|
|
420
|
+
.tryMax("#{times}")
|
|
421
|
+
.on(chain1)
|
|
422
|
+
.tryMax("#{times}", "counterName")
|
|
423
|
+
.on(chain1)
|
|
424
|
+
.tryMax((session) => 1)
|
|
425
|
+
.on(chain1)
|
|
426
|
+
.tryMax((session) => 1, "counterName")
|
|
427
|
+
.on(chain1)
|
|
428
|
+
// exitHereIf
|
|
429
|
+
.exitHereIf("#{condition}")
|
|
430
|
+
.exitHereIf((session) => true)
|
|
431
|
+
// exitHere
|
|
432
|
+
.exitHere()
|
|
433
|
+
// exitHereIfFailed
|
|
434
|
+
.exitHereIfFailed()
|
|
435
|
+
// stopLoadGenerator
|
|
436
|
+
.stopLoadGenerator("#{message}")
|
|
437
|
+
.stopLoadGenerator((session) => "message")
|
|
438
|
+
// stopLoadGeneratorIf
|
|
439
|
+
.stopLoadGeneratorIf("#{message}", "#{condition}")
|
|
440
|
+
.stopLoadGeneratorIf(
|
|
441
|
+
(session) => "message",
|
|
442
|
+
(session) => true
|
|
443
|
+
)
|
|
444
|
+
.stopLoadGeneratorIf("#{message}", (session) => true)
|
|
445
|
+
.stopLoadGeneratorIf((session) => "message", "#{condition}")
|
|
446
|
+
// crashLoadGenerator
|
|
447
|
+
.crashLoadGenerator("#{message}")
|
|
448
|
+
.crashLoadGenerator((session) => "message")
|
|
449
|
+
// crashLoadGeneratorIf
|
|
450
|
+
.crashLoadGeneratorIf("#{message}", "#{condition}")
|
|
451
|
+
.crashLoadGeneratorIf(
|
|
452
|
+
(session) => "message",
|
|
453
|
+
(session) => true
|
|
454
|
+
)
|
|
455
|
+
.crashLoadGeneratorIf("#{message}", (session) => true)
|
|
456
|
+
.crashLoadGeneratorIf((session) => "message", "#{condition}");
|
|
457
|
+
|
|
458
|
+
//registerPebbleExtensions((io.pebbletemplates.pebble.extension.Extension) null);
|
|
459
|
+
|
|
460
|
+
const injectOpen = scn.injectOpen(
|
|
461
|
+
rampUsers(5).during(1),
|
|
462
|
+
rampUsers(5).during({ amount: 1, unit: "seconds" }),
|
|
463
|
+
stressPeakUsers(5).during(1),
|
|
464
|
+
stressPeakUsers(5).during({ amount: 1, unit: "seconds" }),
|
|
465
|
+
atOnceUsers(1000),
|
|
466
|
+
constantUsersPerSec(10).during(1),
|
|
467
|
+
constantUsersPerSec(10).during({ amount: 1, unit: "seconds" }),
|
|
468
|
+
rampUsersPerSec(100).to(200).during(1),
|
|
469
|
+
rampUsersPerSec(100).to(200).during({ amount: 1, unit: "seconds" }),
|
|
470
|
+
nothingFor(1),
|
|
471
|
+
nothingFor({ amount: 1, unit: "seconds" }),
|
|
472
|
+
incrementUsersPerSec(1.0).times(5).eachLevelLasting(1),
|
|
473
|
+
incrementUsersPerSec(1.0).times(5).eachLevelLasting(1).startingFrom(1.0),
|
|
474
|
+
incrementUsersPerSec(1.0).times(5).eachLevelLasting(1).separatedByRampsLasting(1),
|
|
475
|
+
incrementUsersPerSec(1.0).times(5).eachLevelLasting(1).startingFrom(1.0).separatedByRampsLasting(1),
|
|
476
|
+
incrementUsersPerSec(1.0)
|
|
477
|
+
.times(5)
|
|
478
|
+
.eachLevelLasting({ amount: 1, unit: "seconds" })
|
|
479
|
+
.startingFrom(1.0)
|
|
480
|
+
.separatedByRampsLasting({ amount: 1, unit: "seconds" })
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
const injectClosed = scn.injectClosed(
|
|
484
|
+
constantConcurrentUsers(100).during(1),
|
|
485
|
+
constantConcurrentUsers(100).during({ amount: 1, unit: "seconds" }),
|
|
486
|
+
rampConcurrentUsers(1).to(5).during(1),
|
|
487
|
+
rampConcurrentUsers(1).to(5).during({ amount: 1, unit: "seconds" }),
|
|
488
|
+
incrementConcurrentUsers(1).times(5).eachLevelLasting(1),
|
|
489
|
+
incrementConcurrentUsers(1).times(5).eachLevelLasting(1),
|
|
490
|
+
incrementConcurrentUsers(1).times(5).eachLevelLasting(1).startingFrom(1),
|
|
491
|
+
incrementConcurrentUsers(1).times(5).eachLevelLasting(1).separatedByRampsLasting(1),
|
|
492
|
+
incrementConcurrentUsers(1).times(5).eachLevelLasting(1).startingFrom(1).separatedByRampsLasting(1),
|
|
493
|
+
incrementConcurrentUsers(1)
|
|
494
|
+
.times(5)
|
|
495
|
+
.eachLevelLasting({ amount: 1, unit: "seconds" })
|
|
496
|
+
.startingFrom(1)
|
|
497
|
+
.separatedByRampsLasting({ amount: 1, unit: "seconds" })
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
const protocol: ProtocolBuilder = null;
|
|
501
|
+
|
|
502
|
+
runSimulationMock((setUp) => {
|
|
503
|
+
setUp(
|
|
504
|
+
injectOpen,
|
|
505
|
+
injectClosed
|
|
506
|
+
.protocols(protocol)
|
|
507
|
+
.andThen(scn.injectOpen(atOnceUsers(1)))
|
|
508
|
+
.throttle(reachRps(100).in(1))
|
|
509
|
+
.disablePauses()
|
|
510
|
+
.constantPauses()
|
|
511
|
+
.exponentialPauses()
|
|
512
|
+
.customPauses((session) => 1)
|
|
513
|
+
.uniformPauses(1)
|
|
514
|
+
.uniformPauses({ amount: 1, unit: "seconds" })
|
|
515
|
+
.pauses("Constant")
|
|
516
|
+
.noShard()
|
|
517
|
+
)
|
|
518
|
+
.protocols(protocol)
|
|
519
|
+
.assertions(
|
|
520
|
+
global().allRequests().count().is(5),
|
|
521
|
+
global().allRequests().percent().is(5.5),
|
|
522
|
+
forAll().allRequests().count().is(5),
|
|
523
|
+
details("group", "request").allRequests().count().is(5)
|
|
524
|
+
)
|
|
525
|
+
.maxDuration(1)
|
|
526
|
+
.maxDuration({ amount: 1, unit: "seconds" })
|
|
527
|
+
.throttle(
|
|
528
|
+
reachRps(100).in(1),
|
|
529
|
+
reachRps(100).in({ amount: 1, unit: "seconds" }),
|
|
530
|
+
jumpToRps(100),
|
|
531
|
+
holdFor(1),
|
|
532
|
+
holdFor({ amount: 1, unit: "seconds" })
|
|
533
|
+
)
|
|
534
|
+
.disablePauses()
|
|
535
|
+
.constantPauses()
|
|
536
|
+
.exponentialPauses()
|
|
537
|
+
.customPauses((session) => 1)
|
|
538
|
+
.uniformPauses(1)
|
|
539
|
+
.uniformPauses({ amount: 1, unit: "seconds" })
|
|
540
|
+
.normalPausesWithStdDevDuration({ amount: 50, unit: "milliseconds" })
|
|
541
|
+
.normalPausesWithPercentageDuration(30)
|
|
542
|
+
.pauses("Constant");
|
|
543
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import "@gatling.io/jvm-types";
|
|
2
|
+
import JvmSetUp = io.gatling.javaapi.core.Simulation$SetUp;
|
|
3
|
+
|
|
4
|
+
import * as jvm from "./gatlingJvm/app";
|
|
5
|
+
import { PauseType, toJvmPauseType } from "./structure/pauses";
|
|
6
|
+
import { Duration, toJvmDuration } from "./utils/duration";
|
|
7
|
+
import { SessionTo, underlyingSessionTo } from "./session";
|
|
8
|
+
import { Assertion } from "./assertions";
|
|
9
|
+
import { PopulationBuilder } from "./population";
|
|
10
|
+
import { ProtocolBuilder } from "./protocol";
|
|
11
|
+
import { ThrottleStep } from "./throttling";
|
|
12
|
+
|
|
13
|
+
// FIXME no export *
|
|
14
|
+
export { asByteArray, asByteArrayFunction } from "./gatlingJvm/byteArrays";
|
|
15
|
+
export * from "./utils/duration";
|
|
16
|
+
export * from "./assertions";
|
|
17
|
+
export * from "./body";
|
|
18
|
+
export * from "./checks";
|
|
19
|
+
export * from "./closedInjection";
|
|
20
|
+
export * from "./common";
|
|
21
|
+
export * from "./feeders";
|
|
22
|
+
export * from "./filters";
|
|
23
|
+
export { GlobalStore } from "./globalStore";
|
|
24
|
+
export * from "./openInjection";
|
|
25
|
+
export * from "./population";
|
|
26
|
+
export { getParameter, getOption, getEnvironmentVariable, GetWithDefault } from "./parameters";
|
|
27
|
+
export * from "./protocol";
|
|
28
|
+
export * from "./scenario";
|
|
29
|
+
export * from "./session";
|
|
30
|
+
export * from "./structure";
|
|
31
|
+
export * from "./throttling";
|
|
32
|
+
|
|
33
|
+
export interface SetUp {
|
|
34
|
+
/**
|
|
35
|
+
* Define the desired protocol configurations
|
|
36
|
+
*
|
|
37
|
+
* @param protocols - the protocols
|
|
38
|
+
* @returns the same mutated setup instance
|
|
39
|
+
*/
|
|
40
|
+
protocols(...protocols: ProtocolBuilder[]): SetUp;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Define the desired assertions
|
|
44
|
+
*
|
|
45
|
+
* @param assertions - the assertions
|
|
46
|
+
* @returns the same mutated setup instance
|
|
47
|
+
*/
|
|
48
|
+
assertions(...assertions: Assertion[]): SetUp;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Define the run max duration
|
|
52
|
+
*
|
|
53
|
+
* @param duration - the max duration
|
|
54
|
+
* @returns the same mutated setup instance
|
|
55
|
+
*/
|
|
56
|
+
maxDuration(duration: Duration): SetUp;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Define the throttling, meaning a maximum throughput over time
|
|
60
|
+
*
|
|
61
|
+
* @param throttleSteps - the throttling DSL steps
|
|
62
|
+
* @returns the same mutated setup instance
|
|
63
|
+
*/
|
|
64
|
+
throttle(...throttleSteps: ThrottleStep[]): SetUp;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Disable the pauses
|
|
68
|
+
*
|
|
69
|
+
* @returns the same mutated setup instance
|
|
70
|
+
*/
|
|
71
|
+
disablePauses(): SetUp;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Apply constant pauses
|
|
75
|
+
*
|
|
76
|
+
* @returns the same mutated setup instance
|
|
77
|
+
*/
|
|
78
|
+
constantPauses(): SetUp;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Apply exponential pauses
|
|
82
|
+
*
|
|
83
|
+
* @returns the same mutated setup instance
|
|
84
|
+
*/
|
|
85
|
+
exponentialPauses(): SetUp;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Apply custom pauses
|
|
89
|
+
*
|
|
90
|
+
* @returns the same mutated setup instance
|
|
91
|
+
*/
|
|
92
|
+
customPauses(f: SessionTo<number>): SetUp;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Apply uniform pauses with half-width defined as a percentage
|
|
96
|
+
*
|
|
97
|
+
* @returns the same mutated setup instance
|
|
98
|
+
*/
|
|
99
|
+
uniformPauses(plusOrMinus: number): SetUp;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Apply uniform pauses with half-width defined as an absolute value
|
|
103
|
+
*
|
|
104
|
+
* @returns the same mutated setup instance
|
|
105
|
+
*/
|
|
106
|
+
uniformPauses(plusOrMinus: Duration): SetUp;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Apply normal distribution pauses with the standard deviation defined as an absolute value
|
|
110
|
+
*
|
|
111
|
+
* @param stdDevDuration - the standard deviation of the distribution.
|
|
112
|
+
* @returns the same mutated setup instance
|
|
113
|
+
*/
|
|
114
|
+
normalPausesWithStdDevDuration(stdDevDuration: Duration): SetUp;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Apply normal distribution pauses with the standard deviation defined as a percentage of the
|
|
118
|
+
* value defined in the scenario
|
|
119
|
+
*
|
|
120
|
+
* @param stdDevPercent - the standard deviation of the distribution in percents.
|
|
121
|
+
* @returns the same mutated setup instance
|
|
122
|
+
*/
|
|
123
|
+
normalPausesWithPercentageDuration(stdDevPercent: number): SetUp;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Apply uniform pauses with a given strategy
|
|
127
|
+
*
|
|
128
|
+
* @param pauseType - the pause type
|
|
129
|
+
* @returns the same mutated setup instance
|
|
130
|
+
*/
|
|
131
|
+
pauses(pauseType: PauseType): SetUp;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const wrapSetUp = (jvmSetUp: JvmSetUp): SetUp => ({
|
|
135
|
+
protocols: (...protocols) => wrapSetUp(jvmSetUp.protocols(protocols.map((p) => p._underlying))),
|
|
136
|
+
assertions: (...assertions) => wrapSetUp(jvmSetUp.assertions(assertions.map((p) => p._underlying))),
|
|
137
|
+
maxDuration: (duration) => wrapSetUp(jvmSetUp.maxDuration(toJvmDuration(duration))),
|
|
138
|
+
throttle: (...throttleSteps) => wrapSetUp(jvmSetUp.throttle(throttleSteps.map((t) => t._underlying))),
|
|
139
|
+
disablePauses: () => wrapSetUp(jvmSetUp.disablePauses()),
|
|
140
|
+
constantPauses: () => wrapSetUp(jvmSetUp.constantPauses()),
|
|
141
|
+
exponentialPauses: () => wrapSetUp(jvmSetUp.exponentialPauses()),
|
|
142
|
+
customPauses: (f) => wrapSetUp(jvmSetUp.customPauses(underlyingSessionTo(f))),
|
|
143
|
+
uniformPauses: (plusOrMinus) => wrapSetUp(jvmSetUp.uniformPauses(toJvmDuration(plusOrMinus))),
|
|
144
|
+
normalPausesWithStdDevDuration: (stdDevDuration) =>
|
|
145
|
+
wrapSetUp(jvmSetUp.normalPausesWithStdDevDuration(toJvmDuration(stdDevDuration))),
|
|
146
|
+
normalPausesWithPercentageDuration: (stdDevPercent) =>
|
|
147
|
+
wrapSetUp(jvmSetUp.normalPausesWithPercentageDuration(stdDevPercent)),
|
|
148
|
+
pauses: (pauseType) => wrapSetUp(jvmSetUp.pauses(toJvmPauseType(pauseType)))
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export type SetUpFunction = (...populationBuilders: PopulationBuilder[]) => SetUp;
|
|
152
|
+
export type Simulation = (setUp: SetUpFunction) => void;
|
|
153
|
+
|
|
154
|
+
export const simulation =
|
|
155
|
+
(simulation: Simulation): jvm.Simulation =>
|
|
156
|
+
(jvmSetUp) => {
|
|
157
|
+
simulation((...populationBuilders) => wrapSetUp(jvmSetUp(populationBuilders.map((p) => p._underlying))));
|
|
158
|
+
};
|