forked from neonevm/neon-tests
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #518 from neonlabsorg/NDEV-3489-split-trace-transa…
…ction-scenario Ndev 3489 split trace transaction scenario
- Loading branch information
Showing
7 changed files
with
656 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
629 changes: 386 additions & 243 deletions
629
loadtesting/k6/monitoring/.docker/dashboards/neon_performance_dashboard.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionIterative.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}); | ||
} |
89 changes: 89 additions & 0 deletions
89
loadtesting/k6/tests/tracer/traceTransaction/debugTraceTransactionSimple.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}); | ||
} |
Oops, something went wrong.