Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: k6 Load Test
on:
workflow_dispatch:
push:
branches:
- 'main'
# branches:
# - 'main'

jobs:
run-test:
Expand All @@ -15,11 +15,12 @@ jobs:

- name: Setup K6
uses: grafana/setup-k6-action@v1

- name: Run local k6 test
uses: grafana/run-k6-action@v1
env:
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
K6_CLOUD_PROJECT_ID: ${{ secrets.K6_CLOUD_PROJECT_ID }}
with:
path: tests/load-tests/**.js
path: tests/load-tests/load-bootup.js
parallel: false
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ lerna-debug.log*
.pnp.*

# MacOS specific
.DS_Store
.DS_Store

# JetBrains specific
.idea
2,004 changes: 2,004 additions & 0 deletions tests/load-tests/extract.csv

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions tests/load-tests/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import http from 'k6/http';
import { check } from 'k6';
import { open } from 'k6/experimental/fs';
import csv from 'k6/experimental/csv';

const _baseUrl = 'https://api-proxy.koro.com';
const _headers = {
'Content-Type': 'application/json',
'sw-access-key': 'SWSCTNNXAGVLUVDQDHNCCVFQQW',
'x-vercel-protection-bypass': 'EFc2HoLO2HUIQ4Z3S8PlgfnS8BKHP45Y',
};

export const getOptions = {
// Load test for 2 mins with 50 VUs
stages: [
{ duration: '30m', target: 100 },
// { duration: '5m', target: 100 },
// { duration: '1m', target: 0 },
],
};

export const getRecords = async () => {
const records = await csv.parse(await open('./extract.csv'), {
asObjects: true,
});

return records.map((record) => {
if (record.group.includes('/store-api/checkout')) {
return undefined;
}

if (record.group.includes('@proxy.method:GET')) {
return {
method: 'GET',
slug: record.group
.split(';')
.find((r) => r.startsWith('@proxy.path'))
.split(':')[1],
};
}

if (
record.group.includes('@proxy.method:POST') &&
(record.group.includes('/store-api/language') ||
record.group.includes('/store-api/product') ||
record.group.includes('/store-api/category') ||
record.group.includes('/store-api/navigation') ||
record.group.includes('/store-api/salutation') ||
record.group.includes('/store-api/country') ||
record.group.includes('/store-api/seo-url') ||
record.group.includes('/store-api/shipping-method'))
) {
return {
method: 'POST',
slug: record.group
.split(';')
.find((r) => r.startsWith('@proxy.path'))
.split(':')[1],
};
}
});
};

export const performTest = (
method,
slug,
baseUrl = undefined,
headers = {},
) => {
baseUrl = baseUrl ?? _baseUrl;
headers = {
..._headers,
...headers,
};

let res;

switch (method) {
case 'GET':
res = http.get(`${baseUrl}${slug}`, {
headers,
});
break;
case 'POST':
res = http.post(`${baseUrl}${slug}`, undefined, {
headers,
});
break;
default:
return;
}

// console.log(method, `${baseUrl}${slug}`);
// console.log(res.status);
// console.log(res.request.headers);
// console.log(res.headers);

check(res, {
[slug]: (r) => r.status === 200,
});
};
20 changes: 20 additions & 0 deletions tests/load-tests/load-bootup-bff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { sleep } from 'k6';
import { getOptions, getRecords, performTest } from './functions.js';

export const options = getOptions;

const baseUrl = 'https://bff.koro.software';

const records = await getRecords();

export default () => {
records.forEach((record) => {
if (!record) {
return;
}

performTest(record.method, record.slug, baseUrl);
});

sleep(1);
};
154 changes: 14 additions & 140 deletions tests/load-tests/load-bootup-redis.js
Original file line number Diff line number Diff line change
@@ -1,149 +1,23 @@
import http from 'k6/http';
import { sleep } from 'k6';
import { getOptions, getRecords, performTest } from './functions.js';

export const options = {
// Load test for 2 mins with 50 VUs
stages: [
{ duration: '1m', target: 100 },
{ duration: '5m', target: 100 },
{ duration: '1m', target: 0 },
],
};

export default () => {
const baseUrl =
'https://store-api-proxy-git-feature-ntrkv-redis-storage-korohandelsgmbh.vercel.app/store-api';
const headers = {
'Content-Type': 'application/json',
'sw-access-key': 'SWSCTNNXAGVLUVDQDHNCCVFQQW',
Cookie: '_vercel_jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJuU0poeHRqQmZMNWoyeWxKTEMzMUgzR1EiLCJpYXQiOjE3Mzk3OTkxMzksIm93bmVySWQiOiJ0ZWFtX2ZRQVF4MFA3WU1GRlVucVBPVUhVMXVDMSIsImF1ZCI6InN0b3JlLWFwaS1wcm94eS1sb3c5Y3kyeHQta29yb2hhbmRlbHNnbWJoLnZlcmNlbC5hcHAiLCJ1c2VybmFtZSI6ImtsYXJzdGlsIiwic3ViIjoic3NvLXByb3RlY3Rpb24ifQ.ch_bj7D1d7tmdMMKxdo_SKK6UALGCO1GXYkMOm7-HGs',
};

http.get(`${baseUrl}/context`, {
headers,
});

http.post(`${baseUrl}/language`, {
headers,
});

http.get(`${baseUrl}/checkout/survey/options`, {
headers,
});

http.post(`${baseUrl}/country`, {
headers,
});

http.post(`${baseUrl}/payment-method?onlyAvailable=1`, {
headers,
});

http.post(
`${baseUrl}//navigation/0191559989177d0b9f1a6f8c0a53cdeb/0191559989177d0b9f1a6f8c0a53cdeb`,
{
headers,
},
);

http.post(`${baseUrl}/shipping-method?onlyAvailable=true`, {
headers,
});
export const options = getOptions;

http.get(`${baseUrl}/checkout/cart`, {
headers,
});

http.post(`${baseUrl}/category/0191559989177d0b9f1a6f8c0a53cdeb`, {
headers,
});

http.post(`${baseUrl}/salutation`, {
headers,
});

http.post(`${baseUrl}/country-state/b379dec7c6834ce091d341d3e9cb581d`, {
headers,
});

http.post(`${baseUrl}/navigation/footer-navigation/footer-navigation`, {
headers,
});

http.post(`${baseUrl}/category/019155ba27b97b31944bdd87de4d3506`, {
headers,
});

http.post(`${baseUrl}/category/01919946a3797eaa939a82ff1775efdf`, {
headers,
});

http.post(`${baseUrl}/category/019155bcc1ab73709f14c68ca07b9c5c`, {
headers,
});

http.post(`${baseUrl}/category/01943b4162e97b8296be5b9b154d6d50`, {
headers,
});

http.post(`${baseUrl}/category/0191559ae4747220a50815213d6f5c4b`, {
headers,
});

http.post(`${baseUrl}/category/0191559b045a7b97b367cbcbc8508b10`, {
headers,
});

http.post(`${baseUrl}/category/0191559a78897069a171a88038b02f28`, {
headers,
});

http.post(`${baseUrl}/category/39e5a0d1022e5188b7c7607678e26151`, {
headers,
});

http.post(`${baseUrl}/product/e17bbe2b67c45972aac6a0dae822a043`, {
headers,
});

http.post(`${baseUrl}/product/6d523eda5fb95ab4b691c9916a391223`, {
headers,
});

http.post(`${baseUrl}/product/01928b2e79287155a8fa068f336c8813`, {
headers,
});

http.post(`${baseUrl}/product/5b23cedb8c6e558c82c8573b54634bac`, {
headers,
});

http.post(`${baseUrl}/product/1aa704c884f75f2ea79890e33ae5bbf2`, {
headers,
});

http.post(`${baseUrl}/product/0b61497dfe1258ae92323870d709acfa`, {
headers,
});

http.post(`${baseUrl}/product/b420592d82fe5793b1045134e7509686`, {
headers,
});
const baseUrl =
'https://store-api-proxy-git-feature-ntrkv-redis-storage-korohandelsgmbh.vercel.app';
const headers = {
Cookie: '_vercel_jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2Vzh6c1NKRTdLbHcxSEpjanJDSkh0UVQiLCJpYXQiOjE3Mzk4NjkwNTAsIm93bmVySWQiOiJ0ZWFtX2ZRQVF4MFA3WU1GRlVucVBPVUhVMXVDMSIsImF1ZCI6InN0b3JlLWFwaS1wcm94eS1naXQtZmVhdHVyZS1udHJrdi1yZWRpcy1zdG9yYWdlLWtvcm9oYW5kZWxzZ21iaC52ZXJjZWwuYXBwIiwidXNlcm5hbWUiOiJ0aGFsbGEta29yb2Ryb2dlcmllIiwic3ViIjoic3NvLXByb3RlY3Rpb24ifQ.wtegc8kxS95p5H62AhYOBPs_m1tKBpKxQdOenaIXeN0',
};

http.post(`${baseUrl}/product/b150799e54145f519c1dc4395b7bda0e`, {
headers,
});
const records = await getRecords();

http.post(`${baseUrl}/product/01929a39769673cdbbc975947aa08da4`, {
headers,
});

http.post(`${baseUrl}/product/01b05896b15d5d9db59ceaf0b4f0176d`, {
headers,
});
export default () => {
records.forEach((record) => {
if (!record) {
return;
}

http.post(`${baseUrl}/product/738eadd4827853a6b2a57e1c3d853f64`, {
headers,
performTest(record.method, record.slug, baseUrl, headers);
});

sleep(1);
Expand Down
Loading