Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Loadtest (#1201)
Browse files Browse the repository at this point in the history
This PR replaces Pandora's Box load testing with K6 using xk6-ethereum extension as specified in RFC-160

A couple of scenarios are initially provided, simple transfers and ERC20 transfers, take a look to loadtest/scenarios/ for details.

Extra output details that this method can provide are being reported to the slack channel and Datadog dashboards.
  • Loading branch information
vcastellm authored Mar 7, 2023
1 parent b274b16 commit 87936ea
Show file tree
Hide file tree
Showing 10 changed files with 1,048 additions and 249 deletions.
55 changes: 21 additions & 34 deletions .github/workflows/deploy.devnet.eph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Ephemeral DevNet Workflow

on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches:
- develop

permissions:
id-token: write
Expand Down Expand Up @@ -207,45 +210,29 @@ jobs:
]
}
pandoras_box_eoa:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box EOA
needs: deploy_eph_devnet
loadtest:
uses: ./.github/workflows/loadtest.yml
name: Load Test
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
RPC_URL: ${{ secrets.LOADTEST_RPC_URL }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}
with:
runner: devnet-ephemeral
runner: devnet
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: EOA
pandoras_box_erc20:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC20
needs: deploy_eph_devnet
scenario: multiple

loadtestERC20:
needs: loadtest
uses: ./.github/workflows/loadtest.yml
name: Load Test
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
RPC_URL: ${{ secrets.LOADTEST_RPC_URL }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}
with:
runner: devnet-ephemeral
runner: devnet
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: ERC20
pandoras_box_erc721:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC721
needs: deploy_eph_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet-ephemeral
environment: devnet-ephemeral
transaction_batch: '200'
transaction_count: '10000'
mode: ERC721
scenario: multiple_ERC20
52 changes: 18 additions & 34 deletions .github/workflows/deploy.devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,45 +210,29 @@ jobs:
]
}
pandoras_box_eoa:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box EOA
needs: deploy_devnet
loadtest:
uses: ./.github/workflows/loadtest.yml
name: Load Test
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
RPC_URL: ${{ secrets.LOADTEST_RPC_URL }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: EOA
pandoras_box_erc20:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC20
needs: deploy_devnet
environment: devnet-ephemeral
scenario: multiple

loadtestERC20:
needs: loadtest
uses: ./.github/workflows/loadtest.yml
name: Load Test
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
RPC_URL: ${{ secrets.LOADTEST_RPC_URL }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: ERC20
pandoras_box_erc721:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC721
needs: deploy_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: ERC721
environment: devnet-ephemeral
scenario: multiple_ERC20
137 changes: 137 additions & 0 deletions .github/workflows/loadtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
name: Load Test
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
runner:
description: The runner to execute on
default: 'ubuntu-latest'
type: choice
options:
- ubuntu-latest
- devnet
- testnet
environment:
description: The environment to run against
required: false
type: environment
scenario:
default: 'simple'
description: The scenario to run
type: string
workflow_call:
inputs:
environment:
description: The environment to run against
type: string
required: true
runner:
required: true
type: string
description: The runner label to use
scenario:
required: true
description: The mode for the stress test
type: string
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL:
required: true
DD_API_KEY:
required: true
RPC_URL:
required: true
LOADTEST_MNEMONIC:
required: true


jobs:
run_k6:
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.18.x

- name: Checkout code
uses: actions/checkout@v3

- uses: datadog/agent-github-action@v1.3
with:
api_key: ${{ secrets.DD_API_KEY }}

- name: Install xk6
run: |
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with github.com/distribworks/xk6-ethereum@a3127e8173097e725da2890ee61782b1bea13fb7
- name: Install JQ
run: |
mkdir -p $HOME/.local/bin
curl -sLo $HOME/.local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x $HOME/.local/bin/jq
echo "$HOME/.local/bin" >> $GITHUB_PATH
- id: k6
name: Run scenario
continue-on-error: true
run: |
./k6 run --out statsd loadtest/scenarios/${{ inputs.scenario }}.js
echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT
echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT
echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT
echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT
echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT
echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT
echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT
env:
K6_STATSD_ENABLE_TAGS: true
RPC_URL: ${{ secrets.RPC_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }}

- name: Notify Slack
uses: slackapi/slack-github-action@v1.23.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "K6 Loadtest Results"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Scenario*: `${{ inputs.scenario }}`\n *Average TPS*: `${{ steps.k6.outputs.tps_avg }}`\n*Max TPS*: `${{ steps.k6.outputs.tps_max }}`\n*Transactions*: `${{ steps.k6.outputs.iterations }}`\n*Block Number*: `${{ steps.k6.outputs.block }}`\n*Time to Mine*: `${{ steps.k6.outputs.ttm }}`\n*Average Gas Used*: `${{ steps.k6.outputs.gas_avg }}`\n*Max Gas Used*: `${{ steps.k6.outputs.gas_max }}`"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Environment: `${{ inputs.environment }}`"
},
{
"type": "mrkdwn",
"text": "JSON-RPC Endpoint: ${{ secrets.RPC_URL }}"
},
{
"type": "mrkdwn",
"text": "Workflow: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Results>"
}
]
}
]
}
Loading

0 comments on commit 87936ea

Please sign in to comment.