From ba06f44e8163a6932e0ab637e318fc07ae10f6d7 Mon Sep 17 00:00:00 2001 From: Sylvain Decourval Date: Mon, 6 Jun 2022 10:32:06 +0200 Subject: [PATCH 1/5] Add load tests as env + pod --- environments/load.yaml | 43 ++++++++++++++++++++++++++++ loadTests/vegeta-pod.yaml | 51 ++++++++++++++++++++++++++++++++++ values/orchestrate.yaml.gotmpl | 4 +++ 3 files changed, 98 insertions(+) create mode 100644 environments/load.yaml create mode 100644 loadTests/vegeta-pod.yaml diff --git a/environments/load.yaml b/environments/load.yaml new file mode 100644 index 0000000..3005266 --- /dev/null +++ b/environments/load.yaml @@ -0,0 +1,43 @@ +orchestrate: + replicaCount: 3 + global: + environment: + MULTI_TENANCY_ENABLED: true + AUTH_JWT_CLAIMS_NAMESPACE: orchestrate.namespace + AUTH_JWT_CERTIFICATE: MIIDYjCCAkoCCQC9pJWk7qdipjANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJGUjEOMAwGA1UEBwwFUGFyaXMxEjAQBgNVBAoMCUNvbnNlblN5czEQMA4GA1UECwwHUGVnYVN5czEuMCwGA1UEAwwlZTJlLXRlc3RzLm9yY2hlc3RyYXRlLmNvbnNlbnN5cy5wYXJpczAeFw0xOTEyMjcxNjI5MTdaFw0yMDEyMjYxNjI5MTdaMHMxCzAJBgNVBAYTAkZSMQ4wDAYDVQQHDAVQYXJpczESMBAGA1UECgwJQ29uc2VuU3lzMRAwDgYDVQQLDAdQZWdhU3lzMS4wLAYDVQQDDCVlMmUtdGVzdHMub3JjaGVzdHJhdGUuY29uc2Vuc3lzLnBhcmlzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo0NqWqI3TSi1uOBvCUquclWo4LcsYT21tNUXQ8YyqVYRSsiBv+ZKZBCjD8XklLPih40kFSe+r6DNca5/LH/okQIdc8nsQg+BLCkXeH2NFv+QYtPczAw4YhS6GVxJk3u9sfp8NavWBcQbD3MMDpehMOvhSl0zoP/ZlH6ErKHNtoQgUpPNVQGysNU21KpClmIDD/L1drsbq+rFiDrcVWaOLwGxr8SBd/0b4ngtcwH16RJaxcIXXT5AVia1CNdzmU5/AIg3OfgzvKn5AGrMZBsmGAiCyn4/P3PnuF81/WHukk5ETLnzOH+vC2elSmZ8y80HCGeqOiQ1rs66L936wX8cDwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCNcTs3n/Ps+yIZDH7utxTOaqpDTCB10MzPmb22UAal89couIT6R0fAu14p/LTkxdb2STDySsQY2/Lv6rPdFToHGUI9ZYOTYW1GOWkt1EAao9BzdsoJVwmTON6QnOBKy/9RxlhWP+XSWVsY0te6KYzS7rQyzQoJQeeBNMpUnjiQji9kKi5j9rbVMdjIb4HlmYrcE95ps+oFkyJoA1HLVytAeOjJPXGToNlv3k2UPJzOFUM0ujWWeBTyHMCmZ4RhlrfzDNffY5dlW82USjc5dBlzRyZalXSjhcVhK4asUodomVntrvCShp/8C9LpbQZ+ugFNE8J6neStWrhpRU9/sBJx + TOPIC_TX_DECODED: topic-tx-decoded + TOPIC_TX_RECOVER: topic-tx-recover + TOPIC_TX_SENDER: topic-tx-sender + 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: + vault: + agents: {} + +nodeSelector: + enabled: true + value: + benchmark-orchestrate: "true" \ No newline at end of file diff --git a/loadTests/vegeta-pod.yaml b/loadTests/vegeta-pod.yaml new file mode 100644 index 0000000..718f48c --- /dev/null +++ b/loadTests/vegeta-pod.yaml @@ -0,0 +1,51 @@ +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=600/s -connections 75 | vegeta report"] +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: vegeta-configmap +data: + test: | + POST http://orchestrate-api:8081/transactions/transfer + x-api-key: with-key + Content-Type: application/json + @body.json + body.json: | + { + "chain": "besu", + "params": { + "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", + "to": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", + "value": "0x44300E0", + "gas": 21000, + "gasPrice": "0x0", + "gasPricePolicy": { + "priority": "very-high", + "retryPolicy": { + "increment": 0.05, + "interval": "2m", + "limit": 0.5 + } + }, + "transactionType": "legacy" + }, + "labels": {} + } +--- 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: From d7e913496bed41c21f810ff03683db9c0127d455 Mon Sep 17 00:00:00 2001 From: Sylvain Decourval Date: Mon, 6 Jun 2022 11:18:03 +0200 Subject: [PATCH 2/5] Add load tests items and procedure --- loadTests/Counter-formatted-abi.json | 41 ++++++++++++++++++++++++++++ loadTests/Counter.sol | 19 +++++++++++++ loadTests/Readme.md | 34 +++++++++++++++++++++++ loadTests/vegeta-pod.yaml | 28 ++++++------------- 4 files changed, 103 insertions(+), 19 deletions(-) create mode 100644 loadTests/Counter-formatted-abi.json create mode 100644 loadTests/Counter.sol create mode 100644 loadTests/Readme.md 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 index 718f48c..aa1ee9f 100644 --- a/loadTests/vegeta-pod.yaml +++ b/loadTests/vegeta-pod.yaml @@ -15,7 +15,7 @@ spec: volumeMounts: - name: config-volume mountPath: /vegeta - args: ["cd /vegeta; cat test | vegeta attack -format=http -duration=1m30s -rate=600/s -connections 75 | vegeta report"] + args: ["cd /vegeta; cat test | vegeta attack -format=http -duration=1m30s -rate=500/s -connections 75 | vegeta report"] --- apiVersion: v1 kind: ConfigMap @@ -28,24 +28,14 @@ data: Content-Type: application/json @body.json body.json: | - { + { "chain": "besu", "params": { - "from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", - "to": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", - "value": "0x44300E0", - "gas": 21000, - "gasPrice": "0x0", - "gasPricePolicy": { - "priority": "very-high", - "retryPolicy": { - "increment": 0.05, - "interval": "2m", - "limit": 0.5 - } - }, - "transactionType": "legacy" - }, - "labels": {} - } + "methodSignature": "increment(uint256)", + "args": ["1"], + "to": "0xb3f3054bdf200886773dadfeab85ece6690ede8f", + "gasPrice": "0", + "gas": "25000", + "oneTimeKey": true + } --- From 8b6fa6a77f0d0513aa40d9a588bba5f854f7eafd Mon Sep 17 00:00:00 2001 From: Sylvain Decourval Date: Mon, 6 Jun 2022 11:23:25 +0200 Subject: [PATCH 3/5] node selection --- environments/default.yaml | 2 ++ environments/load.yaml | 1 + environments/qa.yaml | 5 ++++- environments/staging.yaml | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) 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 index 3005266..c49e7bc 100644 --- a/environments/load.yaml +++ b/environments/load.yaml @@ -34,6 +34,7 @@ vault: replicaCount: 0 qkm: + url: https://staging-qkm.ops.consensys.net vault: agents: {} 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 From dda003329d5d5b7fc3873a62230832c39f3efec3 Mon Sep 17 00:00:00 2001 From: Sylvain Decourval Date: Tue, 7 Jun 2022 17:25:06 +0200 Subject: [PATCH 4/5] Update transaction --- loadTests/vegeta-pod.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/loadTests/vegeta-pod.yaml b/loadTests/vegeta-pod.yaml index aa1ee9f..fd7b9a2 100644 --- a/loadTests/vegeta-pod.yaml +++ b/loadTests/vegeta-pod.yaml @@ -23,7 +23,7 @@ metadata: name: vegeta-configmap data: test: | - POST http://orchestrate-api:8081/transactions/transfer + POST http://orchestrate-api:8081/transactions/send x-api-key: with-key Content-Type: application/json @body.json @@ -32,10 +32,13 @@ data: "chain": "besu", "params": { "methodSignature": "increment(uint256)", - "args": ["1"], - "to": "0xb3f3054bdf200886773dadfeab85ece6690ede8f", - "gasPrice": "0", - "gas": "25000", - "oneTimeKey": true + "args": [1], + "to": "0x42699a7612a82f1d9c36148af9c77354759b210b", + "gasPrice": "0x0", + "gas": 25000, + "oneTimeKey": true, + "contractName": "increment", + "contractTag": "v1.0.0" + } } --- From c42f6437406d778d7a7b22eb95cb1ec7a2084916 Mon Sep 17 00:00:00 2001 From: Sylvain Decourval Date: Wed, 8 Jun 2022 09:52:15 +0200 Subject: [PATCH 5/5] rm useless env --- environments/load.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/environments/load.yaml b/environments/load.yaml index c49e7bc..c5da41d 100644 --- a/environments/load.yaml +++ b/environments/load.yaml @@ -3,11 +3,6 @@ orchestrate: global: environment: MULTI_TENANCY_ENABLED: true - AUTH_JWT_CLAIMS_NAMESPACE: orchestrate.namespace - AUTH_JWT_CERTIFICATE: MIIDYjCCAkoCCQC9pJWk7qdipjANBgkqhkiG9w0BAQsFADBzMQswCQYDVQQGEwJGUjEOMAwGA1UEBwwFUGFyaXMxEjAQBgNVBAoMCUNvbnNlblN5czEQMA4GA1UECwwHUGVnYVN5czEuMCwGA1UEAwwlZTJlLXRlc3RzLm9yY2hlc3RyYXRlLmNvbnNlbnN5cy5wYXJpczAeFw0xOTEyMjcxNjI5MTdaFw0yMDEyMjYxNjI5MTdaMHMxCzAJBgNVBAYTAkZSMQ4wDAYDVQQHDAVQYXJpczESMBAGA1UECgwJQ29uc2VuU3lzMRAwDgYDVQQLDAdQZWdhU3lzMS4wLAYDVQQDDCVlMmUtdGVzdHMub3JjaGVzdHJhdGUuY29uc2Vuc3lzLnBhcmlzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo0NqWqI3TSi1uOBvCUquclWo4LcsYT21tNUXQ8YyqVYRSsiBv+ZKZBCjD8XklLPih40kFSe+r6DNca5/LH/okQIdc8nsQg+BLCkXeH2NFv+QYtPczAw4YhS6GVxJk3u9sfp8NavWBcQbD3MMDpehMOvhSl0zoP/ZlH6ErKHNtoQgUpPNVQGysNU21KpClmIDD/L1drsbq+rFiDrcVWaOLwGxr8SBd/0b4ngtcwH16RJaxcIXXT5AVia1CNdzmU5/AIg3OfgzvKn5AGrMZBsmGAiCyn4/P3PnuF81/WHukk5ETLnzOH+vC2elSmZ8y80HCGeqOiQ1rs66L936wX8cDwIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCNcTs3n/Ps+yIZDH7utxTOaqpDTCB10MzPmb22UAal89couIT6R0fAu14p/LTkxdb2STDySsQY2/Lv6rPdFToHGUI9ZYOTYW1GOWkt1EAao9BzdsoJVwmTON6QnOBKy/9RxlhWP+XSWVsY0te6KYzS7rQyzQoJQeeBNMpUnjiQji9kKi5j9rbVMdjIb4HlmYrcE95ps+oFkyJoA1HLVytAeOjJPXGToNlv3k2UPJzOFUM0ujWWeBTyHMCmZ4RhlrfzDNffY5dlW82USjc5dBlzRyZalXSjhcVhK4asUodomVntrvCShp/8C9LpbQZ+ugFNE8J6neStWrhpRU9/sBJx - TOPIC_TX_DECODED: topic-tx-decoded - TOPIC_TX_RECOVER: topic-tx-recover - TOPIC_TX_SENDER: topic-tx-sender DB_DATABASE: orchestrate_load DB_POOLSIZE: 750 environmentSecrets: