user auth token load tests using k6.io

This commit is contained in:
Marcus Efraimsson
2019-01-24 22:47:53 +01:00
parent d6edaa1328
commit 6454de74e4
5 changed files with 369 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
export const createTestOrgIfNotExists = (client) => {
let res = client.orgs.getByName('k6');
if (res.status === 404) {
res = client.orgs.create('k6');
if (res.status !== 200) {
throw new Error('Expected 200 response status when creating org');
}
}
client.withOrgId(res.json().orgId);
}
export const createTestdataDatasourceIfNotExists = (client) => {
const payload = {
access: 'proxy',
isDefault: false,
name: 'k6-testdata',
type: 'testdata',
};
let res = client.datasources.getByName(payload.name);
if (res.status === 404) {
res = client.datasources.create(payload);
if (res.status !== 200) {
throw new Error('Expected 200 response status when creating datasource');
}
}
return res.json().id;
}