@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,121 @@
|
|
|
1
|
+
import { SessionTo, underlyingSessionTo } from "../session";
|
|
2
|
+
import { On, wrapOn } from "./on";
|
|
3
|
+
|
|
4
|
+
import JvmAsLongAs = io.gatling.javaapi.core.loop.AsLongAs;
|
|
5
|
+
|
|
6
|
+
export interface AsLongAsFunction<T extends AsLongAs<T>> {
|
|
7
|
+
/**
|
|
8
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
9
|
+
*
|
|
10
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
11
|
+
* @returns a DSL component for defining the loop content
|
|
12
|
+
*/
|
|
13
|
+
(condition: string): On<T>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
17
|
+
*
|
|
18
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
19
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false inside the loop
|
|
20
|
+
* @returns a DSL component for defining the loop content
|
|
21
|
+
*/
|
|
22
|
+
(condition: string, exitASAP: boolean): On<T>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
26
|
+
*
|
|
27
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
28
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
29
|
+
* @returns a DSL component for defining the loop content
|
|
30
|
+
*/
|
|
31
|
+
(condition: string, counterName: string): On<T>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
35
|
+
*
|
|
36
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
37
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
38
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false inside the loop
|
|
39
|
+
* @returns a DSL component for defining the loop content
|
|
40
|
+
*/
|
|
41
|
+
(condition: string, counterName: string, exitASAP: boolean): On<T>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
45
|
+
*
|
|
46
|
+
* @param condition - the condition, expressed as a function
|
|
47
|
+
* @returns a DSL component for defining the loop content
|
|
48
|
+
*/
|
|
49
|
+
(condition: SessionTo<boolean>): On<T>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
53
|
+
*
|
|
54
|
+
* @param condition - the condition, expressed as a function
|
|
55
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false inside the loop
|
|
56
|
+
* @returns a DSL component for defining the loop content
|
|
57
|
+
*/
|
|
58
|
+
(condition: SessionTo<boolean>, exitASAP: boolean): On<T>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
62
|
+
*
|
|
63
|
+
* @param condition - the condition, expressed as a function
|
|
64
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
65
|
+
* @returns a DSL component for defining the loop content
|
|
66
|
+
*/
|
|
67
|
+
(condition: SessionTo<boolean>, counterName: string): On<T>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Define a loop that will iterate as long as the condition holds true
|
|
71
|
+
*
|
|
72
|
+
* @param condition - the condition, expressed as a function
|
|
73
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
74
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false inside the loop
|
|
75
|
+
* @returns a DSL component for defining the loop content
|
|
76
|
+
*/
|
|
77
|
+
(condition: SessionTo<boolean>, counterName: string, exitASAP: boolean): On<T>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AsLongAs<T extends AsLongAs<T>> {
|
|
81
|
+
asLongAs: AsLongAsFunction<T>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const asLongAsImpl =
|
|
85
|
+
<J2, J1 extends JvmAsLongAs<J2, any>, T extends AsLongAs<T>>(
|
|
86
|
+
jvmAsLongAs: J1,
|
|
87
|
+
wrap: (wrapped: J2) => T
|
|
88
|
+
): AsLongAsFunction<T> =>
|
|
89
|
+
(condition: SessionTo<boolean> | string, arg1?: boolean | string, arg2?: boolean) => {
|
|
90
|
+
if (arg2 !== undefined && typeof arg1 === "string") {
|
|
91
|
+
// asLongAs(condition, counterName, exitASAP)
|
|
92
|
+
if (typeof condition === "function") {
|
|
93
|
+
return wrapOn(jvmAsLongAs.asLongAs(underlyingSessionTo(condition), arg1, arg2), wrap);
|
|
94
|
+
} else {
|
|
95
|
+
return wrapOn(jvmAsLongAs.asLongAs(condition, arg1, arg2), wrap);
|
|
96
|
+
}
|
|
97
|
+
} else if (typeof arg1 === "string") {
|
|
98
|
+
// asLongAs(condition, counterName)
|
|
99
|
+
if (typeof condition === "function") {
|
|
100
|
+
return wrapOn(jvmAsLongAs.asLongAs(underlyingSessionTo(condition), arg1), wrap);
|
|
101
|
+
} else {
|
|
102
|
+
return wrapOn(jvmAsLongAs.asLongAs(condition, arg1), wrap);
|
|
103
|
+
}
|
|
104
|
+
} else if (typeof arg1 === "boolean") {
|
|
105
|
+
// asLongAs(condition, exitASAP)
|
|
106
|
+
if (typeof condition === "function") {
|
|
107
|
+
return wrapOn(jvmAsLongAs.asLongAs(underlyingSessionTo(condition), arg1), wrap);
|
|
108
|
+
} else {
|
|
109
|
+
return wrapOn(jvmAsLongAs.asLongAs(condition, arg1), wrap);
|
|
110
|
+
}
|
|
111
|
+
} else if (arg1 === undefined) {
|
|
112
|
+
// asLongAs(condition)
|
|
113
|
+
if (typeof condition === "function") {
|
|
114
|
+
return wrapOn(jvmAsLongAs.asLongAs(underlyingSessionTo(condition)), wrap);
|
|
115
|
+
} else {
|
|
116
|
+
return wrapOn(jvmAsLongAs.asLongAs(condition), wrap);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
throw Error(`asLongAs() called with invalid arguments ${condition}, ${arg1}, ${arg2}`);
|
|
121
|
+
};
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { Duration, isDuration, toJvmDuration } from "../utils/duration";
|
|
2
|
+
import { SessionTo, underlyingSessionTo, underlyingSessionToDuration } from "../session";
|
|
3
|
+
|
|
4
|
+
import { On, wrapOn } from "./on";
|
|
5
|
+
|
|
6
|
+
import JvmAsLongAsDuring = io.gatling.javaapi.core.loop.AsLongAsDuring;
|
|
7
|
+
|
|
8
|
+
export interface AsLongAsDuringFunction<T extends AsLongAsDuring<T>> {
|
|
9
|
+
/**
|
|
10
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
11
|
+
* isn't reached
|
|
12
|
+
*
|
|
13
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
14
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
15
|
+
* @returns a DSL component for defining the loop content
|
|
16
|
+
*/
|
|
17
|
+
(condition: string, duration: Duration): On<T>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
21
|
+
* isn't reached
|
|
22
|
+
*
|
|
23
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
24
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
25
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
26
|
+
* @returns a DSL component for defining the loop content
|
|
27
|
+
*/
|
|
28
|
+
(condition: string, duration: Duration, counterName: string): On<T>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
32
|
+
* isn't reached
|
|
33
|
+
*
|
|
34
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
35
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
36
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
37
|
+
* inside the loop
|
|
38
|
+
* @returns a DSL component for defining the loop content
|
|
39
|
+
*/
|
|
40
|
+
(condition: string, duration: Duration, exitASAP: boolean): On<T>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
44
|
+
* isn't reached
|
|
45
|
+
*
|
|
46
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
47
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
48
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
49
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
50
|
+
* inside the loop
|
|
51
|
+
* @returns a DSL component for defining the loop content
|
|
52
|
+
*/
|
|
53
|
+
(condition: string, duration: Duration, counterName: string, exitASAP: boolean): On<T>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
57
|
+
* isn't reached
|
|
58
|
+
*
|
|
59
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
60
|
+
* @param duration - the maximum duration, expressed as a function
|
|
61
|
+
* @returns a DSL component for defining the loop content
|
|
62
|
+
*/
|
|
63
|
+
(condition: string, duration: SessionTo<Duration>): On<T>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
67
|
+
* isn't reached
|
|
68
|
+
*
|
|
69
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
70
|
+
* @param duration - the maximum duration, expressed as a function
|
|
71
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
72
|
+
* @returns a DSL component for defining the loop content
|
|
73
|
+
*/
|
|
74
|
+
(condition: string, duration: SessionTo<Duration>, counterName: string): On<T>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
78
|
+
* isn't reached
|
|
79
|
+
*
|
|
80
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
81
|
+
* @param duration - the maximum duration, expressed as a function
|
|
82
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
83
|
+
* inside the loop
|
|
84
|
+
* @returns a DSL component for defining the loop content
|
|
85
|
+
*/
|
|
86
|
+
(condition: string, duration: SessionTo<Duration>, exitASAP: boolean): On<T>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
90
|
+
* isn't reached
|
|
91
|
+
*
|
|
92
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
93
|
+
* @param duration - the maximum duration, expressed as a function
|
|
94
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
95
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
96
|
+
* inside the loop
|
|
97
|
+
* @returns a DSL component for defining the loop content
|
|
98
|
+
*/
|
|
99
|
+
(condition: string, duration: SessionTo<Duration>, counterName: string, exitASAP: boolean): On<T>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
103
|
+
* isn't reached
|
|
104
|
+
*
|
|
105
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
106
|
+
* @param duration - the maximum duration, expressed as a Gatling Expression Language String
|
|
107
|
+
* @returns a DSL component for defining the loop content
|
|
108
|
+
*/
|
|
109
|
+
(condition: string, duration: string): On<T>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
113
|
+
* isn't reached
|
|
114
|
+
*
|
|
115
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
116
|
+
* @param duration - the maximum duration, expressed as a Gatling Expression Language String
|
|
117
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
118
|
+
* @returns a DSL component for defining the loop content
|
|
119
|
+
*/
|
|
120
|
+
(condition: string, duration: string, counterName: string): On<T>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
124
|
+
* isn't reached
|
|
125
|
+
*
|
|
126
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
127
|
+
* @param duration - the maximum duration, expressed as a Gatling Expression Language String
|
|
128
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
129
|
+
* inside the loop
|
|
130
|
+
* @returns a DSL component for defining the loop content
|
|
131
|
+
*/
|
|
132
|
+
(condition: string, duration: string, exitASAP: boolean): On<T>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
136
|
+
* isn't reached
|
|
137
|
+
*
|
|
138
|
+
* @param condition - the condition, expressed as a Gatling Expression Language String
|
|
139
|
+
* @param duration - the maximum duration, expressed as a Gatling Expression Language String
|
|
140
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
141
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
142
|
+
* inside the loop
|
|
143
|
+
* @returns a DSL component for defining the loop content
|
|
144
|
+
*/
|
|
145
|
+
(condition: string, duration: string, counterName: string, exitASAP: boolean): On<T>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
149
|
+
* isn't reached
|
|
150
|
+
*
|
|
151
|
+
* @param condition - the condition, expressed as a function
|
|
152
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
153
|
+
* @returns a DSL component for defining the loop content
|
|
154
|
+
*/
|
|
155
|
+
(condition: SessionTo<boolean>, duration: Duration): On<T>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
159
|
+
* isn't reached
|
|
160
|
+
*
|
|
161
|
+
* @param condition - the condition, expressed as a function
|
|
162
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
163
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
164
|
+
* @returns a DSL component for defining the loop content
|
|
165
|
+
*/
|
|
166
|
+
(condition: SessionTo<boolean>, duration: Duration, counterName: string): On<T>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
170
|
+
* isn't reached
|
|
171
|
+
*
|
|
172
|
+
* @param condition - the condition, expressed as a function
|
|
173
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
174
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
175
|
+
* inside the loop
|
|
176
|
+
* @returns a DSL component for defining the loop content
|
|
177
|
+
*/
|
|
178
|
+
(condition: SessionTo<boolean>, duration: Duration, exitASAP: boolean): On<T>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
182
|
+
* isn't reached
|
|
183
|
+
*
|
|
184
|
+
* @param condition - the condition, expressed as a function
|
|
185
|
+
* @param duration - the maximum duration, in seconds or with an explicit time unit
|
|
186
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
187
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
188
|
+
* inside the loop
|
|
189
|
+
* @returns a DSL component for defining the loop content
|
|
190
|
+
*/
|
|
191
|
+
(condition: SessionTo<boolean>, duration: Duration, counterName: string, exitASAP: boolean): On<T>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
195
|
+
* isn't reached
|
|
196
|
+
*
|
|
197
|
+
* @param condition - the condition, expressed as a function
|
|
198
|
+
* @param duration - the maximum duration, expressed as a function
|
|
199
|
+
* @returns a DSL component for defining the loop content
|
|
200
|
+
*/
|
|
201
|
+
(condition: SessionTo<boolean>, duration: SessionTo<Duration>): On<T>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
205
|
+
* isn't reached
|
|
206
|
+
*
|
|
207
|
+
* @param condition - the condition, expressed as a function
|
|
208
|
+
* @param duration - the maximum duration, expressed as a function
|
|
209
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
210
|
+
* @returns a DSL component for defining the loop content
|
|
211
|
+
*/
|
|
212
|
+
(condition: SessionTo<boolean>, duration: SessionTo<Duration>, counterName: string): On<T>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
216
|
+
* isn't reached
|
|
217
|
+
*
|
|
218
|
+
* @param condition - the condition, expressed as a function
|
|
219
|
+
* @param duration - the maximum duration, expressed as a function
|
|
220
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
221
|
+
* inside the loop
|
|
222
|
+
* @returns a DSL component for defining the loop content
|
|
223
|
+
*/
|
|
224
|
+
(condition: SessionTo<boolean>, duration: SessionTo<Duration>, exitASAP: boolean): On<T>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Define a loop that will iterate as long as the condition holds true and a maximum duration
|
|
228
|
+
* isn't reached
|
|
229
|
+
*
|
|
230
|
+
* @param condition - the condition, expressed as a function
|
|
231
|
+
* @param duration - the maximum duration, expressed as a function
|
|
232
|
+
* @param counterName - the name of the loop counter, as stored in the Session
|
|
233
|
+
* @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
|
|
234
|
+
* inside the loop
|
|
235
|
+
* @returns a DSL component for defining the loop content
|
|
236
|
+
*/
|
|
237
|
+
(condition: SessionTo<boolean>, duration: SessionTo<Duration>, counterName: string, exitASAP: boolean): On<T>;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface AsLongAsDuring<T extends AsLongAsDuring<T>> {
|
|
241
|
+
asLongAsDuring: AsLongAsDuringFunction<T>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export const asLongAsDuringImpl =
|
|
245
|
+
<J2, J1 extends JvmAsLongAsDuring<J2, any>, T extends AsLongAsDuring<T>>(
|
|
246
|
+
jvmAsLongAsDuring: J1,
|
|
247
|
+
wrap: (wrapped: J2) => T
|
|
248
|
+
): AsLongAsDuringFunction<T> =>
|
|
249
|
+
(
|
|
250
|
+
condition: SessionTo<boolean> | string,
|
|
251
|
+
duration: Duration | SessionTo<Duration> | string,
|
|
252
|
+
arg2?: string | boolean,
|
|
253
|
+
arg3?: boolean
|
|
254
|
+
) => {
|
|
255
|
+
if (arg3 !== undefined && typeof arg2 === "string") {
|
|
256
|
+
// asLongAsDuring(condition, duration, counterName, exitASAP)
|
|
257
|
+
if (typeof condition === "function") {
|
|
258
|
+
const wrappedCondition = underlyingSessionTo(condition);
|
|
259
|
+
if (isDuration(duration)) {
|
|
260
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, toJvmDuration(duration), arg2, arg3), wrap);
|
|
261
|
+
} else if (typeof duration === "function") {
|
|
262
|
+
return wrapOn(
|
|
263
|
+
jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2, arg3),
|
|
264
|
+
wrap
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
if (isDuration(duration)) {
|
|
269
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, toJvmDuration(duration), arg2, arg3), wrap);
|
|
270
|
+
} else if (typeof duration === "function") {
|
|
271
|
+
return wrapOn(
|
|
272
|
+
jvmAsLongAsDuring.asLongAsDuring(condition, underlyingSessionToDuration(duration), arg2, arg3),
|
|
273
|
+
wrap
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
} else if (typeof arg2 === "string") {
|
|
278
|
+
// asLongAsDuring(condition, duration, counterName)
|
|
279
|
+
if (typeof condition === "function") {
|
|
280
|
+
const wrappedCondition = underlyingSessionTo(condition);
|
|
281
|
+
if (isDuration(duration)) {
|
|
282
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, toJvmDuration(duration), arg2), wrap);
|
|
283
|
+
} else if (typeof duration === "function") {
|
|
284
|
+
return wrapOn(
|
|
285
|
+
jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2),
|
|
286
|
+
wrap
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
if (isDuration(duration)) {
|
|
291
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, toJvmDuration(duration), arg2), wrap);
|
|
292
|
+
} else if (typeof duration === "function") {
|
|
293
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, underlyingSessionToDuration(duration), arg2), wrap);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} else if (typeof arg2 === "boolean") {
|
|
297
|
+
// asLongAsDuring(condition, duration, exitASAP)
|
|
298
|
+
if (typeof condition === "function") {
|
|
299
|
+
const wrappedCondition = underlyingSessionTo(condition);
|
|
300
|
+
if (isDuration(duration)) {
|
|
301
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, toJvmDuration(duration), arg2), wrap);
|
|
302
|
+
} else if (typeof duration === "function") {
|
|
303
|
+
return wrapOn(
|
|
304
|
+
jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2),
|
|
305
|
+
wrap
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
if (isDuration(duration)) {
|
|
310
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, toJvmDuration(duration), arg2), wrap);
|
|
311
|
+
} else if (typeof duration === "function") {
|
|
312
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, underlyingSessionToDuration(duration), arg2), wrap);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
} else if (arg2 === undefined) {
|
|
316
|
+
// asLongAsDuring(condition, duration)
|
|
317
|
+
if (typeof condition === "function") {
|
|
318
|
+
const wrappedCondition = underlyingSessionTo(condition);
|
|
319
|
+
if (isDuration(duration)) {
|
|
320
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, toJvmDuration(duration)), wrap);
|
|
321
|
+
} else if (typeof duration === "function") {
|
|
322
|
+
return wrapOn(
|
|
323
|
+
jvmAsLongAsDuring.asLongAsDuring(wrappedCondition, underlyingSessionToDuration(duration)),
|
|
324
|
+
wrap
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
if (isDuration(duration)) {
|
|
329
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, toJvmDuration(duration)), wrap);
|
|
330
|
+
} else if (typeof duration === "function") {
|
|
331
|
+
return wrapOn(jvmAsLongAsDuring.asLongAsDuring(condition, underlyingSessionToDuration(duration)), wrap);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
throw Error(`asLongAsDuring() called with invalid arguments ${condition}, ${duration}, ${arg2}, ${arg3}`);
|
|
337
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CoreDsl as JvmCoreDsl } from "@gatling.io/jvm-types";
|
|
2
|
+
|
|
3
|
+
import { Wrapper } from "../common";
|
|
4
|
+
import { Executable } from "./execs";
|
|
5
|
+
|
|
6
|
+
import JvmChoiceWithKey = io.gatling.javaapi.core.Choice$WithKey;
|
|
7
|
+
import JvmChoiceWithKeyThen = io.gatling.javaapi.core.WithKey$Then;
|
|
8
|
+
import JvmChoiceWithWeight = io.gatling.javaapi.core.Choice$WithWeight;
|
|
9
|
+
import JvmChoiceWithWeightThen = io.gatling.javaapi.core.WithWeight$Then;
|
|
10
|
+
|
|
11
|
+
export interface ChoiceWithKey extends Wrapper<JvmChoiceWithKey> {}
|
|
12
|
+
const wrapChoiceWithKey = (_underlying: JvmChoiceWithKey): ChoiceWithKey => ({
|
|
13
|
+
_underlying
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
interface ChoiceWithKeyThen {
|
|
17
|
+
then(executable: Executable<any>, ...executables: Executable<any>[]): ChoiceWithKey;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const wrapChoiceWithKeyThen = (jvmChoiceWithKeyThen: JvmChoiceWithKeyThen): ChoiceWithKeyThen => ({
|
|
21
|
+
then: (executable: Executable<any>, ...executables: Executable<any>[]): ChoiceWithKey =>
|
|
22
|
+
wrapChoiceWithKey(jvmChoiceWithKeyThen.then(executable._underlying, ...executables.map((e) => e._underlying)))
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const onCase = (key: unknown): ChoiceWithKeyThen => wrapChoiceWithKeyThen(JvmCoreDsl.onCase(key));
|
|
26
|
+
|
|
27
|
+
export interface ChoiceWithWeight extends Wrapper<JvmChoiceWithWeight> {}
|
|
28
|
+
const wrapChoiceWithWeight = (_underlying: JvmChoiceWithWeight): ChoiceWithWeight => ({
|
|
29
|
+
_underlying
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
interface ChoiceWithWeightThen {
|
|
33
|
+
then(executable: Executable<any>, ...executables: Executable<any>[]): ChoiceWithWeight;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const wrapChoiceWithWeightThen = (jvmChoiceWithWeightThen: JvmChoiceWithWeightThen): ChoiceWithWeightThen => ({
|
|
37
|
+
then: (executable: Executable<any>, ...executables: Executable<any>[]): ChoiceWithWeight =>
|
|
38
|
+
wrapChoiceWithWeight(jvmChoiceWithWeightThen.then(executable._underlying, ...executables.map((e) => e._underlying)))
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const percent = (percent: number): ChoiceWithWeightThen => wrapChoiceWithWeightThen(JvmCoreDsl.percent(percent));
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { SessionTo, underlyingSessionTo } from "../session";
|
|
2
|
+
import { Executable } from "./execs";
|
|
3
|
+
|
|
4
|
+
import JvmDoIf = io.gatling.javaapi.core.condition.DoIf;
|
|
5
|
+
import JvmDoIfEquals = io.gatling.javaapi.core.condition.DoIfEquals;
|
|
6
|
+
import JvmExecutable = io.gatling.javaapi.core.exec.Executable;
|
|
7
|
+
|
|
8
|
+
// DoIf$Then and DoIfEquals$Then are equivalent for us
|
|
9
|
+
interface JvmThen<T> {
|
|
10
|
+
then(executable: JvmExecutable, ...executables: JvmExecutable[]): T;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface Then<T> {
|
|
14
|
+
then(executable: Executable<any>, ...executables: Executable<any>[]): T;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const wrapThen = <J, T>(jvmThen: JvmThen<J>, wrap: (underlying: J) => T): Then<T> => ({
|
|
18
|
+
then: (executable: Executable<any>, ...executables: Executable<any>[]): T =>
|
|
19
|
+
wrap(jvmThen.then(executable._underlying, ...executables.map((e) => e._underlying)))
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export interface DoIfFunction<T extends DoIf<T>> {
|
|
23
|
+
/**
|
|
24
|
+
* Execute the "then" block only if the condition is true
|
|
25
|
+
*
|
|
26
|
+
* @param condition - the condition expressed as a Gatling Expression Language String that must
|
|
27
|
+
* evaluate to a Boolean
|
|
28
|
+
* @returns a DSL component for defining the "then" block
|
|
29
|
+
*/
|
|
30
|
+
(condition: string): Then<T>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Execute the "then" block only if the condition is true
|
|
34
|
+
*
|
|
35
|
+
* @param condition - the condition expressed as a function
|
|
36
|
+
* @returns a DSL component for defining the "then" block
|
|
37
|
+
*/
|
|
38
|
+
(condition: SessionTo<boolean>): Then<T>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface DoIf<T extends DoIf<T>> {
|
|
42
|
+
doIf: DoIfFunction<T>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const doIfImpl =
|
|
46
|
+
<J2, J1 extends JvmDoIf<J2, any>, T extends DoIf<T>>(jvmDoIf: J1, wrap: (wrapped: J2) => T): DoIfFunction<T> =>
|
|
47
|
+
(condition: string | SessionTo<boolean>) =>
|
|
48
|
+
wrapThen(
|
|
49
|
+
typeof condition === "function" ? jvmDoIf.doIf(underlyingSessionTo(condition)) : jvmDoIf.doIf(condition),
|
|
50
|
+
wrap
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export interface DoIfEqualsFunction<T extends DoIfEquals<T>> {
|
|
54
|
+
/**
|
|
55
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
56
|
+
*
|
|
57
|
+
* @param actual - the actual value expressed as a Gatling Expression Language String
|
|
58
|
+
* @param expected - the expected value expressed as a Gatling Expression Language String
|
|
59
|
+
* @returns a DSL component for defining the "then" block
|
|
60
|
+
*/
|
|
61
|
+
(actual: string, expected: string): Then<T>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
65
|
+
*
|
|
66
|
+
* @param actual - the actual value expressed as a Gatling Expression Language String
|
|
67
|
+
* @param expected - the expected static value
|
|
68
|
+
* @returns a DSL component for defining the "then" block
|
|
69
|
+
*/
|
|
70
|
+
(actual: string, expected: unknown): Then<T>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
74
|
+
*
|
|
75
|
+
* @param actual - the actual value expressed as a Gatling Expression Language String
|
|
76
|
+
* @param expected - the expected value expressed as a function
|
|
77
|
+
* @returns a DSL component for defining the "then" block
|
|
78
|
+
*/
|
|
79
|
+
(actual: string, expected: SessionTo<unknown>): Then<T>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
83
|
+
*
|
|
84
|
+
* @param actual - the actual value expressed as a function
|
|
85
|
+
* @param expected - the expected value expressed as a Gatling Expression Language String
|
|
86
|
+
* @returns a DSL component for defining the "then" block
|
|
87
|
+
*/
|
|
88
|
+
(actual: SessionTo<unknown>, expected: string): Then<T>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
92
|
+
*
|
|
93
|
+
* @param actual - the actual value expressed as a function
|
|
94
|
+
* @param expected - the expected static value
|
|
95
|
+
* @returns a DSL component for defining the "then" block
|
|
96
|
+
*/
|
|
97
|
+
(actual: SessionTo<unknown>, expected: unknown): Then<T>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Execute the "then" block only if the actual value is equal to the expected one
|
|
101
|
+
*
|
|
102
|
+
* @param actual - the actual value expressed as a function
|
|
103
|
+
* @param expected - the expected value expressed as a function
|
|
104
|
+
* @returns a DSL component for defining the "then" block
|
|
105
|
+
*/
|
|
106
|
+
(actual: SessionTo<unknown>, expected: SessionTo<unknown>): Then<T>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface DoIfEquals<T extends DoIfEquals<T>> {
|
|
110
|
+
doIfEquals: DoIfEqualsFunction<T>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const doIfEqualsImpl =
|
|
114
|
+
<J2, J1 extends JvmDoIfEquals<J2, any>, T extends DoIfEquals<T>>(
|
|
115
|
+
jvmDoIfEquals: J1,
|
|
116
|
+
wrap: (wrapped: J2) => T
|
|
117
|
+
): DoIfEqualsFunction<T> =>
|
|
118
|
+
(actual: string | SessionTo<unknown>, expected: string | SessionTo<unknown> | unknown) => {
|
|
119
|
+
if (typeof actual === "function") {
|
|
120
|
+
const wrappedActual = underlyingSessionTo(actual);
|
|
121
|
+
if (typeof expected === "function") {
|
|
122
|
+
return wrapThen(
|
|
123
|
+
jvmDoIfEquals.doIfEquals(wrappedActual, underlyingSessionTo(expected as SessionTo<unknown>)),
|
|
124
|
+
wrap
|
|
125
|
+
);
|
|
126
|
+
} else if (typeof expected === "string") {
|
|
127
|
+
return wrapThen(jvmDoIfEquals.doIfEquals(wrappedActual, expected), wrap);
|
|
128
|
+
} else {
|
|
129
|
+
return wrapThen(jvmDoIfEquals.doIfEquals(wrappedActual, expected), wrap);
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
if (typeof expected === "function") {
|
|
133
|
+
return wrapThen(jvmDoIfEquals.doIfEquals(actual, underlyingSessionTo(expected as SessionTo<unknown>)), wrap);
|
|
134
|
+
} else if (typeof expected === "string") {
|
|
135
|
+
return wrapThen(jvmDoIfEquals.doIfEquals(actual, expected), wrap);
|
|
136
|
+
} else {
|
|
137
|
+
return wrapThen(jvmDoIfEquals.doIfEquals(actual, expected), wrap);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|