Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test preload cache #1327

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b0355a8
Change table
MogageNicolae Aug 20, 2024
1edf2de
Change wrong closing tag for table
MogageNicolae Aug 20, 2024
d2dfd66
Refactor generateTable function
MogageNicolae Aug 20, 2024
497ed24
Add more endpoints
MogageNicolae Aug 21, 2024
c6dd914
Fix wrong name for Trends
MogageNicolae Aug 21, 2024
31e0810
Merge pull request #1314 from multiversx/SERVICES-2549-test-integrate…
MogageNicolae Aug 21, 2024
53e3508
Add empty line at end of file
MogageNicolae Aug 21, 2024
9c7b8fe
Fix wrong trend calls
MogageNicolae Aug 21, 2024
92a4f15
Merge pull request #1315 from multiversx/SERVICES-2549-test-integrata…
MogageNicolae Aug 21, 2024
4c334eb
Merge branch 'development' into SERVICES-2549-integrate-k-6-s-in-api
tanghel Sep 10, 2024
147e2b6
Changed actions/upload-artifacts from v2 to v3
GuticaStefan Sep 10, 2024
6c16703
changed actions/download-artifact from v2 to v3
GuticaStefan Sep 10, 2024
a2d9167
Clear docker images caching in workflow
GuticaStefan Sep 10, 2024
833addf
removed unncessary clear docker images cache
GuticaStefan Sep 10, 2024
5d26ad3
Update load-tests.yml
cfaur09 Sep 10, 2024
bdc2c81
Update load-test.yml
GuticaStefan Sep 10, 2024
061a5c7
Merge branch 'development' into SERVICES-2549-integrate-k-6-s-in-api
cfaur09 Sep 10, 2024
f139cb7
updated preload.js path
GuticaStefan Sep 10, 2024
88cf4a9
update path for preload.js
GuticaStefan Sep 10, 2024
5b041bb
test
GuticaStefan Sep 10, 2024
a1deceb
disable preload cache
cfaur09 Sep 10, 2024
609e11d
revert ref base
cfaur09 Sep 10, 2024
4ad3f5d
add tags
GuticaStefan Sep 10, 2024
ae63fd2
add preload cache
GuticaStefan Sep 10, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
run: k6 run ./k6/script.js

- name: Upload result file for base branch
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: base-results
path: k6/output/summary.json
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
run: k6 run ./k6/script.js

- name: Upload result file for head branch
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: head-results
path: k6/output/summary.json
Expand All @@ -131,9 +131,9 @@ jobs:
needs: [test-base, test-head]
steps:
- uses: actions/checkout@v2

- name: Download all artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: artifacts

Expand Down
2 changes: 1 addition & 1 deletion config/config.devnet-old.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ urls:
nftThumbnails: 'https://devnet-old-media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'devnet-old-socket-fra.elrond.com'
socket: 'devnet-socket-api.multiversx.com'
maiarId: 'https://devnet-old-id-api.multiversx.com'
indexer:
type: 'elastic'
Expand Down
14 changes: 10 additions & 4 deletions config/config.devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ features:
hitsThreshold: 100
ttl: 12
transactionPool:
enabled: true
enabled: false
transactionPoolWarmer:
enabled: true
enabled: false
cronExpression: '*/5 * * * * *'
ttlInSeconds: 60
updateCollectionExtraDetails:
Expand Down Expand Up @@ -92,8 +92,14 @@ features:
nftQueueName: 'api-process-nfts'
deadLetterQueueName: 'api-process-nfts-dlq'
tps:
enabled: true
enabled: false
maxLookBehindNonces: 100
nodesFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
tokensFetch:
enabled: true
serviceUrl: 'https://devnet-api.multiversx.com'
image:
width: 600
height: 600
Expand All @@ -118,7 +124,7 @@ urls:
nftThumbnails: 'https://devnet-media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'devnet-socket-fra.elrond.com'
socket: 'devnet-socket-api.multiversx.com'
maiarId: 'https://devnet-id-api.multiversx.com'
indexer:
type: 'elastic'
Expand Down
14 changes: 10 additions & 4 deletions config/config.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ features:
hitsThreshold: 100
ttl: 12
transactionPool:
enabled: true
enabled: false
transactionPoolWarmer:
enabled: true
enabled: false
cronExpression: '*/5 * * * * *'
ttlInSeconds: 60
updateCollectionExtraDetails:
Expand Down Expand Up @@ -96,8 +96,14 @@ features:
nftQueueName: 'api-process-nfts'
deadLetterQueueName: 'api-process-nfts-dlq'
tps:
enabled: false
maxLookBehindNonces: 100
nodesFetch:
enabled: true
serviceUrl: 'https://api.multiversx.com'
tokensFetch:
enabled: true
maxLookBehindNonces: 100
serviceUrl: 'https://api.multiversx.com'
image:
width: 600
height: 600
Expand All @@ -122,7 +128,7 @@ urls:
nftThumbnails: 'https://media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'socket-fra.elrond.com'
socket: 'socket-api-fra.multiversx.com'
maiarId: 'https://id-api.multiversx.com'
indexer:
type: 'elastic'
Expand Down
14 changes: 10 additions & 4 deletions config/config.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ features:
hitsThreshold: 100
ttl: 12
transactionPool:
enabled: true
enabled: false
transactionPoolWarmer:
enabled: true
enabled: false
cronExpression: '*/5 * * * * *'
ttlInSeconds: 60
updateCollectionExtraDetails:
Expand Down Expand Up @@ -95,8 +95,14 @@ features:
nftQueueName: 'api-process-nfts'
deadLetterQueueName: 'api-process-nfts-dlq'
tps:
enabled: true
enabled: false
maxLookBehindNonces: 100
nodesFetch:
enabled: true
serviceUrl: 'https://testnet-api.multiversx.com'
tokensFetch:
enabled: true
serviceUrl: 'https://testnet-api.multiversx.com'
image:
width: 600
height: 600
Expand All @@ -121,7 +127,7 @@ urls:
nftThumbnails: 'https://testnet-media.elrond.com/nfts/thumbnail'
tmp: '/tmp'
ipfs: 'https://ipfs.io/ipfs'
socket: 'testnet-socket-fra.elrond.com'
socket: 'testnet-socket-api.multiversx.com'
maiarId: 'https://testnet-id-api.multiversx.com'
database:
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=api

