org id fix for load test

This commit is contained in:
Marcus Efraimsson
2019-01-24 23:49:45 +01:00
parent 6454de74e4
commit cfd8bd711b
4 changed files with 37 additions and 24 deletions
+6 -2
View File
@@ -99,7 +99,9 @@ export const BaseClient = class BaseClient {
}
withUrl(subUrl) {
return new BaseClient(this.url, subUrl);
let c = new BaseClient(this.url, subUrl);
c.onBeforeRequest = this.onBeforeRequest;
return c;
}
beforeRequest(params) {
@@ -163,7 +165,9 @@ export class BasicAuthClient extends BaseClient {
}
withUrl(subUrl) {
return new BasicAuthClient(this.url, subUrl, this.username, this.password);
let c = new BasicAuthClient(this.url, subUrl, this.username, this.password);
c.onBeforeRequest = this.onBeforeRequest;
return c;
}
beforeRequest(params) {
+6 -1
View File
@@ -1,13 +1,18 @@
export const createTestOrgIfNotExists = (client) => {
let orgId = 0;
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');
}
orgId = res.json().orgId;
} else {
orgId = res.json().id;
}
client.withOrgId(res.json().orgId);
client.withOrgId(orgId);
return orgId;
}
export const createTestdataDatasourceIfNotExists = (client) => {