feat: initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
const http = require("k6/http");
|
||||
const isLogging = false;
|
||||
|
||||
export function runHttp(jsonBlob, token) {
|
||||
let response;
|
||||
if (isLogging) console.log("running file: ", jsonBlob.fileName)
|
||||
let json = JSON.stringify(jsonBlob.text);
|
||||
|
||||
const startDay = Math.floor(Math.random() * 30) + 1;
|
||||
const endDay = Math.floor(Math.random() * 30) + 1;
|
||||
json = json.replace("{startDay}", startDay);
|
||||
json = json.replace("{endDay}", endDay);
|
||||
json = JSON.parse(json);
|
||||
response = http.post(
|
||||
'https://analytics-api-perf.dev.stratanetwork.net/api/v1/data-sources/1307/query',
|
||||
json,
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bearer ${token}`,
|
||||
Accept: '*/*',
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Clientappname": 'strata-analytics',
|
||||
'content-type': 'application/json',
|
||||
'sec-ch-ua': '"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
},
|
||||
}
|
||||
)
|
||||
if(response.status !== 200) console.log("endpoint failed", jsonBlob.fileName);
|
||||
else if (isLogging) console.log("success: ", jsonBlob.fileName);
|
||||
}
|
||||
|
||||
export function generateToken() {
|
||||
const url = "https://identity.dev.stratanetwork.net";
|
||||
const username = `perf1`;
|
||||
const password = "Password1";
|
||||
const dbguid = 'b8018250-af34-403e-bdcc-1770714042b2';
|
||||
|
||||
// token
|
||||
const tokenUrl = url + "/connect/token";
|
||||
const body = {
|
||||
database_guid: dbguid,
|
||||
grant_type: 'password',
|
||||
username: username,
|
||||
password: password,
|
||||
scope: 'strata.api.external offline_access',
|
||||
client_id: 'IntegrationTest',
|
||||
client_secret: 'UhAEQsGByTCrwPdHPLmaet_DmLEfcJVbZqGBxArdeRup_TPLrYKNpUNRHejjdnhd',
|
||||
};
|
||||
const params = {
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'sec-ch-ua': '"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
}
|
||||
};
|
||||
const response = http.post(tokenUrl, body, params);
|
||||
if (response.status !== 200) {
|
||||
if (isLogging) console.log("error getting token: ", response);
|
||||
return false
|
||||
};
|
||||
const token = JSON.parse(response.body).access_token;
|
||||
if (isLogging) console.log("success getting token! access token: ", token);
|
||||
return token;
|
||||
}
|
||||
Reference in New Issue
Block a user