-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added option to generate a K6 summary through the handleSummary() callback. Co-authored-by: Tim <>
- Loading branch information
Showing
9 changed files
with
110 additions
and
1 deletion.
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
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
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,22 @@ | ||
function HandleSummary(k6HandleSummaryOptions, result) { | ||
result.handleSummary = []; | ||
if (k6HandleSummaryOptions.json) { | ||
injectJsonHandleSummary(k6HandleSummaryOptions.json, result); | ||
} | ||
if (k6HandleSummaryOptions.junit) { | ||
injectJunitHandleSummary(k6HandleSummaryOptions.junit, result); | ||
} | ||
} | ||
|
||
function injectJsonHandleSummary(jsonPath, result) { | ||
const jsonOut = `"${jsonPath}": JSON.stringify(data)`; | ||
result.handleSummary.push(jsonOut); | ||
} | ||
|
||
function injectJunitHandleSummary(junitPath, result) { | ||
result.imports.set('jUnit', { base: './libs/shim/handleSummary.js' }); | ||
const junitOut = `"${junitPath}": jUnit(data)`; | ||
result.handleSummary.push(junitOut); | ||
} | ||
|
||
module.exports = HandleSummary; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import test from 'ava'; | ||
import convertFile from 'convert/file'; | ||
|
||
test('k6 handle-summary json', async t => { | ||
const options = { | ||
k6HandleSummary: { | ||
json: 'k6-handle-summary.json', | ||
}, | ||
}; | ||
const [main] = await convertFile('test/material/2/request.json', options); | ||
t.snapshot(main); | ||
}); |
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 @@ | ||
# Snapshot report for `test/int/handlesummary.js` | ||
|
||
The actual snapshot is saved in `handlesummary.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## k6 handle-summary json | ||
|
||
> Snapshot 1 | ||
`// Auto-generated by the postman-to-k6 converter␊ | ||
␊ | ||
import "./libs/shim/core.js";␊ | ||
␊ | ||
export let options = { maxRedirects: 4 };␊ | ||
␊ | ||
const Request = Symbol.for("request");␊ | ||
postman[Symbol.for("initial")]({␊ | ||
options␊ | ||
});␊ | ||
␊ | ||
export function handleSummary(data) {␊ | ||
console.log("Preparing the end-of-test summary: ");␊ | ||
return {␊ | ||
"k6-handle-summary.json": JSON.stringify(data)␊ | ||
};␊ | ||
}␊ | ||
␊ | ||
export default function() {␊ | ||
postman[Request]({␊ | ||
name: "TestRequest",␊ | ||
method: "GET",␊ | ||
address: "http://example.com/"␊ | ||
});␊ | ||
}␊ | ||
` |
Binary file not shown.