mongodbdatabase:
image: mongo:latest
environment:
Expand Down
27 changes: 19 additions & 8 deletions k6/compare-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ function extractMetrics(metrics) {
}

function generateTable(baseCommitHash, baseData, targetCommitHash, targetData) {
const headers = ['Avg', 'Max', '90', '95'];
let table = `k6 load testing comparison.\nBase Commit Hash: ${baseCommitHash}\nTarget Commit Hash: ${targetCommitHash}\n\n`;
table += '| Metric | Base | Target | Diff |\n';
table += '| ------ | ---- | ------ | ---- |\n';
table += '<table><tr> \
<th rowspan="2">Metric</th> \
<th colspan="4">Base</th> \
<th colspan="4">Target</th> \
<th colspan="4">Diff</th> \
</tr><tr> '
for (let i = 0; i < 3; i++) {
headers.forEach(header => {
table += `<th>${header}</th>`;
});
}
table += '</tr>';

for (const key of Object.keys(baseData)) {
if (key === 'Test Run Duration') {
Expand All @@ -71,16 +82,16 @@ function generateTable(baseCommitHash, baseData, targetCommitHash, targetData) {
const p90Color = getColor(baseP90, targetP90);
const p95Color = getColor(baseP95, targetP95);

table += `| **${key}** | | |\n`;
table += `| - Average Response Time | ${baseAvg.toFixed(2)} ms | ${targetAvg.toFixed(2)} ms | ${avgDiff} ${avgColor} |\n`;
table += `| - Max Response Time | ${baseMax.toFixed(2)} ms | ${targetMax.toFixed(2)} ms | ${maxDiff} ${maxColor} |\n`;
table += `| - 90th Percentile | ${baseP90.toFixed(2)} ms | ${targetP90.toFixed(2)} ms | ${p90Diff} ${p90Color} |\n`;
table += `| - 95th Percentile | ${baseP95.toFixed(2)} ms | ${targetP95.toFixed(2)} ms | ${p95Diff} ${p95Color} |\n`;
table += `<tr><td><b>${key}</b></td>`;
table += `<td>${baseAvg.toFixed(2)}</td><td>${baseMax.toFixed(2)}</td><td>${baseP90.toFixed(2)}</td><td>${baseP95.toFixed(2)}</td>`;
table += `<td>${targetAvg.toFixed(2)}</td><td>${targetMax.toFixed(2)}</td><td>${targetP90.toFixed(2)}</td><td>${targetP95.toFixed(2)}</td>`;
table += `<td>${avgDiff} ${avgColor}</td><td>${maxDiff} ${maxColor}</td><td>${p90Diff} ${p90Color}</td><td>${p95Diff} ${p95Color}</td></tr>`;
}

const baseDuration = baseData['Test Run Duration'].toFixed(2);
const targetDuration = targetData['Test Run Duration'].toFixed(2);
table += `| **Test Run Duration** | ${baseDuration} ms | ${targetDuration} ms | |\n`;
table += `<tr><td><b>Test Run Duration</b></td><td colspan="4">${baseDuration}</td><td colspan="4">${targetDuration}</td><td colspan="4"></td></tr></table>`;
table += '\n\nLegend: Avg - Average Response Time, Max - Maximum Response Time, 90 - 90th Percentile, 95 - 95th Percentile\nAll times are in milliseconds.\n';

return table;
}
Expand Down
2 changes: 2 additions & 0 deletions k6/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export default function preloadCache() {
http.get(`${BASE_URL}/tokens?size=${numberofTokens}`);
const numberofNodes = http.get(`${BASE_URL}/nodes/count`);
http.get(`${BASE_URL}/nodes?size=${numberofNodes}`);
const numberofTags = http.get(`${BASE_URL}/tags/count`);
http.get(`${BASE_URL}/tags?size=${numberofTags}`);
}
97 changes: 76 additions & 21 deletions k6/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,96 @@ import { Trend } from 'k6/metrics';

const BASE_URL = 'http://localhost:3001';

const tokensApiCallTrened = new Trend('tokens_http_req_duration', true);
const nodesApiCallTrened = new Trend('nodes_http_req_duration', true);
const accountsApiCallTrend = new Trend('accounts_http_req_duration', true);
const blocksApiCallTrend = new Trend('blocks_http_req_duration', true);
const mexPairsApiCallTrend = new Trend('mex_pairs_http_req_duration', true);
const mexTokensApiCallTrend = new Trend('mex_tokens_http_req_duration', true);
const mexFarmsApiCallTrend = new Trend('mex_farms_http_req_duration', true);
const nodesApiCallTrend = new Trend('nodes_http_req_duration', true);
const nodesAuctionsApiCallTrend = new Trend('nodes_auctions_http_req_duration', true);
const poolApiCallTrend = new Trend('pool_http_req_duration', true);
const tokensApiCallTrend = new Trend('tokens_http_req_duration', true);
const transactionsApiCallTrend = new Trend('transactions_http_req_duration', true);


function getScenarioDict(functionName) {
return {
executor: 'constant-vus',
vus: 10,
duration: '1m',
gracefulStop: '0s',
exec: functionName,
}
}

export const options = {
scenarios: {
tokens: {
executor: 'constant-vus',
vus: 10,
duration: '1m',
gracefulStop: '0s',
exec: 'tokens',
},
nodes: {
executor: 'constant-vus',
vus: 10,
duration: '1m',
gracefulStop: '0s',
exec: 'nodes',
},
accounts: getScenarioDict('accounts'),
blocks: getScenarioDict('blocks'),
mexPairs: getScenarioDict('mexPairs'),
mexTokens: getScenarioDict('mexTokens'),
mexFarms: getScenarioDict('mexFarms'),
nodes: getScenarioDict('nodes'),
nodesAuctions: getScenarioDict('nodesAuctions'),
pool: getScenarioDict('pool'),
tokens: getScenarioDict('tokens'),
transactions: getScenarioDict('transactions'),
},
discardResponseBodies: true,
};

export function tokens() {
const response = http.get(`${BASE_URL}/tokens`);
tokensApiCallTrened.add(response.timings.duration);
export function accounts() {
const response = http.get(`${BASE_URL}/accounts`);
accountsApiCallTrend.add(response.timings.duration);
}

export function blocks() {
const response = http.get(`${BASE_URL}/blocks`);
blocksApiCallTrend.add(response.timings.duration);
}

export function mexPairs() {
const response = http.get(`${BASE_URL}/mex/pairs`);
mexPairsApiCallTrend.add(response.timings.duration);
}

export function mexTokens() {
const response = http.get(`${BASE_URL}/mex/tokens`);
mexTokensApiCallTrend.add(response.timings.duration);
}

export function mexFarms() {
const response = http.get(`${BASE_URL}/mex/farms`);
mexFarmsApiCallTrend.add(response.timings.duration);
}

export function nodes() {
const response = http.get(`${BASE_URL}/nodes`);
nodesApiCallTrened.add(response.timings.duration);
nodesApiCallTrend.add(response.timings.duration);
}

export function nodesAuctions() {
const response = http.get(`${BASE_URL}/nodes/auctions`);
nodesAuctionsApiCallTrend.add(response.timings.duration);
}

export function pool() {
const response = http.get(`${BASE_URL}/pool`);
poolApiCallTrend.add(response.timings.duration);
}

export function tokens() {
const response = http.get(`${BASE_URL}/tokens`);
tokensApiCallTrend.add(response.timings.duration);
}

export function transactions() {
const response = http.get(`${BASE_URL}/transactions`);
transactionsApiCallTrend.add(response.timings.duration);
}

export function handleSummary(data) {
return {
'k6/output/summary.json': JSON.stringify(data),
};
}
}
Loading
Loading