Skip to content

Commit

Permalink
Merge pull request #702 from AntelopeIO/ph-gen-newaccounts
Browse files Browse the repository at this point in the history
[PH] Transaction Generator support generating newaccount transactions
  • Loading branch information
oschwaldp-oci authored Feb 13, 2023
2 parents 938d4ab + f25de1b commit 8a1fecd
Show file tree
Hide file tree
Showing 11 changed files with 652 additions and 205 deletions.
6 changes: 3 additions & 3 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ def stripValues(lowestMaxes,greaterThan):

def launchTrxGenerators(self, contractOwnerAcctName: str, acctNamesList: list, acctPrivKeysList: list,
nodeId: int=0, tpsPerGenerator: int=10, numGenerators: int=1, durationSec: int=60,
waitToComplete:bool=False, abiFile=None, actionName=None, actionData=None):
waitToComplete:bool=False, abiFile=None, actionsData=None, actionsAuths=None):
Utils.Print("Configure txn generators")
node=self.getNode(nodeId)
p2pListenPort = self.getNodeP2pPort(nodeId)
Expand All @@ -1779,8 +1779,8 @@ def launchTrxGenerators(self, contractOwnerAcctName: str, acctNamesList: list, a
tpsTrxGensConfig = TpsTrxGensConfig(targetTps=targetTps, tpsLimitPerGenerator=tpsLimitPerGenerator)
self.trxGenLauncher = TransactionGeneratorsLauncher(chainId=chainId, lastIrreversibleBlockId=lib_id,
contractOwnerAccount=contractOwnerAcctName, accts=','.join(map(str, acctNamesList)),
privateKeys=','.join(map(str, acctPrivKeysList)), trxGenDurationSec=durationSec,
logDir=Utils.DataDir, abiFile=abiFile, actionName=actionName, actionData=actionData,
privateKeys=','.join(map(str, acctPrivKeysList)), trxGenDurationSec=durationSec, logDir=Utils.DataDir,
abiFile=abiFile, actionsData=actionsData, actionsAuths=actionsAuths,
peerEndpoint=self.host, port=p2pListenPort, tpsTrxGensConfig=tpsTrxGensConfig)

Utils.Print("Launch txn generators and start generating/sending transactions")
Expand Down
31 changes: 18 additions & 13 deletions tests/TestHarness/launch_transaction_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def __init__(self, targetTps: int, tpsLimitPerGenerator: int):

class TransactionGeneratorsLauncher:

def __init__(self, chainId: int, lastIrreversibleBlockId: int, contractOwnerAccount: str, accts: str, privateKeys: str,
trxGenDurationSec: int, logDir: str, abiFile: Path, actionName: str, actionData, peerEndpoint: str, port: int, tpsTrxGensConfig: TpsTrxGensConfig):
def __init__(self, chainId: int, lastIrreversibleBlockId: int, contractOwnerAccount: str, accts: str, privateKeys: str, trxGenDurationSec: int, logDir: str,
abiFile: Path, actionsData, actionsAuths,
peerEndpoint: str, port: int, tpsTrxGensConfig: TpsTrxGensConfig):
self.chainId = chainId
self.lastIrreversibleBlockId = lastIrreversibleBlockId
self.contractOwnerAccount = contractOwnerAccount
Expand All @@ -47,18 +48,19 @@ def __init__(self, chainId: int, lastIrreversibleBlockId: int, contractOwnerAcco
self.tpsTrxGensConfig = tpsTrxGensConfig
self.logDir = logDir
self.abiFile = abiFile
self.actionName = actionName
self.actionData = actionData
self.actionsData=actionsData
self.actionsAuths=actionsAuths
self.peerEndpoint = peerEndpoint
self.port = port

def launch(self, waitToComplete=True):
self.subprocess_ret_codes = []
for targetTps in self.tpsTrxGensConfig.targetTpsPerGenList:
if self.abiFile is not None and self.actionName is not None and self.actionData is not None:
for id, targetTps in enumerate(self.tpsTrxGensConfig.targetTpsPerGenList):
if self.abiFile is not None and self.actionsData is not None and self.actionsAuths is not None:
if Utils.Debug:
Print(
f'Running trx_generator: ./tests/trx_generator/trx_generator '
f'--generator-id {id} '
f'--chain-id {self.chainId} '
f'--last-irreversible-block-id {self.lastIrreversibleBlockId} '
f'--contract-owner-account {self.contractOwnerAccount} '
Expand All @@ -67,15 +69,16 @@ def launch(self, waitToComplete=True):
f'--trx-gen-duration {self.trxGenDurationSec} '
f'--target-tps {targetTps} '
f'--log-dir {self.logDir} '
f'--action-name {self.actionName} '
f'--action-data {self.actionData} '
f'--abi-file {self.abiFile} '
f'--actions-data {self.actionsData} '
f'--actions-auths {self.actionsAuths} '
f'--peer-endpoint {self.peerEndpoint} '
f'--port {self.port}'
)
self.subprocess_ret_codes.append(
subprocess.Popen([
'./tests/trx_generator/trx_generator',
'--generator-id', f'{id}',
'--chain-id', f'{self.chainId}',
'--last-irreversible-block-id', f'{self.lastIrreversibleBlockId}',
'--contract-owner-account', f'{self.contractOwnerAccount}',
Expand All @@ -84,9 +87,9 @@ def launch(self, waitToComplete=True):
'--trx-gen-duration', f'{self.trxGenDurationSec}',
'--target-tps', f'{targetTps}',
'--log-dir', f'{self.logDir}',
'--action-name', f'{self.actionName}',
'--action-data', f'{self.actionData}',
'--abi-file', f'{self.abiFile}',
'--actions-data', f'{self.actionsData}',
'--actions-auths', f'{self.actionsAuths}',
'--peer-endpoint', f'{self.peerEndpoint}',
'--port', f'{self.port}'
])
Expand All @@ -95,6 +98,7 @@ def launch(self, waitToComplete=True):
if Utils.Debug:
Print(
f'Running trx_generator: ./tests/trx_generator/trx_generator '
f'--generator-id {id} '
f'--chain-id {self.chainId} '
f'--last-irreversible-block-id {self.lastIrreversibleBlockId} '
f'--contract-owner-account {self.contractOwnerAccount} '
Expand All @@ -109,6 +113,7 @@ def launch(self, waitToComplete=True):
self.subprocess_ret_codes.append(
subprocess.Popen([
'./tests/trx_generator/trx_generator',
'--generator-id', f'{id}',
'--chain-id', f'{self.chainId}',
'--last-irreversible-block-id', f'{self.lastIrreversibleBlockId}',
'--contract-owner-account', f'{self.contractOwnerAccount}',
Expand Down Expand Up @@ -144,9 +149,9 @@ def parseArgs():
parser.add_argument("target_tps", type=int, help="Goal transactions per second")
parser.add_argument("tps_limit_per_generator", type=int, help="Maximum amount of transactions per second a single generator can have.", default=4000)
parser.add_argument("log_dir", type=str, help="Path to directory where trx logs should be written.")
parser.add_argument("action_name", type=str, help="The action name applied to the provided action data input")
parser.add_argument("action_data", type=str, help="The path to the json action data file or json action data description string to use")
parser.add_argument("abi_file", type=str, help="The path to the contract abi file to use for the supplied transaction action data")
parser.add_argument("actions_data", type=str, help="The json actions data file or json actions data description string to use")
parser.add_argument("actions_auths", type=str, help="The json actions auth file or json actions auths description string to use, containting authAcctName to activePrivateKey pairs.")
parser.add_argument("peer_endpoint", type=str, help="set the peer endpoint to send transactions to", default="127.0.0.1")
parser.add_argument("port", type=int, help="set the peer endpoint port to send transactions to", default=9876)
args = parser.parse_args()
Expand All @@ -158,7 +163,7 @@ def main():
trxGenLauncher = TransactionGeneratorsLauncher(chainId=args.chain_id, lastIrreversibleBlockId=args.last_irreversible_block_id,
contractOwnerAccount=args.contract_owner_account, accts=args.accounts,
privateKeys=args.priv_keys, trxGenDurationSec=args.trx_gen_duration, logDir=args.log_dir,
abiFile=args.abi_file, actionName=args.action_name, actionData=args.action_data,
abiFile=args.abi_file, actionsData=args.actions_data, actionsAuths=args.actions_auths,
peerEndpoint=args.peer_endpoint, port=args.port,
tpsTrxGensConfig=TpsTrxGensConfig(targetTps=args.target_tps, tpsLimitPerGenerator=args.tps_limit_per_generator))

Expand Down
10 changes: 7 additions & 3 deletions tests/performance_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ configure_file(nodeos_log_2_0_14.txt.gz nodeos_log_2_0_14.txt.gz COPYONLY)
configure_file(nodeos_log_3_2.txt.gz nodeos_log_3_2.txt.gz COPYONLY)
configure_file(genesis.json genesis.json COPYONLY)
configure_file(validate_nodeos_plugin_args.py validate_nodeos_plugin_args.py COPYONLY)
configure_file(userTrxData.json userTrxData.json COPYONLY)
configure_file(userTrxDataTransfer.json userTrxDataTransfer.json COPYONLY)
configure_file(userTrxDataNewAccount.json userTrxDataNewAccount.json COPYONLY)

add_test(NAME performance_test_basic COMMAND tests/performance_tests/performance_test_basic.py -v -p 1 -n 1 --target-tps 20 --tps-limit-per-generator 10 --clean-run WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME performance_test_basic_ex_trx_spec COMMAND tests/performance_tests/performance_test_basic.py -v -p 1 -n 1 --target-tps 20 --tps-limit-per-generator 10 --clean-run --user-trx-data-file tests/performance_tests/userTrxData.json WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME performance_test_basic COMMAND tests/performance_tests/performance_test_basic.py -v -p 1 -n 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --clean-run WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME performance_test_basic_ex_transfer_trx_spec COMMAND tests/performance_tests/performance_test_basic.py -v -p 1 -n 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --clean-run --user-trx-data-file tests/performance_tests/userTrxDataTransfer.json WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME performance_test_basic_ex_new_acct_trx_spec COMMAND tests/performance_tests/performance_test_basic.py -v -p 1 -n 1 --target-tps 20 --tps-limit-per-generator 10 --test-duration-sec 5 --clean-run --user-trx-data-file tests/performance_tests/userTrxDataNewAccount.json WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME log_reader_tests COMMAND tests/performance_tests/log_reader_tests.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME validate_nodeos_plugin_args COMMAND tests/performance_tests/validate_nodeos_plugin_args.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST performance_test_basic PROPERTY LABELS nonparallelizable_tests)
set_property(TEST performance_test_basic_ex_transfer_trx_spec PROPERTY LABELS nonparallelizable_tests)
set_property(TEST performance_test_basic_ex_new_acct_trx_spec PROPERTY LABELS nonparallelizable_tests)

add_subdirectory( NodeosPluginArgs )
Loading

0 comments on commit 8a1fecd

Please sign in to comment.