-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this test was used to help with load testing
- Loading branch information
1 parent
5d47076
commit 050998e
Showing
2 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { sleep, check } from 'k6'; | ||
import { createRealm, deleteRealm, createUser, generateRealms, getAccessToken, clearRealmSessions } from './helpers.js'; | ||
import { user, realm } from './constants.js'; | ||
import { username, password, clientId } from './env.js'; | ||
|
||
const TOTAL_ACTIVE_SESSIONS = 3000; | ||
const TOTAL_REALMS = 30; | ||
const MAX_ALLOWED_FAILURE_RATE = '0.01'; | ||
|
||
const RAMP_UP_TIME_SECONDS = 60; | ||
const HOLD_TIME_SECONDS = 300; | ||
// SESSION_TIME determines how long a user sleeps before requesting a new token. | ||
const SESSION_TIME = 10; | ||
|
||
|
||
export const options = { | ||
stages: [ | ||
{ | ||
target: TOTAL_ACTIVE_SESSIONS, | ||
duration: `${RAMP_UP_TIME_SECONDS}s`, | ||
}, | ||
{ | ||
target: TOTAL_ACTIVE_SESSIONS, | ||
duration: `${HOLD_TIME_SECONDS}s`, | ||
}, | ||
], | ||
thresholds: { | ||
http_req_failed: [ | ||
{ | ||
threshold: `rate<${MAX_ALLOWED_FAILURE_RATE}`, | ||
// abortOnFail: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export function setup() { | ||
const accessToken = getAccessToken(username, password, clientId); | ||
const emptyRealms = generateRealms(TOTAL_REALMS); | ||
emptyRealms.forEach((realm, i) => { | ||
createRealm(realm, accessToken); | ||
if (i === 0) createUser(user, realm.realm, accessToken); | ||
}); | ||
return emptyRealms; | ||
} | ||
|
||
export default function (realms) { | ||
getAccessToken(user.username, user.credentials[0].value, clientId, realms[0].realm); | ||
sleep(SESSION_TIME); | ||
return realms; | ||
} | ||
|
||
export function teardown(realms) { | ||
const accessToken = getAccessToken(username, password, clientId); | ||
realms.forEach((realm, i) => { | ||
deleteRealm(realm.realm, accessToken); | ||
}); | ||
} |