diff --git a/clickfile.py b/clickfile.py index bfda1c66c..cb2b82172 100755 --- a/clickfile.py +++ b/clickfile.py @@ -1306,7 +1306,7 @@ def build(tag): "-u", "--users", default=None, required=True, help="Number of users (have to be generated before load test run)" ) @click.option("-b", "--balance", default=None, required=True, help="Initial balance of accounts in Neon") -@click.option("-a", "--bank_account", default="", required=False, help="Eth bank account private key") +@click.option("-a", "--bank_account", default=None, required=False, help="Eth bank account private key") @catch_traceback def run_load_k6(network, script, users, balance, bank_account): network_manager = NetworkManager() diff --git a/loadtesting/k6/monitoring/.docker/dashboards/neon_performance_dashboard.json b/loadtesting/k6/monitoring/.docker/dashboards/neon_performance_dashboard.json index 72739876c..1410f9f85 100644 --- a/loadtesting/k6/monitoring/.docker/dashboards/neon_performance_dashboard.json +++ b/loadtesting/k6/monitoring/.docker/dashboards/neon_performance_dashboard.json @@ -441,7 +441,7 @@ "showLegend": true }, "tooltip": { - "mode": "single", + "mode": "multi", "sort": "none" } }, @@ -452,9 +452,33 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "irate(k6_debug_trace_transaction_requests_counter{})[$__rate_interval]", + "expr": "irate(k6_debug_trace_transaction_with_events_requests_counter{})[$__rate_interval]", "hide": false, - "legendFormat": "{{scenario}}", + "legendFormat": "tx with events", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "irate(k6_debug_trace_transaction_iterative_requests_counter{})[$__rate_interval]", + "hide": false, + "legendFormat": "iterative tx", + "range": true, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "irate(k6_debug_trace_transaction_simple_requests_counter{})[$__rate_interval]", + "hide": false, + "legendFormat": "simple tx", "range": true, "refId": "B" } @@ -585,7 +609,7 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "sum(irate(k6_tracer_eth_call_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_balance_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_transaction_count_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_storage_at_requests_counter{})[$__rate_interval], irate(k6_debug_trace_transaction_requests_counter{})[$__rate_interval])", + "expr": "sum(irate(k6_tracer_eth_call_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_balance_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_transaction_count_requests_counter{})[$__rate_interval], irate(k6_tracer_eth_get_storage_at_requests_counter{})[$__rate_interval], irate(k6_debug_trace_transaction_simple_requests_counter{})[$__rate_interval], irate(k6_debug_trace_transaction_with_events_requests_counter{})[$__rate_interval], irate(k6_debug_trace_transaction_iterative_requests_counter{})[$__rate_interval])", "hide": false, "legendFormat": "sum rate rps per 15s interval", "range": true, @@ -776,9 +800,9 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "k6_debug_trace_transaction_request_errors_counter{}", + "expr": "k6_debug_trace_transaction_simple_request_errors_counter{}", "hide": false, - "legendFormat": "debug_trace_transaction", + "legendFormat": "debug_trace_transaction (simple)", "range": true, "refId": "E" }, @@ -796,6 +820,30 @@ "legendFormat": "eth_get_storage_at", "range": true, "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "k6_debug_trace_transaction_with_events_request_errors_counter{}", + "hide": false, + "legendFormat": "debug_trace_transaction (with events)", + "range": true, + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "k6_debug_trace_transaction_iterative_request_errors_counter{}", + "hide": false, + "legendFormat": "debug_trace_transaction (iterative)", + "range": true, + "refId": "G" } ], "title": "Errors in response", @@ -916,6 +964,45 @@ } } ] + }, + { + "__systemRef": "hideSeriesFrom", + "matcher": { + "id": "byNames", + "options": { + "mode": "exclude", + "names": [ + "debug_trace_transaction (iterative)" + ], + "prefix": "All except:", + "readOnly": true + } + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": false, + "tooltip": false, + "viz": true + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "debug_trace_transaction (iterative)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] } ] }, @@ -993,11 +1080,35 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "k6_debug_trace_transaction_errors_counter{}", + "expr": "k6_debug_trace_transaction_simple_errors_counter{}", "hide": false, - "legendFormat": "debug_trace_transaction", + "legendFormat": "debug_trace_transaction (simple)", "range": true, "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "k6_debug_trace_transaction_with_events_errors_counter{}", + "hide": false, + "legendFormat": "debug_trace_transaction (with events)", + "range": true, + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "k6_debug_trace_transaction_iterative_errors_counter{}", + "hide": false, + "legendFormat": "debug_trace_transaction (iterative)", + "range": true, + "refId": "G" } ], "title": "Requests Errors", @@ -1327,10 +1438,34 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "avg(k6_debug_trace_transaction_request_time_0.95{})[$__interval]", - "legendFormat": "debug_trace_transaction", + "expr": "avg(k6_debug_trace_transaction_simple_request_time_0.95{})[$__interval]", + "legendFormat": "simple tx", "range": true, "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "avg(k6_debug_trace_transaction_with_events_request_time_0.95{})[$__interval]", + "hide": false, + "legendFormat": "tx with events", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "avg(k6_debug_trace_transaction_iterative_request_time_0.95{})[$__interval]", + "hide": false, + "legendFormat": "iterative tx", + "range": true, + "refId": "C" } ], "title": "Requests Time Trace Tx 0.95%tile", @@ -1600,10 +1735,34 @@ "uid": "P4169E866C3094E38" }, "editorMode": "code", - "expr": "avg(k6_debug_trace_transaction_request_time_1{})[$__interval]", - "legendFormat": "debug_trace_transaction", + "expr": "avg(k6_debug_trace_transaction_simple_request_time_1{})[$__interval]", + "legendFormat": "simple tx", "range": true, "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "avg(k6_debug_trace_transaction_with_events_request_time_1{})[$__interval]", + "hide": false, + "legendFormat": "tx with events", + "range": true, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "avg(k6_debug_trace_transaction_iterative_request_time_1{})[$__interval]", + "hide": false, + "legendFormat": "iterative tx", + "range": true, + "refId": "C" } ], "title": "Requests Time Trace Tx 1%tile", @@ -1664,8 +1823,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -1756,8 +1914,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -1848,8 +2005,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -1941,8 +2097,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2051,8 +2206,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2146,8 +2300,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2240,8 +2393,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2393,8 +2545,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2487,8 +2638,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2627,8 +2777,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2738,8 +2887,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2862,8 +3010,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -2972,8 +3119,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3112,8 +3258,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3238,8 +3383,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -3323,7 +3467,7 @@ "type": "row" }, { - "collapsed": false, + "collapsed": true, "gridPos": { "h": 1, "w": 24, @@ -3331,226 +3475,225 @@ "y": 58 }, "id": 46, - "panels": [], - "title": "k6 Params", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P4169E866C3094E38" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "blue", - "value": null + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, - { - "color": "red", - "value": 80 + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + }, + { + "color": "red", + "value": 80 + } + ] } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "iteration rate" }, - "properties": [ + "overrides": [ { - "id": "color", - "value": { - "fixedColor": "dark-green", - "mode": "fixed" - } + "matcher": { + "id": "byName", + "options": "iteration rate" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-green", + "mode": "fixed" + } + } + ] } ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 59 - }, - "id": 48, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 59 + }, + "id": 48, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "irate(k6_iterations_counter{})[$__rate_interval]", + "legendFormat": "{{scenario}}", + "range": true, + "refId": "A" + } + ], + "title": "Iterations", + "type": "timeseries" }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ { "datasource": { "type": "prometheus", "uid": "P4169E866C3094E38" }, - "editorMode": "code", - "expr": "irate(k6_iterations_counter{})[$__rate_interval]", - "legendFormat": "{{scenario}}", - "range": true, - "refId": "A" - } - ], - "title": "Iterations", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "P4169E866C3094E38" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [ { - "color": "red", - "value": 80 + "matcher": { + "id": "byName", + "options": "avg duration" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#d4e222", + "mode": "fixed" + } + } + ] } ] }, - "unit": "ms" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "avg duration" + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 59 + }, + "id": 19, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#d4e222", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 12, - "y": 59 - }, - "id": 19, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "P4169E866C3094E38" + "tooltip": { + "mode": "single", + "sort": "none" + } }, - "editorMode": "code", - "expr": "avg(k6_iteration_duration_1{})", - "legendFormat": "avg duration", - "range": true, - "refId": "A" + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P4169E866C3094E38" + }, + "editorMode": "code", + "expr": "avg(k6_iteration_duration_1{})", + "legendFormat": "avg duration", + "range": true, + "refId": "A" + } + ], + "title": "Iterations duration", + "type": "timeseries" } ], - "title": "Iterations duration", - "type": "timeseries" + "title": "k6 Params", + "type": "row" } ], "refresh": "5s", @@ -3589,13 +3732,13 @@ ] }, "time": { - "from": "now-3h", + "from": "now-1h", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Neonlabs performance test", "uid": "-PUaX7vIk", - "version": 1, + "version": 7, "weekStart": "" } \ No newline at end of file diff --git a/loadtesting/k6/scenarios/tracerDebugTraceTransaction.js b/loadtesting/k6/scenarios/tracerDebugTraceTransaction.js new file mode 100644 index 000000000..6fd0fd295 --- /dev/null +++ b/loadtesting/k6/scenarios/tracerDebugTraceTransaction.js @@ -0,0 +1,52 @@ +import { default as DebugTraceTransactionTest } from '../tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js' +import { default as DebugTraceTransactionWithEventsTest } from '../tests/tracer/traceTransaction/debugTraceTransactionWithEvents.test.js' +import { default as DebugTraceIterativeTransactionTest } from '../tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js' +import { usersNumber } from "../tests/utils/consts.js"; + +export const options = { + scenarios: { + DebugTraceTransaction: { + exec: 'DebugTraceTransaction', + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '20s', target: usersNumber }, + { duration: '20m', target: usersNumber }, + ], + gracefulRampDown: '60s', + }, + DebugTraceTransactionWithEvents: { + exec: 'DebugTraceTransactionWithEvents', + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '20s', target: usersNumber }, + { duration: '20m', target: usersNumber }, + ], + gracefulRampDown: '60s', + }, + DebugTraceIterativeTransaction: { + exec: 'DebugTraceIterativeTransaction', + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '20s', target: usersNumber }, + { duration: '20m', target: usersNumber }, + ], + gracefulRampDown: '60s', + }, + }, + noConnectionReuse: true, +}; + +export function DebugTraceTransaction() { + DebugTraceTransactionTest(); +} + +export function DebugTraceTransactionWithEvents() { + DebugTraceTransactionWithEventsTest(); +} + +export function DebugTraceIterativeTransaction() { + DebugTraceIterativeTransactionTest(); +} diff --git a/loadtesting/k6/scenarios/tracerStandardLoad.js b/loadtesting/k6/scenarios/tracerStandardLoad.js index bb7dd4918..a57f682f9 100644 --- a/loadtesting/k6/scenarios/tracerStandardLoad.js +++ b/loadtesting/k6/scenarios/tracerStandardLoad.js @@ -1,4 +1,6 @@ -import { default as DebugTraceTransactionTest } from '../tests/tracer/debugTraceTransaction.test.js' +import { default as DebugTraceTransactionTest } from '../tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js' +import { default as DebugTraceTransactionWithEventsTest } from '../tests/tracer/traceTransaction/debugTraceTransactionWithEvents.test.js' +import { default as DebugTraceIterativeTransactionTest } from '../tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js' import { default as EthCallTest } from '../tests/tracer/ethCall.test.js'; import { default as EthGetBalanceTest } from '../tests/tracer/ethGetBalance.test.js'; import { default as EthGetTransactionCountTest } from '../tests/tracer/ethGetTransactionCount.test.js'; @@ -17,6 +19,26 @@ export const options = { ], gracefulRampDown: '60s', }, + DebugTraceTransactionWithEvents: { + exec: 'DebugTraceTransactionWithEvents', + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '20s', target: usersNumber }, + { duration: '20m', target: usersNumber }, + ], + gracefulRampDown: '60s', + }, + DebugTraceIterativeTransaction: { + exec: 'DebugTraceIterativeTransaction', + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '20s', target: usersNumber }, + { duration: '20m', target: usersNumber }, + ], + gracefulRampDown: '60s', + }, EthCall: { exec: 'EthCall', executor: 'ramping-vus', @@ -65,6 +87,14 @@ export function DebugTraceTransaction() { DebugTraceTransactionTest(); } +export function DebugTraceTransactionWithEvents() { + DebugTraceTransactionWithEventsTest(); +} + +export function DebugTraceIterativeTransaction() { + DebugTraceIterativeTransactionTest(); +} + export function EthCall() { EthCallTest(); } diff --git a/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js new file mode 100644 index 000000000..d46657d5d --- /dev/null +++ b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js @@ -0,0 +1,88 @@ +import { ethClient } from '../../utils/ethClient.js'; +import { standardScenarioOptions } from '../../../options/options.js'; +import { Trend, Counter } from 'k6/metrics'; +import { SharedArray } from 'k6/data'; + +import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; +import exec from 'k6/execution'; +import { check } from 'k6'; + +const debugTraceTransactionRequests = new Counter('debug_trace_transaction_iterative_requests'); +const debugTraceTransactionRequestErrorCounter = new Counter('debug_trace_transaction_iterative_request_errors'); +const debugTraceTransactionErrorCounter = new Counter('debug_trace_transaction_iterative_errors'); +const debugTraceTransactionRequestTime = new Trend('debug_trace_transaction_iterative_request_time', true); + +export const options = standardScenarioOptions; + +const historicalData = JSON.parse(open("../../../data/tracer_data.json")); + +const usersArray = new SharedArray('Users accounts', function () { + const accounts = JSON.parse(open("../../../data/accounts.json")); + let data = []; + for (let i = 0; i < Object.keys(accounts).length; i++) { + data[i] = accounts[i]; + } + return data; +}); + + +export default function DebugTraceIterativeTransactionTest() { + const vuID = exec.vu.idInTest + const index = vuID % usersArray.length; + + const dataIndexIterative = randomIntBetween(0, (historicalData.iterative_tx_contract_calls).length - 1); + const txInfoIterative = historicalData.iterative_tx_contract_calls[dataIndexIterative]; + + const accountPrivateKey = usersArray[index].sender_key; + const client = ethClient(accountPrivateKey); + const tracer_config = { "tracer": "callTracer", "tracerConfig": { "withLog": true } } + + // call iterative tx contract + // blockNumber + const requestParamsBlockNumberIterative = { + requestType: "blockNumber", + method: "debug_traceTransaction", + params: [txInfoIterative.tx_hash, tracer_config] + } + + doRequest(client, requestParamsBlockNumberIterative, checkExpectedValueIterative, 1001); + + // blockHash + const requestParamsBlockHashIterative = { + requestType: "blockHash", + method: "debug_traceTransaction", + params: [txInfoIterative.tx_hash, tracer_config] + } + + doRequest(client, requestParamsBlockHashIterative, checkExpectedValueIterative, 1001); +} + +function doRequest(client, requestParams, checkExpectedValueFunction, args) { + const startTime = new Date(); + try { + const responseBody = client.callTracer( + JSON.stringify(requestParams.requestType), + JSON.stringify(requestParams.method), + JSON.stringify(requestParams.params) + ); + const response = JSON.parse(responseBody); + const checkResult = checkExpectedValueFunction(response, args); + if (!checkResult) { + console.log('Error in response of debug_traceTransaction: ' + JSON.stringify(response)); + debugTraceTransactionRequestErrorCounter.add(1); + } + } catch (e) { + console.log('Error in debug_traceTransaction: ' + e); + debugTraceTransactionErrorCounter.add(1); + } + debugTraceTransactionRequestTime.add(new Date() - startTime); + debugTraceTransactionRequests.add(1); +} + +function checkExpectedValueIterative(response, expectedValue) { + return check(response, { + 'response result is not expected value': (r) => { + return (r.result.logs.length == expectedValue) + } + }); +} \ No newline at end of file diff --git a/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js new file mode 100644 index 000000000..cf9bf1625 --- /dev/null +++ b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js @@ -0,0 +1,89 @@ +import { ethClient } from '../../utils/ethClient.js'; +import { standardScenarioOptions } from '../../../options/options.js'; +import { Trend, Counter } from 'k6/metrics'; +import { SharedArray } from 'k6/data'; + +import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; +import exec from 'k6/execution'; +import { check } from 'k6'; + +const debugTraceTransactionRequests = new Counter('debug_trace_transaction_simple_requests'); +const debugTraceTransactionRequestErrorCounter = new Counter('debug_trace_transaction_simple_request_errors'); +const debugTraceTransactionErrorCounter = new Counter('debug_trace_transaction_simple_errors'); +const debugTraceTransactionRequestTime = new Trend('debug_trace_transaction_simple_request_time', true); + +export const options = standardScenarioOptions; + +const historicalData = JSON.parse(open("../../../data/tracer_data.json")); + +const usersArray = new SharedArray('Users accounts', function () { + const accounts = JSON.parse(open("../../../data/accounts.json")); + let data = []; + for (let i = 0; i < Object.keys(accounts).length; i++) { + data[i] = accounts[i]; + } + return data; +}); + + +export default function DebugTraceTransactionTest() { + const vuID = exec.vu.idInTest + const index = vuID % usersArray.length; + + const dataIndexStorage = randomIntBetween(0, (historicalData.storage_contract_calls).length - 1); + const txInfoStorage = historicalData.storage_contract_calls[dataIndexStorage]; + + const accountPrivateKey = usersArray[index].sender_key; + const client = ethClient(accountPrivateKey); + + // call storage contract + // blockNumber + const requestParamsBlockNumberStorage = { + requestType: "blockNumber", + method: "debug_traceTransaction", + params: [txInfoStorage.tx_hash, { "blockNumber": txInfoStorage.blockNumber }] + } + + doRequest(client, requestParamsBlockNumberStorage, checkExpectedValueStorage, txInfoStorage.store_value); + + // blockHash + const requestParamsBlockHashStorage = { + requestType: "blockHash", + method: "debug_traceTransaction", + params: [txInfoStorage.tx_hash, { "blockHash": txInfoStorage.blockHash }] + } + + doRequest(client, requestParamsBlockHashStorage, checkExpectedValueStorage, txInfoStorage.store_value); + +} + +function doRequest(client, requestParams, checkExpectedValueFunction, args) { + const startTime = new Date(); + try { + const responseBody = client.callTracer( + JSON.stringify(requestParams.requestType), + JSON.stringify(requestParams.method), + JSON.stringify(requestParams.params) + ); + const response = JSON.parse(responseBody); + const checkResult = checkExpectedValueFunction(response, args); + if (!checkResult) { + console.log('Error in response of debug_traceTransaction: ' + JSON.stringify(response)); + debugTraceTransactionRequestErrorCounter.add(1); + } + } catch (e) { + console.log('Error in debug_traceTransaction: ' + e); + debugTraceTransactionErrorCounter.add(1); + } + debugTraceTransactionRequestTime.add(new Date() - startTime); + debugTraceTransactionRequests.add(1); +} + + +function checkExpectedValueStorage(response, expectedValue) { + return check(response, { + 'response result is not expected value': (r) => { + return (parseInt(r.result.returnValue, 16) == expectedValue) + } + }); +} \ No newline at end of file diff --git a/loadtesting/k6/tests/tracer/debugTraceTransaction.test.js b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionWithEvents.test.js similarity index 53% rename from loadtesting/k6/tests/tracer/debugTraceTransaction.test.js rename to loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionWithEvents.test.js index ee986689a..fee738cb4 100644 --- a/loadtesting/k6/tests/tracer/debugTraceTransaction.test.js +++ b/loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionWithEvents.test.js @@ -1,5 +1,5 @@ -import { ethClient } from '../utils/ethClient.js'; -import { standardScenarioOptions } from '../../options/options.js'; +import { ethClient } from '../../utils/ethClient.js'; +import { standardScenarioOptions } from '../../../options/options.js'; import { Trend, Counter } from 'k6/metrics'; import { SharedArray } from 'k6/data'; @@ -7,17 +7,17 @@ import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; import exec from 'k6/execution'; import { check } from 'k6'; -const debugTraceTransactionRequests = new Counter('debug_trace_transaction_requests'); -const debugTraceTransactionRequestErrorCounter = new Counter('debug_trace_transaction_request_errors'); -const debugTraceTransactionErrorCounter = new Counter('debug_trace_transaction_errors'); -const debugTraceTransactionRequestTime = new Trend('debug_trace_transaction_request_time', true); +const debugTraceTransactionRequests = new Counter('debug_trace_transaction_with_events_requests'); +const debugTraceTransactionRequestErrorCounter = new Counter('debug_trace_transaction_with_events_request_errors'); +const debugTraceTransactionErrorCounter = new Counter('debug_trace_transaction_with_events_errors'); +const debugTraceTransactionRequestTime = new Trend('debug_trace_transaction_with_events_request_time', true); export const options = standardScenarioOptions; -const historicalData = JSON.parse(open("../../data/tracer_data.json")); +const historicalData = JSON.parse(open("../../../data/tracer_data.json")); const usersArray = new SharedArray('Users accounts', function () { - const accounts = JSON.parse(open("../../data/accounts.json")); + const accounts = JSON.parse(open("../../../data/accounts.json")); let data = []; for (let i = 0; i < Object.keys(accounts).length; i++) { data[i] = accounts[i]; @@ -26,41 +26,16 @@ const usersArray = new SharedArray('Users accounts', function () { }); -export default function DebugTraceTransactionTest() { +export default function DebugTraceTransactionWithEventsTest() { const vuID = exec.vu.idInTest const index = vuID % usersArray.length; - const dataIndexStorage = randomIntBetween(0, (historicalData.storage_contract_calls).length - 1); - const txInfoStorage = historicalData.storage_contract_calls[dataIndexStorage]; - const dataIndexEvent = randomIntBetween(0, (historicalData.event_caller_contract_calls).length - 1); const txInfoEvent = historicalData.event_caller_contract_calls[dataIndexEvent]; - const dataIndexIterative = randomIntBetween(0, (historicalData.iterative_tx_contract_calls).length - 1); - const txInfoIterative = historicalData.iterative_tx_contract_calls[dataIndexIterative]; - const accountPrivateKey = usersArray[index].sender_key; const client = ethClient(accountPrivateKey); - // call storage contract - // blockNumber - const requestParamsBlockNumberStorage = { - requestType: "blockNumber", - method: "debug_traceTransaction", - params: [txInfoStorage.tx_hash, {"blockNumber": txInfoStorage.blockNumber}] - } - - doRequest(client, requestParamsBlockNumberStorage, checkExpectedValueStorage, txInfoStorage.store_value); - - // blockHash - const requestParamsBlockHashStorage = { - requestType: "blockHash", - method: "debug_traceTransaction", - params: [txInfoStorage.tx_hash, {"blockHash": txInfoStorage.blockHash}] - } - - doRequest(client, requestParamsBlockHashStorage, checkExpectedValueStorage, txInfoStorage.store_value); - // call event caller contract // blockNumber const tracer_config = { "tracer": "callTracer", "tracerConfig": { "withLog": true } } @@ -80,25 +55,6 @@ export default function DebugTraceTransactionTest() { } doRequest(client, requestParamsBlockHashEvent, checkExpectedValueEvent, [1, 2]); - - // call iterative tx contract - // blockNumber - const requestParamsBlockNumberIterative = { - requestType: "blockNumber", - method: "debug_traceTransaction", - params: [txInfoIterative.tx_hash, tracer_config] - } - - doRequest(client, requestParamsBlockNumberIterative, checkExpectedValueIterative, 1001); - - // blockHash - const requestParamsBlockHashIterative = { - requestType: "blockHash", - method: "debug_traceTransaction", - params: [txInfoIterative.tx_hash, tracer_config] - } - - doRequest(client, requestParamsBlockHashIterative, checkExpectedValueIterative, 1001); } function doRequest(client, requestParams, checkExpectedValueFunction, args) { @@ -123,15 +79,6 @@ function doRequest(client, requestParams, checkExpectedValueFunction, args) { debugTraceTransactionRequests.add(1); } - -function checkExpectedValueStorage(response, expectedValue) { - return check(response, { - 'response result is not expected value': (r) => { - return (parseInt(r.result.returnValue, 16) == expectedValue) - } - }); -} - function checkExpectedValueEvent(response, expectedValue) { return check(response, { 'response result is not expected value': (r) => { @@ -139,11 +86,3 @@ function checkExpectedValueEvent(response, expectedValue) { } }); } - -function checkExpectedValueIterative(response, expectedValue) { - return check(response, { - 'response result is not expected value': (r) => { - return (r.result.logs.length == expectedValue) - } - }); -} \ No newline at end of file