Skip to content

Commit

Permalink
Add load test script
Browse files Browse the repository at this point in the history
  • Loading branch information
mesudip committed Nov 27, 2024
1 parent c8ec728 commit e9aab05
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
38 changes: 38 additions & 0 deletions integration_test/load_test/ccv-flow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
config:
# This is a test server run by team Artillery
# It's designed to be highly scalable
target: https://mainnet-ccv.cardanoapi.io
phases:
- duration: 20
arrivalRate: 1
rampTo: 5
name: Warm up phase
- duration: 20
arrivalRate: 5
rampTo: 10
name: Ramp up load
- duration: 30
arrivalRate: 4
rampTo: 30
name: Spike phase
# Load & configure a couple of useful plugins
# https://docs.art/reference/extensions
plugins:
ensure: {}
apdex: {}
metrics-by-endpoint: {}
apdex:
threshold: 100
ensure:
thresholds:
- http.response_time.p99: 500
- http.response_time.p95: 400
engines:
playwright: {}
# Path to JavaScript file that defines Playwright test functions
processor: './flows.js'
scenarios:
- engine: playwright
testFunction: visitPollFlow
- engine: playwright
testFunction: 'representativeFlow'
40 changes: 40 additions & 0 deletions integration_test/load_test/flows.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

async function representativeFlow(page) {
// Navigate to the home page
await page.goto('/');
await page.waitForLoadState('networkidle')
const randomX = Math.floor(Math.random() * 63)+1;

// Navigate to the generated URL
await page.goto(`/representatives/${randomX}`);
await page.waitForLoadState('networkidle')

}

async function visitPollFlow(page) {
// Navigate to the home page
await page.goto('/');

await page.waitForLoadState('networkidle');

// List all cards with the data-testid attribute 'poll-card-xxx'
const pollCards = await page.$$('[data-testid^="poll-card-"]'); // Select all elements starting with 'poll-card-'

if (pollCards.length === 0) {
console.log("No poll cards found!");
return;
}

// Select a random poll card
const randomIndex = Math.floor(Math.random() * pollCards.length);
const randomPollCard = pollCards[randomIndex];

// Click on the random card
await randomPollCard.click();
await page.waitForLoadState('networkidle')

// You can uncomment the next line if you need to navigate to a specific page after clicking
// await page.goto(`/representatives/${randomX}`);
}

module.exports = { representativeFlow,visitPollFlow };
56 changes: 56 additions & 0 deletions integration_test/load_test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions integration_test/load_test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"scripts": {
"start": "artillery run --output result.json ccv-flow.yml ; artillery report result.json ",
"serve": "python3 -m http.server ",
"report": "artillery report result.json"
},
"dependencies": {
"playwright": "^1.49.0"
}
}

0 comments on commit e9aab05

Please sign in to comment.