Skip to content

Commit 39ce41b

Browse files
committed
added basic k6 load test
1 parent 4bae2c8 commit 39ce41b

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

.github/workflows/k6.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Nightly k6 Load Test
2+
3+
on:
4+
workflow_dispatch:
5+
6+
schedule:
7+
- cron: "0 2 * * *"
8+
9+
jobs:
10+
k6-load-test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
indexers:
15+
- id: heliax-indexer
16+
url: https://indexer.testnet.siuuu.click
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
- name: Run k6 test
22+
uses: grafana/run-k6-action@v1
23+
with:
24+
path: k6/main.js
25+
env:
26+
BASE_URL: ${{ matrix.indexers.url }}
27+
28+
- name: Upload k6 report
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: k6-load-test-report-${{ matrix.indexers.id }}
32+
path: k6/summary.html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ swagger-codegen.json
8989
# Ignore docker compose override files
9090
docker-compose.override*
9191
overrides
92+
k6/summary.html

k6/main.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import http from "k6/http";
2+
import { check, sleep, group } from "k6";
3+
import { randomItem } from "https://jslib.k6.io/k6-utils/1.2.0/index.js";
4+
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
5+
6+
export const options = {
7+
stages: [
8+
{ duration: "30s", target: 20 },
9+
{ duration: "1m", target: 20 },
10+
{ duration: "30s", target: 0 },
11+
],
12+
thresholds: {
13+
http_req_duration: ["p(95)<200"],
14+
http_req_failed: ["rate<0.01"],
15+
checks: ["rate==1.0"],
16+
},
17+
};
18+
19+
const BASE_URL = __ENV.BASE_URL || "https://indexer.namada.tududes.com";
20+
const ADDRESSES = [
21+
"tnam1q893l8zdx48wcdg62mf9gy4klgq9rmvg9ss48rz7",
22+
"tnam1q8w3wpa2rh9qepzyn72923lkd9aepwnsucw4wcp7",
23+
"tnam1qqec0hwnhqss75ngqgh4jrjxwgzxq6c8u5sr03mg",
24+
"tnam1qz9g9w3mnre6ravw3wrxw5mpzv4vtajy8s0rm8af",
25+
];
26+
const GOVERNANCE_PROPOSALS = [1, 10, 30];
27+
28+
export default function () {
29+
group("Health Check", function () {
30+
const res = http.get(`${BASE_URL}/health`);
31+
check(res, { "Health check is 200": (r) => r.status === 200 });
32+
});
33+
34+
sleep(1);
35+
36+
group("PoS Validator Endpoints", function () {
37+
const res = http.get(`${BASE_URL}/api/v1/pos/validator?page=1`, {
38+
tags: { name: "GetValidators" },
39+
});
40+
check(res, { "Get validators is 200": (r) => r.status === 200 });
41+
});
42+
43+
sleep(1);
44+
45+
group("PoS Rewards Endpoints", function () {
46+
const address = randomItem(ADDRESSES);
47+
const res = http.get(`${BASE_URL}/api/v1/pos/reward/${address}`, {
48+
tags: { name: "GetReward" },
49+
});
50+
check(res, { "Get reward is 200": (r) => r.status === 200 });
51+
});
52+
53+
sleep(1);
54+
55+
group("Governance proposal Endpoints", function () {
56+
const proposalId = randomItem(GOVERNANCE_PROPOSALS);
57+
const res = http.get(
58+
`${BASE_URL}/api/v1/gov/proposal/${proposalId}`,
59+
{
60+
tags: { name: "GetGovernanceProposal" },
61+
}
62+
);
63+
check(res, { "Get governance proposal is 200": (r) => r.status === 200 });
64+
});
65+
66+
sleep(1);
67+
68+
group("Governance votes Endpoints", function () {
69+
const proposalId = randomItem(GOVERNANCE_PROPOSALS);
70+
const res = http.get(
71+
`${BASE_URL}/api/v1/gov/proposal/${proposalId}/votes`,
72+
{
73+
tags: { name: "GetGovernanceVotes" },
74+
}
75+
);
76+
check(res, {
77+
"Get governance proposal votes is 200": (r) => r.status === 200,
78+
});
79+
});
80+
81+
group("Account Balance Endpoints", function () {
82+
const address = randomItem(ADDRESSES);
83+
const res = http.get(`${BASE_URL}/api/v1/account/${address}`, {
84+
tags: { name: "GetAccountBalance" },
85+
});
86+
check(res, { "Get account balance is 200": (r) => r.status === 200 });
87+
});
88+
89+
sleep(1);
90+
91+
group("Masp Aggregated Endpoints", function () {
92+
const res = http.get(`${BASE_URL}/api/v1/masp/aggregates`, {
93+
tags: { name: "GetMaspAggregated" },
94+
});
95+
check(res, { "Get masp aggregated is 200": (r) => r.status === 200 });
96+
});
97+
}
98+
99+
export function handleSummary(data) {
100+
return {
101+
"summary.html": htmlReport(data),
102+
};
103+
}

0 commit comments

Comments
 (0)