Skip to content

Commit

Permalink
feat: DEVOPS-1833 jmeter test pipeline (#2258)
Browse files Browse the repository at this point in the history
* feat: DEVOPS-1833 jmeter test pipeline

* feat: DEVOPS-1833 jmeter test pipeline

* feat: DEVOPS-1833 jmeter test pipeline

* feat: DEVOPS-1833 jmeter test pipeline
  • Loading branch information
pavlops authored Feb 4, 2025
1 parent 54bf5dc commit 47a813b
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 0 deletions.
131 changes: 131 additions & 0 deletions .github/workflows/test_performance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: "Jmeter tests"

on:
workflow_dispatch:
inputs:
network:
description: "Network"
type: choice
options:
- "devnet"
- "infratest"
- "perftest"
- "protomainnet"
- "prototestnet"
- "richard"
- "uccbtest"
required: false
default: "prototestnet"
target_host:
description: "Target host"
type: string
required: false
default: "api.zq2-prototestnet.zilliqa.com"
target_port:
description: "Target port"
type: string
required: false
default: "443"
protocol:
description: "Protocol (http/https)"
type: choice
options:
- "https"
- "http"
required: false
default: "https"
json_params:
description: "JSON RPC parameters"
type: string
required: false
default: '{"id":"1","jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x${__RandomString(5,abcdef0123456789)}",false]}'
response_timeout:
description: "Response timeout in milliseconds"
type: number
required: false
default: 10000
connect_timeout:
description: "Connection timeout in milliseconds"
type: number
required: false
default: 300
threads:
description: "Number of concurrent threads"
type: number
required: false
default: 20
duration:
description: "Test duration in seconds"
type: number
required: false
default: 60

jobs:
jmeter-test:
permissions:
id-token: write
contents: write
name: Jmeter test
runs-on: self-hosted
container:
image: alpine/jmeter:5.6
if: github.actor != 'dependabot[bot]'
timeout-minutes: 1440
env:
TEST_ID: "jmeter-test-zq2-${{ github.run_id }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install dependencies
run: apk add --update python3 curl which bash

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'

- name: Run tests
working-directory: infra/jmeter
run: |
export TARGET_HOST=${{ github.event.inputs.target_host || 'query.zq2-prototestnet.zilliqa.com' }}
export TARGET_PORT=${{ github.event.inputs.target_port || '443' }}
export PROTOCOL=${{ github.event.inputs.protocol || 'https' }}
export JSON_PARAMS='${{ github.event.inputs.json_params || '{"id":"1","jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x${__RandomString(5,abcdef0123456789)}",false]}' }}'
export RESPONSE_TIMEOUT=${{ github.event.inputs.response_timeout || 10000 }}
export CONNECT_TIMEOUT=${{ github.event.inputs.connect_timeout || 300 }}
export THREADS=${{ github.event.inputs.threads || 20 }}
export DURATION=${{ github.event.inputs.duration || 60 }}
jmeter -n -e -Dlog_level.jmeter=DEBUG \
-JTARGET_HOST=${TARGET_HOST} \
-JTARGET_PORT=${TARGET_PORT} \
-JPROTOCOL=${PROTOCOL} \
-JJSON_PARAMS=${JSON_PARAMS} \
-JTHREADS=${THREADS} \
-JDURATION=${DURATION} \
-JCONNECT_TIMEOUT=${CONNECT_TIMEOUT} \
-JRESPONSE_TIMEOUT=${RESPONSE_TIMEOUT} \
-t jmeter-plan-template.jmx \
-l ${TEST_ID}.jtl \
-o ${TEST_ID}
echo "Test results for ${TEST_ID}:"
cat "${TEST_ID}.jtl"
- name: "Configure GCP Credentials"
id: google-auth
uses: "google-github-actions/auth@v2"
with:
token_format: "access_token"
workload_identity_provider: ${{ secrets.GCP_PRD_GITHUB_WIF }}
service_account: "${{ secrets.GCP_PRD_GITHUB_SA_TESTING }}"
create_credentials_file: true

