@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.
Files changed (64) hide show
  1. package/jest.config.js +5 -0
  2. package/package.json +3 -3
  3. package/src/assertions.ts +305 -0
  4. package/src/body.ts +211 -0
  5. package/src/checks/builder.ts +14 -0
  6. package/src/checks/captureGroup.ts +22 -0
  7. package/src/checks/condition.ts +24 -0
  8. package/src/checks/final.ts +31 -0
  9. package/src/checks/find.ts +23 -0
  10. package/src/checks/index.ts +540 -0
  11. package/src/checks/jsonOfTypeFind.ts +81 -0
  12. package/src/checks/jsonOfTypeMultipleFind.ts +84 -0
  13. package/src/checks/multipleFind.ts +87 -0
  14. package/src/checks/validate.ts +336 -0
  15. package/src/closedInjection.ts +182 -0
  16. package/src/common.ts +3 -0
  17. package/src/feeders.ts +279 -0
  18. package/src/filters.ts +49 -0
  19. package/src/gatlingJvm/app.ts +5 -0
  20. package/src/gatlingJvm/byteArrays.ts +14 -0
  21. package/src/gatlingJvm/collections.ts +28 -0
  22. package/src/globalStore.ts +104 -0
  23. package/src/index.test.ts +543 -0
  24. package/src/index.ts +158 -0
  25. package/src/openInjection.ts +286 -0
  26. package/src/parameters.ts +38 -0
  27. package/src/population.ts +105 -0
  28. package/src/protocol.ts +5 -0
  29. package/src/scenario.ts +37 -0
  30. package/src/session.ts +182 -0
  31. package/src/structure/asLongAs.ts +121 -0
  32. package/src/structure/asLongAsDuring.ts +337 -0
  33. package/src/structure/choices.ts +41 -0
  34. package/src/structure/doIf.ts +140 -0
  35. package/src/structure/doIfOrElse.ts +160 -0
  36. package/src/structure/doSwitch.ts +46 -0
  37. package/src/structure/doSwitchOrElse.ts +61 -0
  38. package/src/structure/doWhile.ts +53 -0
  39. package/src/structure/doWhileDuring.ts +337 -0
  40. package/src/structure/during.ts +182 -0
  41. package/src/structure/errors.ts +266 -0
  42. package/src/structure/execs.ts +66 -0
  43. package/src/structure/feeds.ts +62 -0
  44. package/src/structure/forEach.ts +68 -0
  45. package/src/structure/forever.ts +25 -0
  46. package/src/structure/groups.ts +23 -0
  47. package/src/structure/index.ts +130 -0
  48. package/src/structure/jvmStructureBuilder.ts +52 -0
  49. package/src/structure/on.ts +20 -0
  50. package/src/structure/paces.ts +156 -0
  51. package/src/structure/pauses.ts +211 -0
  52. package/src/structure/randomSwitch.ts +34 -0
  53. package/src/structure/randomSwitchOrElse.ts +45 -0
  54. package/src/structure/rendezVous.ts +23 -0
  55. package/src/structure/repeat.ts +64 -0
  56. package/src/structure/roundRobinSwitch.ts +34 -0
  57. package/src/structure/uniformRandomSwitch.ts +34 -0
  58. package/src/throttling.ts +67 -0
  59. package/src/utils/duration.ts +28 -0
  60. package/target/structure/errors.d.ts +70 -10
  61. package/target/structure/errors.js +29 -8
  62. package/target/structure/index.d.ts +4 -2
  63. package/target/structure/index.js +5 -3
  64. package/tsconfig.json +18 -0
