mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-05 05:42:16 +00:00
test: add load test for session creation (#8088)
# Which Problems Are Solved Extends load tests by testing session creation. # How the Problems Are Solved The test creates a session including a check for user id. # Additional Context - part of https://github.com/zitadel/zitadel/issues/7639
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { Trend } from 'k6/metrics';
|
||||
import { Org } from './org';
|
||||
import http from 'k6/http';
|
||||
import url from './url';
|
||||
import { check } from 'k6';
|
||||
import { User } from './user';
|
||||
|
||||
export type Session = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const addSessionTrend = new Trend('session_add_session_duration', true);
|
||||
export function createSession(user: User, org: Org, accessToken: string): Promise<Session> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let response = http.asyncRequest(
|
||||
'POST',
|
||||
url('/v2beta/sessions'),
|
||||
JSON.stringify({
|
||||
checks: {
|
||||
user: {
|
||||
userId: user.userId,
|
||||
}
|
||||
}
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bearer ${accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'x-zitadel-orgid': org.organizationId,
|
||||
},
|
||||
},
|
||||
);
|
||||
response.then((res) => {
|
||||
check(res, {
|
||||
'add Session status ok': (r) => r.status === 201,
|
||||
}) || reject(`unable to add Session status: ${res.status} body: ${res.body}`);
|
||||
|
||||
addSessionTrend.add(res.timings.duration);
|
||||
resolve(res.json() as Session);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user