- name: Upload reports
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
process_gcloudignore: false
path: "infra/jmeter/${{ env.TEST_ID }}"
destination: "zq2-${{ github.event.inputs.network || 'prototestnet' }}-performance-tests"
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Then you can install a suitable Solc version by executing:
svm install <solc version>
```

### Tests with JMeter

JMeter for performance and load tests is integrated in the Github Action pipelines in `.github/workflows/test_performance.yaml` and can be manually executed from the Github console with custom and default parameters. The test executions are restricted to users of the Zilliqa organization.

## Running benchmarks

Benchmarks can be run with `cargo bench --package zilliqa --bench it`.
Expand All @@ -104,6 +108,23 @@ Or via individual modules using eg.
RUST_LOG=debug,sled=info,zilliqa::scilla=trace
```

## Observability

### OpenTelemetry

OpenTelemetry metrics from the Zilliqa nodes container are available when the OTLP collector endpoint is defined in the configuration.

```yaml
otlp_collector_endpoint = "http://otel-collector:4317"
```

There is a docker-compose project that includes the OpenTelemetry configuration and tech stack that can be run in local environment for testing purposes:

```bash
cd infra/opentelemetry
docker-compose up
```

## `rustfmt`

We use a couple of nightly-only rustfmt features. The easiest way to get these is:
Expand Down
201 changes: 201 additions & 0 deletions infra/jmeter/jmeter-plan-template.jmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan">
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Scenario 1">
<stringProp name="TestPlan.comments">Virtual Users Running Scenario 1.
Make test last 1 minute (see Scheduler)</stringProp>
<intProp name="ThreadGroup.num_threads">150</intProp>
<intProp name="ThreadGroup.ramp_time">10</intProp>
<stringProp name="ThreadGroup.duration">${DURATION}</stringProp>
<longProp name="ThreadGroup.delay">0</longProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller">
<intProp name="LoopController.loops">-1</intProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
</ThreadGroup>
<hashTree>
<ConfigTestElement guiclass="HttpDefaultsGui" testclass="ConfigTestElement" testname="HTTP Request Defaults">
<stringProp name="TestPlan.comments">Notice Timeouts:
Read to 1s
Connect to 300ms</stringProp>
<stringProp name="HTTPSampler.connect_timeout">${CONNECT_TIMEOUT}</stringProp>
<stringProp name="HTTPSampler.response_timeout">${RESPONSE_TIMEOUT}</stringProp>
<stringProp name="HTTPSampler.domain">${TARGET_HOST}</stringProp>
<stringProp name="HTTPSampler.port">${TARGET_PORT}</stringProp>
<stringProp name="HTTPSampler.protocol">${PROTOCOL}</stringProp>
<stringProp name="HTTPSampler.path">${TARGET_PATH}</stringProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
</ConfigTestElement>
<hashTree/>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="ZQ2 load tests">
<stringProp name="HTTPSampler.domain">api.zq2-prototestnet.zilliqa.com</stringProp>
<stringProp name="HTTPSampler.port">443</stringProp>
<stringProp name="HTTPSampler.protocol">https</stringProp>
<stringProp name="HTTPSampler.path">/</stringProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{&quot;id&quot;:&quot;1&quot;,&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;method&quot;:&quot;eth_getBlockByNumber&quot;,&quot;params&quot;:[&quot;0x${__RandomString(5,abcdef0123456789)}&quot;,false]}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
</HTTPSamplerProxy>
<hashTree>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager">
<collectionProp name="HeaderManager.headers">
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
<stringProp name="Header.value">application/json</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree/>
</hashTree>
<TestAction guiclass="TestActionGui" testclass="TestAction" testname="ThinkTime1s" enabled="true">
<intProp name="ActionProcessor.action">1</intProp>
<intProp name="ActionProcessor.target">0</intProp>
<stringProp name="ActionProcessor.duration">0</stringProp>
</TestAction>
<hashTree>
<UniformRandomTimer guiclass="UniformRandomTimerGui" testclass="UniformRandomTimer" testname="URT" enabled="true">
<stringProp name="ConstantTimer.delay">0</stringProp>
<stringProp name="RandomTimer.range">0</stringProp>
</UniformRandomTimer>
<hashTree/>
</hashTree>
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments">
<elementProp name="TARGET_HOST" elementType="Argument">
<stringProp name="Argument.name">TARGET_HOST</stringProp>
<stringProp name="Argument.value">${__P(TARGET_HOST,query.zq2-prototestnet.zilliqa.com)}</stringProp>
<stringProp name="Argument.desc">target server domain/IP for testing</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="TARGET_PORT" elementType="Argument">
<stringProp name="Argument.name">TARGET_PORT</stringProp>
<stringProp name="Argument.value">${__P(TARGET_PORT,443)}</stringProp>
<stringProp name="Argument.desc">target port on TARGET_HOST for testing</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="PROTOCOL" elementType="Argument">
<stringProp name="Argument.name">PROTOCOL</stringProp>
<stringProp name="Argument.value">${__P(PROTOCOL,https)}</stringProp>
<stringProp name="Argument.desc">Protocol of the target host</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="JSON_PARAMS" elementType="Argument">
<stringProp name="Argument.name">JSON_PARAMS</stringProp>
<stringProp name="Argument.value">${__P(JSON_PARAMS)}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="THREADS" elementType="Argument">
<stringProp name="Argument.name">THREADS</stringProp>
<stringProp name="Argument.value">${__P(THREADS,20)}</stringProp>
<stringProp name="Argument.desc">Number of concurrent threads</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="DURATION" elementType="Argument">
<stringProp name="Argument.name">DURATION</stringProp>
<stringProp name="Argument.value">${__P(DURATION,60)}</stringProp>
<stringProp name="Argument.desc">Number of samples to run</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="CONNECT_TIMEOUT" elementType="Argument">
<stringProp name="Argument.name">CONNECT_TIMEOUT</stringProp>
<stringProp name="Argument.value">${__P(CONNECT_TIMEOUT,300)}</stringProp>
<stringProp name="Argument.desc">Connect timeout</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="RESPONSE_TIMEOUT" elementType="Argument">
<stringProp name="Argument.name">RESPONSE_TIMEOUT</stringProp>
<stringProp name="Argument.value">${__P(RESPONSE_TIMEOUT,10000)}</stringProp>
<stringProp name="Argument.desc">Response timeout</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
<stringProp name="TestPlan.comments">Example using UDV for symbolic names test target and response to test</stringProp>
</Arguments>
<hashTree/>
<ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="false">
<intProp name="calcMode">0</intProp>
<doubleProp>
<name>throughput</name>
<value>60.0</value>
<savedValue>0.0</savedValue>
</doubleProp>
</ConstantThroughputTimer>
<hashTree/>
<PreciseThroughputTimer guiclass="TestBeanGUI" testclass="PreciseThroughputTimer" testname="Precise Throughput Timer">
<doubleProp>
<name>allowedThroughputSurplus</name>
<value>1.0</value>
<savedValue>0.0</savedValue>
</doubleProp>
<intProp name="exactLimit">10000</intProp>
<stringProp name="throughput">${THREADS}</stringProp>
<intProp name="throughputPeriod">1</intProp>
<stringProp name="duration">${DURATION}</stringProp>
<intProp name="batchSize">1</intProp>
<intProp name="batchThreadDelay">0</intProp>
<longProp name="randomSeed">0</longProp>
</PreciseThroughputTimer>
<hashTree/>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Summary Report">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>false</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="TestPlan.comments">For scripting only</stringProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>
Loading

0 comments on commit 47a813b

Please sign in to comment.