Skip to content

Commit

Permalink
Automate load testting (#642)
Browse files Browse the repository at this point in the history
* Automate load tetsting

* update node version
  • Loading branch information
ausias-armesto authored May 2, 2024
1 parent ab22949 commit e07901a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/load-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,31 @@ jobs:
with:
python-version: '3.10'


- name: Set up Google Cloud Credentials
uses: google-github-actions/auth@v1
with:
token_format: "access_token"
credentials_json: ${{ secrets.GCP_SA_TERRAFORM_JSON }}

- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: hopr-staging
install_components: beta

- name: Get credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: cluster-staging
location: europe-west3
project_id: hopr-staging

- name: Setup NodeJs
uses: actions/setup-node@v3
with:
node-version: 20

- name: Run Load test
run: |
pip install -r requirements.txt
Expand Down
9 changes: 2 additions & 7 deletions devkit/loadtesting-k6/k6.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,10 @@ spec:
- name: WALLET_TYPE
value: {{ walletType }}
- name: RPC_SERVER_URL
value: http://rpc-server-one-hop.rpch.svc:45750
value: http://phttp-server.phttp.svc:45750
- name: K6_PROMETHEUS_RW_SERVER_URL
value: https://prometheus.prod.hoprtech.net/api/v1/write
value: http://kube-prometheus-stack-prometheus.monitoring.svc:9090/api/v1/write
- name: K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM
value: 'true'
- name: K6_OUT
value: xk6-prometheus-rw
# envFrom:
# - secretRef:
# name: rpc-server


10 changes: 5 additions & 5 deletions devkit/loadtesting-k6/src/rpc-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { JsonRpcMethodCounters } from './wallet/mock-wallet.js';
import { buildWallet } from './wallet/index.js';

// get values from env
const url = __ENV.RPC_SERVER_URL;
const testType = __ENV.TEST_TYPE as OptionTypes;
const walletType = __ENV.WALLET_TYPE as WalletTypes;
const url = __ENV.RPC_SERVER_URL || 'http://localhost:45750';
const testType = __ENV.TEST_TYPE || 'SMOKE';
const walletType = __ENV.WALLET_TYPE || 'METAMASK';

// get the test option
console.log(`Starting TestType '${testType}' for wallet type '${walletType}' against '${url}'`);
export const options = getOption(testType);
export const options = getOption(testType as OptionTypes);

// create metrics counter
const counters: JsonRpcMethodCounters = instantiatePayloadCounters();

// Simulated user behavior
export default function (): void {
const wallet = buildWallet(walletType, url);
const wallet = buildWallet(walletType as WalletTypes, url);
wallet.sendRpcCalls(counters);
}

0 comments on commit e07901a

Please sign in to comment.