-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update threshold to use checks metrics instead of errors - Simplified the stopInterationOnFail method and updated call points.
- Loading branch information
1 parent
bf04c37
commit 39c74d5
Showing
8 changed files
with
178 additions
and
315 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
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ import KJUR from "https://unpkg.com/[email protected]/lib/jsrsasign.js"; | |
|
||
import { buildHeaderWithContentType} from "../apiHelpers.js"; | ||
import * as config from "../config.js"; | ||
import { stopIterationOnFail, addErrorCount } from "../errorhandler.js"; | ||
import { stopIterationOnFail } from "../errorhandler.js"; | ||
|
||
const encodedJwk = __ENV.encodedJwk; | ||
const mpClientId = __ENV.mpClientId; | ||
|
@@ -40,12 +40,8 @@ export function generateAccessToken(scopes) { | |
"// Setup // Authentication towards Maskinporten Success": (r) => | ||
r.status === 200, | ||
}); | ||
addErrorCount(success); | ||
stopIterationOnFail( | ||
"// Setup // Authentication towards Maskinporten Failed", | ||
success, | ||
res | ||
); | ||
|
||
stopIterationOnFail("// Setup // Authentication towards Maskinporten Failed", success); | ||
|
||
let accessToken = JSON.parse(res.body)['access_token']; | ||
return accessToken; | ||
|
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 |
---|---|---|
@@ -1,25 +1,12 @@ | ||
import { Counter } from "k6/metrics"; | ||
import { fail } from "k6"; | ||
|
||
let ErrorCount = new Counter("errors"); | ||
|
||
//Adds a count to the error counter when value of success is false | ||
export function addErrorCount(success) { | ||
if (!success) { | ||
ErrorCount.add(1); | ||
} | ||
} | ||
|
||
/** | ||
* Stops k6 iteration when success is false and prints test name with response code | ||
* @param {String} testName | ||
* @param {boolean} success | ||
* @param {JSON} res | ||
* @param {String} failReason The reason for stopping the tests | ||
* @param {boolean} success The result of a check | ||
*/ | ||
export function stopIterationOnFail(testName, success, res) { | ||
if (!success && res != null) { | ||
fail(testName + ": Response code: " + res.status + ". Response message: " + res.body); | ||
} else if (!success) { | ||
fail(testName); | ||
export function stopIterationOnFail(failReason, success) { | ||
if (!success) { | ||
fail(failReason); | ||
} | ||
} |
Oops, something went wrong.