Skip to content

Commit

Permalink
feat: udpated stress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dskart committed May 30, 2024
1 parent 1c95b43 commit f6aad1d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 51 deletions.
4 changes: 2 additions & 2 deletions load_tests/src/get-original-stress-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { check } from 'k6';
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.1.0/index.js';
import { getStressTestOptions } from './options';
import { SignedRequest } from './signed-request';
import { getCSVStressMetrics } from './stress-metrics';
import { getStressTestCsv } from './stress-test-csv';

// this test calls s3 directly
const signedRequest = SignedRequest({
Expand All @@ -24,7 +24,7 @@ export default async function () {
}

export function handleSummary(data: any) {
const csv = getCSVStressMetrics(data['metrics']);
const csv = getStressTestCsv(data);
return {
stdout: textSummary(data, { indent: ' ', enableColors: true }),
'get-original-load-test-summary.json': JSON.stringify(data, null, 2),
Expand Down
4 changes: 2 additions & 2 deletions load_tests/src/get-sidekick-stress-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { tagWithCurrentStageIndex } from 'https://jslib.k6.io/k6-utils/1.3.0/ind
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.1.0/index.js';
import { getStressTestOptions } from './options';
import { SignedRequest } from './signed-request';
import { getCSVStressMetrics } from './stress-metrics';
import { getStressTestCsv } from './stress-test-csv';

// This test will get the original file through sidekick
const signedRequest = SignedRequest({
Expand All @@ -26,7 +26,7 @@ export default async function () {
}

export function handleSummary(data: any) {
const csv = getCSVStressMetrics(data['metrics']);
const csv = getStressTestCsv(data);

return {
stdout: textSummary(data, { indent: ' ', enableColors: true }),
Expand Down
47 changes: 0 additions & 47 deletions load_tests/src/stress-metrics.ts

This file was deleted.

25 changes: 25 additions & 0 deletions load_tests/src/stress-test-csv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function getStressTestCsv(data: any) {
let csv: string[] = ['scenario,avg,min,med,max,p(90),p(95)'];

for (const metric in data['metrics']) {
// Check if the metrics is a http_req_duration scenario
if (metric.startsWith('http_req_duration') && metric.includes('scenario')) {
const scenario = metric.split('{')[1].split('}')[0];
const values = data['metrics'][metric]['values'];

const csvRow: string[] = [
scenario,
values['avg'].toString(),
values['min'].toString(),
values['med'].toString(),
values['max'].toString(),
values['p(90)'].toString(),
values['p(95)'].toString(),
];

csv.push(csvRow.join(','));
}
}

return csv.join('\n');
}

0 comments on commit f6aad1d

Please sign in to comment.