Skip to content

Add load tests as env + pod #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions environments/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ drop:
enabled: false
qkm:
url: https://qa-qkm.ops.consensys.net
nodeSelector:
enabled: false
39 changes: 39 additions & 0 deletions environments/load.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
orchestrate:
replicaCount: 3
global:
environment:
MULTI_TENANCY_ENABLED: true
DB_DATABASE: orchestrate_load
DB_POOLSIZE: 750
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this value being customizable?

environmentSecrets:
AUTH_API_KEY: with-key

observability:
enabled: true

drop:
enabled: false

kafka:
enabled: false

postgresql:
enabled: false
tls:
enabled: true
postgresqlHA:
enabled: false

vault:
enabled: false
replicaCount: 0

qkm:
url: https://staging-qkm.ops.consensys.net
vault:
agents: {}

nodeSelector:
enabled: true
value:
benchmark-orchestrate: "true"
5 changes: 4 additions & 1 deletion environments/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ drop:
enabled: true

qkm:
url: https://qa-qkm.ops.consensys.net
url: https://qa-qkm.ops.consensys.net

nodeSelector:
enabled: false
5 changes: 4 additions & 1 deletion environments/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ vault:
replicaCount: 3

qkm:
url: https://staging-qkm.ops.consensys.net
url: https://staging-qkm.ops.consensys.net

nodeSelector:
enabled: false
41 changes: 41 additions & 0 deletions loadTests/Counter-formatted-abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "by",
"type": "uint256"
}
],
"name": "Incremented",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "increment",
"contractTag": "v1.1.0",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
],
"name": "increment",
"bytecode": "0x608060405234801561001057600080fd5b5061023c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80637cf5dab014610030575b600080fd5b61004a600480360381019061004591906100b5565b61004c565b005b8060008082825461005d9190610129565b925050819055507f38ac789ed44572701765277c4d0970f2db1c1a571ed39e84358095ae4eaa54203382604051610095929190610100565b60405180910390a150565b6000813590506100af816101ef565b92915050565b6000602082840312156100cb576100ca6101ea565b5b60006100d9848285016100a0565b91505092915050565b6100eb8161017f565b82525050565b6100fa816101b1565b82525050565b600060408201905061011560008301856100e2565b61012260208301846100f1565b9392505050565b6000610134826101b1565b915061013f836101b1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610174576101736101bb565b5b828201905092915050565b600061018a82610191565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6101f8816101b1565b811461020357600080fd5b5056fea2646970667358221220c60e80c05b07a4cdf0613322321a43f5f630166032ec9b866ffe52ddff573c1264736f6c63430008070033",
"deployedBytecode": "0x608060405234801561001057600080fd5b5061023c806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80637cf5dab014610030575b600080fd5b61004a600480360381019061004591906100b5565b61004c565b005b8060008082825461005d9190610129565b925050819055507f38ac789ed44572701765277c4d0970f2db1c1a571ed39e84358095ae4eaa54203382604051610095929190610100565b60405180910390a150565b6000813590506100af816101ef565b92915050565b6000602082840312156100cb576100ca6101ea565b5b60006100d9848285016100a0565b91505092915050565b6100eb8161017f565b82525050565b6100fa816101b1565b82525050565b600060408201905061011560008301856100e2565b61012260208301846100f1565b9392505050565b6000610134826101b1565b915061013f836101b1565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115610174576101736101bb565b5b828201905092915050565b600061018a82610191565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6101f8816101b1565b811461020357600080fd5b5056fea2646970667358221220c60e80c05b07a4cdf0613322321a43f5f630166032ec9b866ffe52ddff573c1264736f6c63430008070033",
"tag": "v1.0.0"
}
19 changes: 19 additions & 0 deletions loadTests/Counter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pragma solidity ^0.6.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need solidity source code


/**
* @dev Counter contract for demo purposes
*
*/
contract Counter {
uint256 counter;

event Incremented(address from, uint256 by);

/**
* @dev increment counter of `value`
*/
function increment(uint256 value) public {
counter += value;
emit Incremented(msg.sender, value);
}
}
34 changes: 34 additions & 0 deletions loadTests/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Performance testing

In order to run relevant perfomance tests it is recommended to run API pods on AWS `m5.xlarge`instances (4vCpus / 16Gio), at least. Or equivalent on other platforms.

These instances are targeted using the k8s node selector technique, as you may see in both the load profile and orchestrate values file. Respectively located in `environments/load.yaml` and `values/orchestrate.yaml.gotmpl`

## Deployment

### orchestrate

Define a load test namespace within you k8s cluster and set the `ORCHESTRATE_NAMESPACE` accordingly, one good choice could be :
`export ORCHESTRATE_NAMESPACE=benchmark`

The following command will deploy orchestrate in performance testing mode within the defined namespace

`helmfile apply -e load --suppress-secrets`

### Test smart contract

The provided `Counter.sol` smart contract must be deployed into a test blockchain, in the given test we have been using a Besu node. This might be changed at line 32 of the `vegeta-pod.yaml`file, accordingly with your registered/targeted chains.

The `Counter-formatted-abi.json` file will help you deploy that contract quicker using orchestrate contract registration API.

## Run test

Current test is proposed as a Pod that enables running the vegeta tool against the deployed version of orchestrate. You should be careful to run the test within the same namespace as you load instances. Using the following command :

`kubectl apply -f vegeta-pod.yaml -n $ORCHESTRATE_NAMESPACE`

If you are not using default API-KEY, the value must be changed before running at line 27 of the `vegeta-pod.yaml`file.

## Note

Current version of the test has run successfully (100% success) with the given configuration.
44 changes: 44 additions & 0 deletions loadTests/vegeta-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: v1
kind: Pod
metadata:
name: vegeta
spec:
restartPolicy: Never
volumes:
- name: config-volume
configMap:
name: vegeta-configmap
containers:
- name: vegeta1
image: peterevans/vegeta:6.9.1
command: ["/bin/sh", "-c"]
volumeMounts:
- name: config-volume
mountPath: /vegeta
args: ["cd /vegeta; cat test | vegeta attack -format=http -duration=1m30s -rate=500/s -connections 75 | vegeta report"]
---
apiVersion: v1
kind: ConfigMap
metadata:
name: vegeta-configmap
data:
test: |
POST http://orchestrate-api:8081/transactions/send
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why url is hard coded?

x-api-key: with-key
Content-Type: application/json
@body.json
body.json: |
{
"chain": "besu",
"params": {
"methodSignature": "increment(uint256)",
"args": [1],
"to": "0x42699a7612a82f1d9c36148af9c77354759b210b",
"gasPrice": "0x0",
"gas": 25000,
"oneTimeKey": true,
"contractName": "increment",
"contractTag": "v1.0.0"
}
}
---
4 changes: 4 additions & 0 deletions values/orchestrate.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ global:

api:
enabled: true
{{- if .Values.nodeSelector.enabled }}
nodeSelector:
{{ toYaml .Values.nodeSelector.value | indent 4 }}
{{- end }}
replicaCount: {{ $replicaCount }}
{{- if .Values.domainName }}
ingress:
Expand Down