This repository contains k6 spike tests for three marketing endpoints:
- campaigns list: GET
/marketing/campaigns - campaign info: GET
/marketing/campaign - reward capacity: GET
/marketing/campaign/reward/capacity
Each test writes individual summary reports to the reports/ directory with API-specific names.
- A system-installed k6 (see
https://k6.io/docs/getting-started/installation/) - A valid
ACCESS_TOKEN(auth scheme can beToken)
If your shell shows command not found: k6, run the bundled binary directly (via ./k6 symlink or absolute path) or add it to your PATH for the session.
A sample env file is provided at env.example. Key variables:
- BASE_URL: default
https://testnetapiv2.nobitex.ir - ACCESS_TOKEN: auth token value
- AUTH_SCHEME:
Token(default) forAuthorizationheader - SPIKE_MAX_VUS, RAMP_UP_S, HOLD_S, RAMP_DOWN_S: traffic shaping
- P95_MS: p95 latency threshold (ms)
export $(grep -v '^#' env.example | xargs)All commands below work with either k6 on your PATH or the absolute binary path:
/Users/apple/Downloads/loadTest/k6-v1.2.3-macos-arm64/k6.
Quick run (matches local usage):
./k6 run \
-e BASE_URL=https://testnetapiv2.nobitex.ir \
-e ACCESS_TOKEN='ACTUAL_TOKEN_HERE' \
-e UTM_CAMPAIGN='multistep_payout:base:crypto_champions:public' \
-e UTM_SOURCE='snapp' \
-e UTM_MEDIUM='banner' \
-e EXPECT_RATE_LIMIT=false \
-e DEBUG_LOG=false \
spike/campaignInfo_spike_test.js- campaigns list
k6 run /Users/apple/Downloads/loadTest/spike/campaignsList_spike_test.js \
-e BASE_URL="$BASE_URL" \
-e ACCESS_TOKEN="$ACCESS_TOKEN" \
-e AUTH_SCHEME="${AUTH_SCHEME:-Token}"- campaign info
k6 run /Users/apple/Downloads/loadTest/spike/campaignInfo_spike_test.js \
-e BASE_URL="$BASE_URL" \
-e ACCESS_TOKEN="$ACCESS_TOKEN" \
-e UTM_CAMPAIGN="${UTM_CAMPAIGN:-multistep_payout:base:crypto_champions:public}" \
-e UTM_SOURCE="${UTM_SOURCE:-snapp}" \
-e UTM_MEDIUM="${UTM_MEDIUM:-banner}"Note: campaignInfo_spike_test.js now honors AUTH_SCHEME via env; set to Bearer if needed.
- reward capacity
k6 run /Users/apple/Downloads/loadTest/spike/rewardCapacity_spike_test.js \
-e BASE_URL="$BASE_URL" \
-e ACCESS_TOKEN="$ACCESS_TOKEN" \
-e AUTH_SCHEME="${AUTH_SCHEME:-Token}"Note: UTM parameters in this script are also configurable via env.
Outputs: Individual reports are generated in the reports/ directory:
reports/campaignsList_summary.htmlandreports/campaignsList_summary.jsonreports/campaignInfo_summary.htmlandreports/campaignInfo_summary.jsonreports/rewardCapacity_summary.htmlandreports/rewardCapacity_summary.json
Use the generic breakpoint test to find the capacity breakpoint per API using a ramped arrival-rate and thresholds on p95 latency and error rate. Reports are generated like the other tests.
Run example (campaign endpoint):
./k6 run spike/breakpoint_test.js --duration 20s \
-e TEST_NAME=campaign \
-e ENDPOINT=/marketing/campaign \
-e QUERY='utmCampaign=multistep_payout:base:crypto_champions_2:public&utmSource=snapp&utmMedium=banner'Key env vars:
TEST_NAMElogical name for report files and metric tagsMETHODGET (default), POST, PUT, PATCH, DELETEENDPOINTAPI path, e.g./marketing/campaignQUERYraw query string (will be URI-encoded)PAYLOAD,CONTENT_TYPEfor non-GET methods- Thresholds:
P95_SLA_MS(default 500),ERROR_RATE_MAX(default 0.01) - Ramp schedule:
RAMP_START,RAMP_PEAK,RAMP_STEPS,STEP_SECONDS
Reports:
reports/breakpoint_<TEST_NAME>_summary.htmlreports/breakpoint_<TEST_NAME>_summary.json
You can also run per-API wrappers in breakpoint/ that preset sensible defaults:
- Campaigns List breakpoint:
./k6 run breakpoint/campaignsList_breakpoint_test.js --duration 20s- Campaign Info breakpoint:
./k6 run breakpoint/campaignInfo_breakpoint_test.js --duration 20s- Reward Capacity breakpoint:
./k6 run breakpoint/rewardCapacity_breakpoint_test.js --duration 20sYou can still override any env var (e.g., token, BASE_URL, ramp settings) via -e VAR=value.
To run all tests at once and generate all reports:
./run_all_tests.sh/loadTest
│
├── breakpoint/
│ ├── discover_breakpoint_test.js
│ ├── campaign_breakpoint_test.js
│ ├── campaignInfo_breakpoint_test.js
│ └── rewardCapacity_breakpoint_test.js
│
├── spike/
│ ├── campaignInfo_spike_test.js
│ ├── campaignsList_spike_test.js
│ ├── breakpoint_test.js
│ └── rewardCapacity_spike_test.js
│
├── reports/
│ ├── campaignsList_summary.html
│ ├── campaignsList_summary.json
│ ├── campaignInfo_summary.html
│ ├── campaignInfo_summary.json
│ ├── rewardCapacity_summary.html
│ ├── rewardCapacity_summary.json
│ ├── breakpoint_campaign_summary.html
│ └── breakpoint_campaign_summary.json
│
├── env.example
├── k6-v1.2.3-macos-arm64/
├── k6-v1.2.3-macos-arm64.zip
├── run_all_tests.sh
└── README.md
- Add CI job to run a small smoke (e.g., 1 VU, 3 iterations) on PRs.
- Consider centralizing shared helpers (headers, jitter, summary) in a module.
- Set
ACCESS_TOKENfor endpoints requiring auth. - If 429 rate limiting is expected, adjust thresholds accordingly.
- Use the HTML/JSON reports in the
reports/directory to monitor p95, status distribution, and error rates for each API.