chore: init load tests (#7635)

* init load tests

* add machine pat

* setup app

* add introspect

* use xk6-modules repo

* logging

* add teardown

* add manipulate user

* add manipulate user

* remove logs

* convert tests to ts

* add readme

* zitadel

* review comments
This commit is contained in:
Silvan
2024-04-18 11:21:07 +02:00
committed by GitHub
parent dbb824a73f
commit d337668599
22 changed files with 5612 additions and 0 deletions

37
load-test/src/project.ts Normal file
View File

@@ -0,0 +1,37 @@
import { Trend } from 'k6/metrics';
import { Org } from './org';
import http from 'k6/http';
import url from './url';
import { check } from 'k6';
export type Project = {
id: string;
};
const addProjectTrend = new Trend('project_add_project_duration', true);
export function createProject(name: string, org: Org, accessToken: string): Promise<Project> {
return new Promise((resolve, reject) => {
let response = http.asyncRequest(
'POST',
url('/management/v1/projects'),
JSON.stringify({
name: name,
}),
{
headers: {
authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'x-zitadel-orgid': org.organizationId,
},
},
);
response.then((res) => {
check(res, {
'add project status ok': (r) => r.status === 200,
}) || reject(`unable to add project status: ${res.status} body: ${res.body}`);
addProjectTrend.add(res.timings.duration);
resolve(res.json() as Project);
});
});
}