diff --git a/environments/default.yaml b/environments/default.yaml index 622a396..e3986a1 100644 --- a/environments/default.yaml +++ b/environments/default.yaml @@ -4,3 +4,5 @@ drop: enabled: false qkm: url: https://qa-qkm.ops.consensys.net +nodeSelector: + enabled: false \ No newline at end of file diff --git a/environments/load.yaml b/environments/load.yaml new file mode 100644 index 0000000..c5da41d --- /dev/null +++ b/environments/load.yaml @@ -0,0 +1,39 @@ +orchestrate: + replicaCount: 3 + global: + environment: + MULTI_TENANCY_ENABLED: true + DB_DATABASE: orchestrate_load + DB_POOLSIZE: 750 + 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" \ No newline at end of file diff --git a/environments/qa.yaml b/environments/qa.yaml index 577a662..53678a6 100644 --- a/environments/qa.yaml +++ b/environments/qa.yaml @@ -13,4 +13,7 @@ drop: enabled: true qkm: - url: https://qa-qkm.ops.consensys.net \ No newline at end of file + url: https://qa-qkm.ops.consensys.net + +nodeSelector: + enabled: false \ No newline at end of file diff --git a/environments/staging.yaml b/environments/staging.yaml index fd10290..669706c 100644 --- a/environments/staging.yaml +++ b/environments/staging.yaml @@ -16,4 +16,7 @@ vault: replicaCount: 3 qkm: - url: https://staging-qkm.ops.consensys.net \ No newline at end of file + url: https://staging-qkm.ops.consensys.net + +nodeSelector: + enabled: false \ No newline at end of file diff --git a/loadTests/Counter-formatted-abi.json b/loadTests/Counter-formatted-abi.json new file mode 100644 index 0000000..cffd746 --- /dev/null +++ b/loadTests/Counter-formatted-abi.json @@ -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" +} \ No newline at end of file diff --git a/loadTests/Counter.sol b/loadTests/Counter.sol new file mode 100644 index 0000000..c821a5f --- /dev/null +++ b/loadTests/Counter.sol @@ -0,0 +1,19 @@ +pragma solidity ^0.6.0; + +/** + * @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); + } +} \ No newline at end of file diff --git a/loadTests/Readme.md b/loadTests/Readme.md new file mode 100644 index 0000000..215025e --- /dev/null +++ b/loadTests/Readme.md @@ -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. \ No newline at end of file diff --git a/loadTests/vegeta-pod.yaml b/loadTests/vegeta-pod.yaml new file mode 100644 index 0000000..fd7b9a2 --- /dev/null +++ b/loadTests/vegeta-pod.yaml @@ -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 + 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" + } + } +--- diff --git a/values/orchestrate.yaml.gotmpl b/values/orchestrate.yaml.gotmpl index 6b6b79b..d4ba98a 100644 --- a/values/orchestrate.yaml.gotmpl +++ b/values/orchestrate.yaml.gotmpl @@ -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: