@@ -342,6 +342,38 @@ func TestMetricsAndThresholds(t *testing.T) {
342
342
require .Equal (t , expected , teardownThresholds )
343
343
}
344
344
345
+ func TestThresholdsWithCustomPercentile (t * testing.T ) {
346
+ t .Parallel ()
347
+ script := `
348
+ export const options = {
349
+ scenarios: {
350
+ sc1: {
351
+ executor: 'per-vu-iterations',
352
+ vus: 1,
353
+ iterations: 1,
354
+ },
355
+ },
356
+ thresholds: {
357
+ 'iteration_duration': ['p(0)<50', 'p(90)<100', 'p(99.5)<150', 'p(99.99)<200'],
358
+ },
359
+ };
360
+
361
+ export default function () {}
362
+ `
363
+ ts := getSingleFileTestState (t , script , nil , 0 )
364
+ cmd .ExecuteWithGlobalState (ts .GlobalState )
365
+
366
+ stdout := ts .Stdout .String ()
367
+ t .Log (stdout )
368
+
369
+ // We want to make sure that all the thresholds expressions are accompanied
370
+ // by their values, despite those being present in `options.summaryTrendStats` or not.
371
+ assert .Regexp (t , `✓ 'p\(0\)<50' p\(0\)=\d+(\.\d+)?µs` , stdout )
372
+ assert .Regexp (t , `✓ 'p\(90\)<100' p\(90\)=\d+(\.\d+)?µs` , stdout )
373
+ assert .Regexp (t , `✓ 'p\(99.5\)<150' p\(99.5\)=\d+(\.\d+)?µs` , stdout )
374
+ assert .Regexp (t , `✓ 'p\(99.99\)<200' p\(99.99\)=\d+(\.\d+)?µs` , stdout )
375
+ }
376
+
345
377
func TestSSLKEYLOGFILEAbsolute (t * testing.T ) {
346
378
t .Parallel ()
347
379
ts := NewGlobalTestState (t )
@@ -2102,14 +2134,14 @@ func TestEventSystemError(t *testing.T) {
2102
2134
test.abort('oops!');
2103
2135
}
2104
2136
` , expLog : []string {
2105
- "got event Init with data '<nil>'" ,
2106
- "got event TestStart with data '<nil>'" ,
2107
- "got event IterStart with data '{Iteration:0 VUID:1 ScenarioName:default Error:<nil>}'" ,
2108
- "got event IterEnd with data '{Iteration:0 VUID:1 ScenarioName:default Error:test aborted: oops! at default (file:///-:11:16(5))}'" ,
2109
- "got event TestEnd with data '<nil>'" ,
2110
- "got event Exit with data '&{Error:test aborted: oops! at default (file:///-:11:16(5))}'" ,
2111
- "test aborted: oops! at default (file:///-:11:16(5))" ,
2112
- },
2137
+ "got event Init with data '<nil>'" ,
2138
+ "got event TestStart with data '<nil>'" ,
2139
+ "got event IterStart with data '{Iteration:0 VUID:1 ScenarioName:default Error:<nil>}'" ,
2140
+ "got event IterEnd with data '{Iteration:0 VUID:1 ScenarioName:default Error:test aborted: oops! at default (file:///-:11:16(5))}'" ,
2141
+ "got event TestEnd with data '<nil>'" ,
2142
+ "got event Exit with data '&{Error:test aborted: oops! at default (file:///-:11:16(5))}'" ,
2143
+ "test aborted: oops! at default (file:///-:11:16(5))" ,
2144
+ },
2113
2145
expExitCode : exitcodes .ScriptAborted ,
2114
2146
},
2115
2147
{
@@ -2134,17 +2166,17 @@ func TestEventSystemError(t *testing.T) {
2134
2166
throw new Error('oops!');
2135
2167
}
2136
2168
` , expLog : []string {
2137
- "got event Init with data '<nil>'" ,
2138
- "got event TestStart with data '<nil>'" ,
2139
- "got event IterStart with data '{Iteration:0 VUID:1 ScenarioName:default Error:<nil>}'" ,
2140
- "got event IterEnd with data '{Iteration:0 VUID:1 ScenarioName:default Error:Error: oops!\n \t at default (file:///-:9:12(3))\n }'" ,
2141
- "Error: oops!\n \t at default (file:///-:9:12(3))\n " ,
2142
- "got event IterStart with data '{Iteration:1 VUID:1 ScenarioName:default Error:<nil>}'" ,
2143
- "got event IterEnd with data '{Iteration:1 VUID:1 ScenarioName:default Error:Error: oops!\n \t at default (file:///-:9:12(3))\n }'" ,
2144
- "Error: oops!\n \t at default (file:///-:9:12(3))\n " ,
2145
- "got event TestEnd with data '<nil>'" ,
2146
- "got event Exit with data '&{Error:<nil>}'" ,
2147
- },
2169
+ "got event Init with data '<nil>'" ,
2170
+ "got event TestStart with data '<nil>'" ,
2171
+ "got event IterStart with data '{Iteration:0 VUID:1 ScenarioName:default Error:<nil>}'" ,
2172
+ "got event IterEnd with data '{Iteration:0 VUID:1 ScenarioName:default Error:Error: oops!\n \t at default (file:///-:9:12(3))\n }'" ,
2173
+ "Error: oops!\n \t at default (file:///-:9:12(3))\n " ,
2174
+ "got event IterStart with data '{Iteration:1 VUID:1 ScenarioName:default Error:<nil>}'" ,
2175
+ "got event IterEnd with data '{Iteration:1 VUID:1 ScenarioName:default Error:Error: oops!\n \t at default (file:///-:9:12(3))\n }'" ,
2176
+ "Error: oops!\n \t at default (file:///-:9:12(3))\n " ,
2177
+ "got event TestEnd with data '<nil>'" ,
2178
+ "got event Exit with data '&{Error:<nil>}'" ,
2179
+ },
2148
2180
expExitCode : 0 ,
2149
2181
},
2150
2182
}
0 commit comments