@@ -0,0 +1,182 @@
1
+ import { Duration, isDuration, toJvmDuration } from "../utils/duration";
2
+ import { SessionTo, underlyingSessionToDuration } from "../session";
3
+ import { On, wrapOn } from "./on";
4
+
5
+ import JvmDuring = io.gatling.javaapi.core.loop.During;
6
+
7
+ export interface DuringFunction<T extends During<T>> {
8
+ /**
9
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
10
+ * the loop.
11
+ *
12
+ * @param duration - the maximum duration, in seconds or with an explicit time unit
13
+ * @returns a DSL component for defining the loop content
14
+ */
15
+ (duration: Duration): On<T>;
16
+
17
+ /**
18
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
19
+ * the loop.
20
+ *
21
+ * @param duration - the maximum duration, in seconds or with an explicit time unit
22
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
23
+ * @returns a DSL component for defining the loop content
24
+ */
25
+ (duration: Duration, exitASAP: boolean): On<T>;
26
+
27
+ /**
28
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
29
+ * the loop.
30
+ *
31
+ * @param duration - the maximum duration, in seconds or with an explicit time unit
32
+ * @param counterName - the name of the loop counter, as stored in the Session
33
+ * @returns a DSL component for defining the loop content
34
+ */
35
+ (duration: Duration, counterName: string): On<T>;
36
+
37
+ /**
38
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
39
+ * the loop.
40
+ *
41
+ * @param duration - the maximum duration, in seconds or with an explicit time unit
42
+ * @param counterName - the name of the loop counter, as stored in the Session
43
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
44
+ * @returns a DSL component for defining the loop content
45
+ */
46
+ (duration: Duration, counterName: string, exitASAP: boolean): On<T>;
47
+
48
+ /**
49
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
50
+ * the loop.
51
+ *
52
+ * @param duration - the maximum duration as a Gatling Expression Language string. This expression must resolve to
53
+ * either a number, then the unit will be seconds, or an object with an explicit time unit.
54
+ * @returns a DSL component for defining the loop content
55
+ */
56
+ (duration: string): On<T>;
57
+
58
+ /**
59
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
60
+ * the loop.
61
+ *
62
+ * @param duration - the maximum duration as a Gatling Expression Language string. This expression must resolve to
63
+ * either a number, then the unit will be seconds, or an object with an explicit time unit.
64
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
65
+ * @returns a DSL component for defining the loop content
66
+ */
67
+ (duration: string, exitASAP: boolean): On<T>;
68
+
69
+ /**
70
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
71
+ * the loop.
72
+ *
73
+ * @param duration - the maximum duration as a Gatling Expression Language string. This expression must resolve to
74
+ * either a number, then the unit will be seconds, or an object with an explicit time unit.
75
+ * @param counterName - the name of the loop counter, as stored in the Session
76
+ * @returns a DSL component for defining the loop content
77
+ */
78
+ (duration: string, counterName: string): On<T>;
79
+
80
+ /**
81
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
82
+ * the loop.
83
+ *
84
+ * @param duration - the maximum duration as a Gatling Expression Language string. This expression must resolve to
85
+ * either a number, then the unit will be seconds, or an object with an explicit time unit.
86
+ * @param counterName - the name of the loop counter, as stored in the Session
87
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
88
+ * @returns a DSL component for defining the loop content
89
+ */
90
+ (duration: string, counterName: string, exitASAP: boolean): On<T>;
91
+
92
+ /**
93
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
94
+ * the loop.
95
+ *
96
+ * @param duration - the maximum duration as a function
97
+ * @returns a DSL component for defining the loop content
98
+ */
99
+ (duration: SessionTo<Duration>): On<T>;
100
+
101
+ /**
102
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
103
+ * the loop.
104
+ *
105
+ * @param duration - the maximum duration as a function
106
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
107
+ * @returns a DSL component for defining the loop content
108
+ */
109
+ (duration: SessionTo<Duration>, exitASAP: boolean): On<T>;
110
+
111
+ /**
112
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
113
+ * the loop.
114
+ *
115
+ * @param duration - the maximum duration as a function
116
+ * @param counterName - the name of the loop counter, as stored in the Session
117
+ * @returns a DSL component for defining the loop content
118
+ */
119
+ (duration: SessionTo<Duration>, counterName: string): On<T>;
120
+
121
+ /**
122
+ * Define a loop that will iterate for a given duration. The condition is evaluated at the end of
123
+ * the loop.
124
+ *
125
+ * @param duration - the maximum duration as a function
126
+ * @param counterName - the name of the loop counter, as stored in the Session
127
+ * @param exitASAP - if the loop must be interrupted if the max duration is reached inside the loop
128
+ * @returns a DSL component for defining the loop content
129
+ */
130
+ (duration: SessionTo<Duration>, counterName: string, exitASAP: boolean): On<T>;
131
+ }
132
+
133
+ export interface During<T extends During<T>> {
134
+ during: DuringFunction<T>;
135
+ }
136
+
137
+ export const duringImpl =
138
+ <J2, J1 extends JvmDuring<J2, any>, T extends During<T>>(
139
+ jvmDuring: J1,
140
+ wrap: (wrapped: J2) => T
141
+ ): DuringFunction<T> =>
142
+ (duration: Duration | SessionTo<Duration> | string, arg1?: boolean | string, arg2?: boolean) => {
143
+ if (arg2 !== undefined && typeof arg1 === "string") {
144
+ // during(duration, counterName, exitASAP)
145
+ if (isDuration(duration)) {
146
+ return wrapOn(jvmDuring.during(toJvmDuration(duration), arg1, arg2), wrap);
147
+ } else if (typeof duration === "function") {
148
+ return wrapOn(jvmDuring.during(underlyingSessionToDuration(duration), arg1, arg2), wrap);
149
+ } else {
150
+ return wrapOn(jvmDuring.during(duration, arg1, arg2), wrap);
151
+ }
152
+ } else if (typeof arg1 === "string") {
153
+ // during(duration, counterName)
154
+ if (isDuration(duration)) {
155
+ return wrapOn(jvmDuring.during(toJvmDuration(duration), arg1), wrap);
156
+ } else if (typeof duration === "function") {
157
+ return wrapOn(jvmDuring.during(underlyingSessionToDuration(duration), arg1), wrap);
158
+ } else {
159
+ return wrapOn(jvmDuring.during(duration, arg1), wrap);
160
+ }
161
+ } else if (typeof arg1 === "boolean") {
162
+ // during(duration, exitASAP)
163
+ if (isDuration(duration)) {
164
+ return wrapOn(jvmDuring.during(toJvmDuration(duration), arg1), wrap);
165
+ } else if (typeof duration === "function") {
166
+ return wrapOn(jvmDuring.during(underlyingSessionToDuration(duration), arg1), wrap);
167
+ } else {
168
+ return wrapOn(jvmDuring.during(duration, arg1), wrap);
169
+ }
170
+ } else if (arg1 === undefined) {
171
+ // during(duration)
172
+ if (isDuration(duration)) {
173
+ return wrapOn(jvmDuring.during(toJvmDuration(duration)), wrap);
174
+ } else if (typeof duration === "function") {
175
+ return wrapOn(jvmDuring.during(underlyingSessionToDuration(duration)), wrap);
176
+ } else {
177
+ return wrapOn(jvmDuring.during(duration), wrap);
178
+ }
179
+ }
180
+
181
+ throw Error(`during() called with invalid arguments ${duration}, ${arg1}, ${arg2}`);
182
+ };
@@ -0,0 +1,266 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { On, wrapOn } from "./on";
3
+
4
+ import JvmErrors = io.gatling.javaapi.core.error.Errors;
5
+
6
+ export interface ExitBlockOnFailFunction<T extends Errors<T>> {
7
+ /**
8
+ * Define a block that is interrupted for a given virtual user if it experiences a failure.
9
+ *
10
+ * @returns a DSL component for defining the tried block
11
+ */
12
+ (): On<T>;
13
+ }
14
+
15
+ export interface TryMaxFunction<T extends Errors<T>> {
16
+ /**
17
+ * Define a block that is interrupted and retried for a given virtual user if it experiences a failure.
18
+ *
19
+ * @param times - the maximum number of tries, including the first one (hence number of retries + 1)
20
+ * @returns a DSL component for defining the tried block
21
+ */
22
+ (times: number | string | SessionTo<number>): On<T>;
23
+
24
+ /**
25
+ * Define a block that is interrupted and retried for a given virtual user if it experiences a failure.
26
+ *
27
+ * @param times - the maximum number of tries, including the first one (hence number of retries + 1)
28
+ * @param counterName - the name of the loop counter, as stored in the Session
29
+ * @returns a DSL component for defining the tried block
30
+ */
31
+ (times: number | string | SessionTo<number>, counterName: string): On<T>;
32
+ }
33
+
34
+ export interface ExitHereIfFunction<T extends Errors<T>> {
35
+ /**
36
+ * Have the virtual user exit here if the condition holds true
37
+ *
38
+ * @param condition - the condition, expressed as a Gatling Expression Language String
39
+ * @returns a new StructureBuilder
40
+ */
41
+ (condition: string): T;
42
+
43
+ /**
44
+ * Have the virtual user exit here if the condition holds true
45
+ *
46
+ * @param condition - the condition, expressed as a function
47
+ * @returns a new StructureBuilder
48
+ */
49
+ (condition: SessionTo<boolean>): T;
50
+ }
51
+
52
+ export interface ExitHereFunction<T extends Errors<T>> {
53
+ /**
54
+ * Have the virtual user exit here
55
+ *
56
+ * @returns a new StructureBuilder
57
+ */
58
+ (): T;
59
+ }
60
+
61
+ export interface ExitHereIfFailedFunction<T extends Errors<T>> {
62
+ /**
63
+ * Have the virtual user exit here if the state of its Session is failed
64
+ *
65
+ * @returns a new StructureBuilder
66
+ */
67
+ (): T;
68
+ }
69
+
70
+ export interface StopLoadGeneratorFunction<T extends Errors<T>> {
71
+ /**
72
+ * Have the virtual user abruptly stop the load generator with a successful status
73
+ *
74
+ * @param message - the message, expressed as a Gatling Expression Language String
75
+ * @returns a new StructureBuilder
76
+ */
77
+ (message: string): T;
78
+
79
+ /**
80
+ * Have the virtual user abruptly stop the load generator with a successful status
81
+ *
82
+ * @param message - the message, expressed as a function
83
+ * @returns a new StructureBuilder
84
+ */
85
+ (message: SessionTo<string>): T;
86
+ }
87
+
88
+ export interface StopLoadGeneratorIfFunction<T extends Errors<T>> {
89
+ /**
90
+ * Have the virtual user abruptly stop the load generator with a successful status if a condition
91
+ * is met
92
+ *
93
+ * @param message - the message, expressed as a Gatling Expression Language String
94
+ * @param condition - the condition, expressed as a Gatling Expression Language String
95
+ * @returns a new StructureBuilder
96
+ */
97
+ (message: string, condition: string): T;
98
+
99
+ /**
100
+ * Have the virtual user abruptly stop the load generator with a successful status if a condition
101
+ * is met
102
+ *
103
+ * @param message - the message, expressed as a Gatling Expression Language String
104
+ * @param condition - the condition, expressed as a function
105
+ * @returns a new StructureBuilder
106
+ */
107
+ (message: string, condition: SessionTo<boolean>): T;
108
+
109
+ /**
110
+ * Have the virtual user abruptly stop the load generator with a successful status if a condition
111
+ * is met
112
+ *
113
+ * @param message - the message, expressed as a function
114
+ * @param condition - the condition, expressed as a Gatling Expression Language String
115
+ * @returns a new StructureBuilder
116
+ */
117
+ (message: SessionTo<string>, condition: string): T;
118
+
119
+ /**
120
+ * Have the virtual user abruptly stop the load generator with a successful status if a condition
121
+ * is met
122
+ *
123
+ * @param message - the message, expressed as a function
124
+ * @param condition - the condition, expressed as a function
125
+ * @returns a new StructureBuilder
126
+ */
127
+ (message: SessionTo<string>, condition: SessionTo<boolean>): T;
128
+ }
129
+
130
+ export interface CrashLoadGeneratorFunction<T extends Errors<T>> {
131
+ /**
132
+ * Have the virtual user abruptly stop the load generator with a failed status
133
+ *
134
+ * @param message - the message, expressed as a Gatling Expression Language String
135
+ * @returns a new StructureBuilder
136
+ */
137
+ (message: string): T;
138
+
139
+ /**
140
+ * Have the virtual user abruptly crash the load generator with a failed status
141
+ *
142
+ * @param message - the message, expressed as a function
143
+ * @returns a new StructureBuilder
144
+ */
145
+ (message: SessionTo<string>): T;
146
+ }
147
+
148
+ export interface CrashLoadGeneratorIfFunction<T extends Errors<T>> {
149
+ /**
150
+ * Have the virtual user abruptly crash the load generator with a failed status if a condition is
151
+ * met
152
+ *
153
+ * @param message - the message, expressed as a Gatling Expression Language String
154
+ * @param condition - the condition, expressed as a Gatling Expression Language String
155
+ * @returns a new StructureBuilder
156
+ */
157
+ (message: string, condition: string): T;
158
+
159
+ /**
160
+ * Have the virtual user abruptly crash the load generator with a failed status if a condition is
161
+ * met
162
+ *
163
+ * @param message - the message, expressed as a Gatling Expression Language String
164
+ * @param condition - the condition, expressed as a function
165
+ * @returns a new StructureBuilder
166
+ */
167
+ (message: string, condition: SessionTo<boolean>): T;
168
+
169
+ /**
170
+ * Have the virtual user abruptly crash the load generator with a failed status if a condition is
171
+ * met
172
+ *
173
+ * @param message - the message, expressed as a function
174
+ * @param condition - the condition, expressed as a Gatling Expression Language String
175
+ * @returns a new StructureBuilder
176
+ */
177
+ (message: SessionTo<string>, condition: string): T;
178
+
179
+ /**
180
+ * Have the virtual user abruptly crash the load generator with a failed status if a condition is
181
+ * met
182
+ *
183
+ * @param message - the message, expressed as a function
184
+ * @param condition - the condition, expressed as a function
185
+ * @returns a new StructureBuilder
186
+ */
187
+ (message: SessionTo<string>, condition: SessionTo<boolean>): T;
188
+ }
189
+
190
+ export interface Errors<T extends Errors<T>> {
191
+ exitBlockOnFail: ExitBlockOnFailFunction<T>;
192
+ tryMax: TryMaxFunction<T>;
193
+ exitHereIf: ExitHereIfFunction<T>;
194
+ exitHere: ExitHereFunction<T>;
195
+ exitHereIfFailed: ExitHereIfFailedFunction<T>;
196
+ stopLoadGenerator: StopLoadGeneratorFunction<T>;
197
+ stopLoadGeneratorIf: StopLoadGeneratorIfFunction<T>;
198
+ crashLoadGenerator: CrashLoadGeneratorFunction<T>;
199
+ crashLoadGeneratorIf: CrashLoadGeneratorIfFunction<T>;
200
+ }
201
+
202
+ export const errorsImpl = <J2, J1 extends JvmErrors<J2, any>, T extends Errors<T>>(
203
+ jvmErrors: J1,
204
+ wrap: (wrapped: J2) => T
205
+ ): Errors<T> => ({
206
+ exitBlockOnFail: (): On<T> => wrapOn(jvmErrors.exitBlockOnFail(), wrap),
207
+ tryMax: (times: string | number | SessionTo<number>): On<T> =>
208
+ wrapOn(
209
+ typeof times === "function"
210
+ ? jvmErrors.tryMax(underlyingSessionTo(times))
211
+ : typeof times === "string"
212
+ ? jvmErrors.tryMax(times)
213
+ : jvmErrors.tryMax(times),
214
+ wrap
215
+ ),
216
+ exitHereIf: (condition: string | SessionTo<boolean>): T =>
217
+ wrap(
218
+ typeof condition === "function"
219
+ ? jvmErrors.exitHereIf(underlyingSessionTo(condition))
220
+ : jvmErrors.exitHereIf(condition)
221
+ ),
222
+ exitHere: (): T => wrap(jvmErrors.exitHere()),
223
+ exitHereIfFailed: (): T => wrap(jvmErrors.exitHereIfFailed()),
224
+ stopLoadGenerator: (message: string | SessionTo<string>): T =>
225
+ wrap(
226
+ typeof message === "function"
227
+ ? jvmErrors.stopLoadGenerator(underlyingSessionTo(message))
228
+ : jvmErrors.stopLoadGenerator(message)
229
+ ),
230
+ stopLoadGeneratorIf: (message: string | SessionTo<string>, condition: string | SessionTo<boolean>): T => {
231
+ if (typeof message === "function") {
232
+ if (typeof condition === "function") {
233
+ return wrap(jvmErrors.stopLoadGeneratorIf(underlyingSessionTo(message), underlyingSessionTo(condition)));
234
+ } else {
235
+ return wrap(jvmErrors.stopLoadGeneratorIf(underlyingSessionTo(message), condition));
236
+ }
237
+ } else {
238
+ if (typeof condition === "function") {
239
+ return wrap(jvmErrors.stopLoadGeneratorIf(message, underlyingSessionTo(condition)));
240
+ } else {
241
+ return wrap(jvmErrors.stopLoadGeneratorIf(message, condition));
242
+ }
243
+ }
244
+ },
245
+ crashLoadGenerator: (message: string | SessionTo<string>): T =>
246
+ wrap(
247
+ typeof message === "function"
248
+ ? jvmErrors.crashLoadGenerator(underlyingSessionTo(message))
249
+ : jvmErrors.crashLoadGenerator(message)
250
+ ),
251
+ crashLoadGeneratorIf: (message: string | SessionTo<string>, condition: string | SessionTo<boolean>): T => {
252
+ if (typeof message === "function") {
253
+ if (typeof condition === "function") {
254
+ return wrap(jvmErrors.crashLoadGeneratorIf(underlyingSessionTo(message), underlyingSessionTo(condition)));
255
+ } else {
256
+ return wrap(jvmErrors.crashLoadGeneratorIf(underlyingSessionTo(message), condition));
257
+ }
258
+ } else {
259
+ if (typeof condition === "function") {
260
+ return wrap(jvmErrors.crashLoadGeneratorIf(message, underlyingSessionTo(condition)));
261
+ } else {
262
+ return wrap(jvmErrors.crashLoadGeneratorIf(message, condition));
263
+ }
264
+ }
265
+ }
266
+ });
@@ -0,0 +1,66 @@
1
+ import { Wrapper } from "../common";
2
+ import { SessionTransform, underlyingSessionTransform } from "../session";
3
+
4
+ import JvmActionBuilder = io.gatling.javaapi.core.ActionBuilder;
5
+ import JvmExecs = io.gatling.javaapi.core.exec.Execs;
6
+ import JvmExecutable = io.gatling.javaapi.core.exec.Executable;
7
+
8
+ export interface Executable<T extends JvmExecutable> extends Wrapper<T> {}
9
+
10
+ export interface ActionBuilder extends Executable<JvmActionBuilder> {}
11
+
12
+ export const wrapActionBuilder = (_underlying: JvmActionBuilder): ActionBuilder => ({
13
+ _underlying
14
+ });
15
+
16
+ // interface JvmExecs {
17
+ // exec<T>(arg0: JvmExecutable, ...arg1: JvmExecutable[]): T;
18
+ // exec<T>(arg0: JvmChainBuilder[]): T;
19
+ // exec<T>(arg0: Func<JvmSession, JvmSession>): T;
20
+ // }
21
+
22
+ export interface ExecFunction<T extends Execs<T>> {
23
+ /**
24
+ * Attach some `Executable`s. Chains will be attached sequentially.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const chain1: ChainBuilder = ???
29
+ * const chain2: ChainBuilder = ???
30
+ * const chain1ThenChain2 = exec(chain1, chain2)
31
+ * ```
32
+ *
33
+ * @param executable - some `ChainBuilder` or `ActionBuilder`
34
+ * @param executables - other `ChainBuilder`s or `ActionBuilder`s
35
+ * @returns a new `StructureBuilder`
36
+ */
37
+ (executable: Executable<any>, ...executables: Array<Executable<any>>): T;
38
+
39
+ /**
40
+ * Attach a new action that will execute a function. Important: the function must only perform
41
+ * fast in-memory operations. In particular, it mustn't perform any long block I/O operation, or
42
+ * it will hurt Gatling performance badly.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * exec(session => session.set("foo", "bar"))
47
+ * ```
48
+ *
49
+ * @param executable - the function
50
+ * @returns a new `StructureBuilder`
51
+ */
52
+ (executable: SessionTransform): T;
53
+ }
54
+
55
+ export interface Execs<T extends Execs<T>> {
56
+ exec: ExecFunction<T>;
57
+ }
58
+
59
+ export const execImpl =
60
+ <J2, J1 extends JvmExecs<J2, any>, T extends Execs<T>>(jvmExecs: J1, wrap: (wrapped: J2) => T): ExecFunction<T> =>
61
+ (arg0: Executable<any> | SessionTransform, ...arg1: Array<Executable<any>>) =>
62
+ wrap(
63
+ typeof arg0 === "function"
64
+ ? jvmExecs.exec(underlyingSessionTransform(arg0)) // arg0: SessionTransform
65
+ : jvmExecs.exec(arg0._underlying, ...arg1.map((e) => e._underlying)) // arg0: Executable, ...arg1: Executable[]
66
+ );
@@ -0,0 +1,62 @@
1
+ import { FeederBuilder } from "../feeders";
2
+ import { SessionTo, underlyingSessionTo } from "../session";
3
+
4
+ import JvmFeeds = io.gatling.javaapi.core.feed.Feeds;
5
+
6
+ export interface FeedFunction<T extends Feeds<T>> {
7
+ // TODO (maybe?): Supplier<Iterator<Map<String, Object>>>, Iterator<Map<String, Object>>
8
+
9
+ /**
10
+ * Attach a feed action.
11
+ *
12
+ * @param feederBuilder - a source of records
13
+ * @returns a new StructureBuilder
14
+ */
15
+ (feederBuilder: FeederBuilder<unknown>): T;
16
+
17
+ /**
18
+ * Attach a feed action.
19
+ *
20
+ * @param feederBuilder - a source of records
21
+ * @param numberOfRecords - the number of records to poll from the feeder at once
22
+ * @returns a new StructureBuilder
23
+ */
24
+ (feederBuilder: FeederBuilder<unknown>, numberOfRecords: number): T;
25
+
26
+ /**
27
+ * Attach a feed action.
28
+ *
29
+ * @param feederBuilder - a source of records
30
+ * @param numberOfRecords - the number of records to poll from the feeder at once, expressed as a Gatling Expression
31
+ * Language String
32
+ * @returns a new StructureBuilder
33
+ */
34
+ (feederBuilder: FeederBuilder<unknown>, numberOfRecords: string): T;
35
+
36
+ /**
37
+ * Attach a feed action.
38
+ *
39
+ * @param feederBuilder - a source of records
40
+ * @param numberOfRecords - the number of records to poll from the feeder at once, as a function
41
+ * @returns a new StructureBuilder
42
+ */
43
+ (feederBuilder: FeederBuilder<unknown>, numberOfRecords: SessionTo<number>): T;
44
+ }
45
+
46
+ export interface Feeds<T extends Feeds<T>> {
47
+ feed: FeedFunction<T>;
48
+ }
49
+
50
+ export const feedImpl =
51
+ <J2, J1 extends JvmFeeds<J2, any>, T extends Feeds<T>>(jvmFeeds: J1, wrap: (wrapped: J2) => T): FeedFunction<T> =>
52
+ (feederBuilder: FeederBuilder<unknown>, numberOfRecords?: number | string | SessionTo<number>) => {
53
+ if (typeof numberOfRecords === "number") {
54
+ return wrap(jvmFeeds.feed(feederBuilder._underlying, numberOfRecords));
55
+ } else if (typeof numberOfRecords === "string") {
56
+ return wrap(jvmFeeds.feed(feederBuilder._underlying, numberOfRecords));
57
+ } else if (typeof numberOfRecords === "function") {
58
+ return wrap(jvmFeeds.feed(feederBuilder._underlying, underlyingSessionTo(numberOfRecords)));
59
+ } else {
60
+ return wrap(jvmFeeds.feed(feederBuilder._underlying));
61
+ }
62
+ };
@@ -0,0 +1,68 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { On, wrapOn } from "./on";
3
+
4
+ import JvmForEach = io.gatling.javaapi.core.loop.ForEach;
5
+
6
+ export interface ForEachFunction<T extends ForEach<T>> {
7
+ /**
8
+ * Define a loop that will iterate over a list of values.
9
+ *
10
+ * @param seq - the static list of values to iterate over
11
+ * @param attributeName - the key to store the current element in the Session
12
+ * @param counterName - the name of the loop counter, as stored in the Session
13
+ * @returns a DSL component to define the loop content
14
+ */
15
+ (seq: unknown[], attributeName: string, counterName?: string): On<T>;
16
+
17
+ /**
18
+ * Define a loop that will iterate over a list of values.
19
+ *
20
+ * @param seq - the list of values to iterate over, expressed as a Gatling Expression Language String, must evaluate
21
+ * to an array
22
+ * @param attributeName - the key to store the current element in the Session
23
+ * @param counterName - the name of the loop counter, as stored in the Session
24
+ * @returns a DSL component to define the loop content
25
+ */
26
+ (seq: string, attributeName: string, counterName?: string): On<T>;
27
+
28
+ /**
29
+ * Define a loop that will iterate over a list of values.
30
+ *
31
+ * @param seq - the list of values to iterate over, expressed as a function
32
+ * @param attributeName - the key to store the current element in the Session
33
+ * @param counterName - the name of the loop counter, as stored in the Session
34
+ * @returns a DSL component to define the loop content
35
+ */
36
+ (seq: SessionTo<Array<unknown>>, attributeName: string, counterName?: string): On<T>;
37
+ }
38
+
39
+ export interface ForEach<T extends ForEach<T>> {
40
+ foreach: ForEachFunction<T>;
41
+ }
42
+
43
+ export const foreachImpl =
44
+ <J2, J1 extends JvmForEach<J2, any>, T extends ForEach<T>>(
45
+ jvmForEach: J1,
46
+ wrap: (wrapped: J2) => T
47
+ ): ForEachFunction<T> =>
48
+ (seq: unknown[] | string | SessionTo<Array<unknown>>, attributeName: string, counterName?: string) => {
49
+ if (typeof seq === "function") {
50
+ if (counterName !== undefined) {
51
+ return wrapOn(jvmForEach.foreach(underlyingSessionTo(seq), attributeName, counterName), wrap);
52
+ } else {
53
+ return wrapOn(jvmForEach.foreach(underlyingSessionTo(seq), attributeName), wrap);
54
+ }
55
+ } else if (typeof seq === "string") {
56
+ if (counterName !== undefined) {
57
+ return wrapOn(jvmForEach.foreach(seq, attributeName, counterName), wrap);
58
+ } else {
59
+ return wrapOn(jvmForEach.foreach(seq, attributeName), wrap);
60
+ }
61
+ } else {
62
+ if (counterName !== undefined) {
63
+ return wrapOn(jvmForEach.foreach(seq, attributeName, counterName), wrap);
64
+ } else {
65
+ return wrapOn(jvmForEach.foreach(seq, attributeName), wrap);
66
+ }
67
+ }
68
+ };
@@ -0,0 +1,25 @@
1
+ import JvmForever = io.gatling.javaapi.core.loop.Forever;
2
+
3
+ import { On, wrapOn } from "./on";
4
+
5
+ export interface ForeverFunction<T extends Forever<T>> {
6
+ /**
7
+ * Define a loop that will iterate forever.
8
+ *
9
+ * @param counterName - the name of the loop counter, as stored in the Session
10
+ * @returns a DSL component for defining the loop content
11
+ */
12
+ (counterName?: string): On<T>;
13
+ }
14
+
15
+ export interface Forever<T extends Forever<T>> {
16
+ forever: ForeverFunction<T>;
17
+ }
18
+
19
+ export const foreverImpl =
20
+ <J2, J1 extends JvmForever<J2, any>, T extends Forever<T>>(
21
+ jvmForever: J1,
22
+ wrap: (wrapped: J2) => T
23
+ ): ForeverFunction<T> =>
24
+ (counterName?: string) =>
25
+ wrapOn(counterName !== undefined ? jvmForever.forever(counterName) : jvmForever.forever(), wrap);