-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(apdex): run apdex logic correctly in workers (#2195)
Solves #2193
- Loading branch information
1 parent
5516ff0
commit 9c51118
Showing
5 changed files
with
91 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/artillery-plugin-apdex/test/fixtures/processor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function myAfterResponseHandler(req, res, context, ee, next) { | ||
//Change your function name and add your logic here. | ||
//For more information, check: https://docs.art/http-reference#function-signatures | ||
console.log('After Response Handler still working'); | ||
next(); | ||
} | ||
|
||
module.exports = { | ||
myAfterResponseHandler | ||
}; |
14 changes: 14 additions & 0 deletions
14
packages/artillery-plugin-apdex/test/fixtures/scenario.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
config: | ||
target: "http://asciiart.artillery.io:8080" | ||
processor: "./processor.js" | ||
phases: | ||
- duration: 5 | ||
arrivalRate: 1 | ||
name: "Phase 1" | ||
|
||
scenarios: | ||
- name: apdexPluginTest | ||
flow: | ||
- get: | ||
afterResponse: myAfterResponseHandler | ||
url: "/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const { test, afterEach } = require('tap'); | ||
const { $ } = require('zx'); | ||
|
||
test('apdex plugin works when other after response hooks are set', async (t) => { | ||
//Arrange: Plugin overrides | ||
const override = JSON.stringify({ | ||
config: { | ||
plugins: { apdex: {} }, | ||
apdex: { | ||
threshold: 100 | ||
} | ||
} | ||
}); | ||
|
||
//Act: run the test | ||
const output = | ||
await $`../artillery/bin/run run ./test/fixtures/scenario.yml --overrides ${override}`; | ||
|
||
const apdexRegex = | ||
/Apdex score: (\d(?:\.\d+)?) \((unacceptable|poor|fair|good|excellent)\)/; | ||
|
||
const apdexTest = apdexRegex.test(output.stdout); | ||
const afterResponseOccurrences = ( | ||
output.stdout.match( | ||
new RegExp(/After Response Handler still working/, 'g') | ||
) || [] | ||
).length; | ||
|
||
// Assert | ||
t.ok(apdexTest, 'Console did not include Apdex score'); | ||
t.equal( | ||
afterResponseOccurrences, | ||
5, | ||
'After Response Handler did not run five times' | ||
); | ||
}); |