Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many Transaction Long Running Test #88

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/ubuntu-2004.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ jobs:
tar -xzf ubuntu-2004-build/build.tar.gz
export DOCKER="docker run --rm -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} -w ${GITHUB_WORKSPACE} ${UBUNTU_2004_IMAGE}"
docker pull ${UBUNTU_2004_IMAGE}
${DOCKER} bash -c 'cd build && ctest --output-on-failure -L "long_running_tests" -E "nodeos_short_fork_take_over_lr_test|nodeos_under_min_avail_ram_lr_test|nodeos_startup_catchup_lr_test|nodeos_producer_watermark_lr_test|nodeos_irreversible_mode_lr_test|nodeos_forked_chain_lr_test|nodeos_voting_lr_test"'
${DOCKER} bash -c 'cd build && ctest --output-on-failure -L "long_running_tests" -E "nodeos_short_fork_take_over_lr_test|nodeos_under_min_avail_ram_lr_test|nodeos_startup_catchup_lr_test|nodeos_producer_watermark_lr_test|nodeos_irreversible_mode_lr_test|nodeos_forked_chain_lr_test|nodeos_voting_lr_test|nodeos_high_transaction_lr_test"'
nodeos_short_fork_take_over_lr_test:
name: Ubuntu 20.04 | nodeos_short_fork_take_over_lr_test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -367,3 +367,24 @@ jobs:
export DOCKER="docker run --rm -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} -w ${GITHUB_WORKSPACE} ${UBUNTU_2004_IMAGE}"
docker pull ${UBUNTU_2004_IMAGE}
${DOCKER} bash -c 'cd build && ctest --output-on-failure -R nodeos_voting_lr_test'
nodeos_high_transaction_lr_test:
name: Ubuntu 20.04 | nodeos_high_transaction_lr_test
runs-on: ubuntu-latest
needs: ubuntu-2004-build
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- name: Download build
uses: actions/download-artifact@v1
with:
name: ubuntu-2004-build
- name: nodeos_high_transaction_lr_test
run: |
set -e
tar -xzf ubuntu-2004-build/build.tar.gz
export DOCKER="docker run --rm -v ${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE} -w ${GITHUB_WORKSPACE} ${UBUNTU_2004_IMAGE}"
docker pull ${UBUNTU_2004_IMAGE}
${DOCKER} bash -c 'cd build && ctest --output-on-failure -R nodeos_high_transaction_lr_test'
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ship_client.js ${CMAKE_CURRENT_BINARY
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/large-lib-test.py ${CMAKE_CURRENT_BINARY_DIR}/large-lib-test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/http_plugin_test.py ${CMAKE_CURRENT_BINARY_DIR}/http_plugin_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_high_latency_test.py ${CMAKE_CURRENT_BINARY_DIR}/p2p_high_latency_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nodeos_high_transaction_test.py ${CMAKE_CURRENT_BINARY_DIR}/nodeos_high_transaction_test.py COPYONLY)

#To run plugin_test with all log from blockchain displayed, put --verbose after --, i.e. plugin_test -- --verbose
add_test(NAME plugin_test COMMAND plugin_test --report_level=detailed --color_output)
Expand Down Expand Up @@ -158,6 +159,9 @@ endif()
add_test(NAME nodeos_producer_watermark_lr_test COMMAND tests/nodeos_producer_watermark_test.py -v --clean-run --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_producer_watermark_lr_test PROPERTY LABELS long_running_tests)

add_test(NAME nodeos_high_transaction_lr_test COMMAND tests/nodeos_high_transaction_test.py -v --clean-run --dump-error-detail -p 4 -n 8 --num-transactions 10000 --max-transactions-per-second 500 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST nodeos_high_transaction_lr_test PROPERTY LABELS long_running_tests)


add_test(NAME cli_test COMMAND tests/cli_test.py WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

Expand Down
32 changes: 32 additions & 0 deletions tests/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,38 @@ def isValid(policy):
policy == PFSetupPolicy.PREACTIVATE_FEATURE_ONLY or \
policy == PFSetupPolicy.FULL

# Class for generating distinct names for many accounts
class NamedAccounts:

def __init__(self, cluster, numAccounts):
Utils.Print("NamedAccounts %d" % (numAccounts))
self.numAccounts=numAccounts
self.accounts=cluster.createAccountKeys(numAccounts)
if self.accounts is None:
Utils.errorExit("FAILURE - create keys")
accountNum = 0
for account in self.accounts:
Utils.Print("NamedAccounts Name for %d" % (accountNum))
account.name=self.setName(accountNum)
accountNum+=1

def setName(self, num):
retStr="test"
digits=[]
maxDigitVal=5
maxDigits=8
temp=num
while len(digits) < maxDigits:
digit=(num % maxDigitVal)+1
num=int(num/maxDigitVal)
digits.append(digit)

digits.reverse()
retStr += "".join(map(str, digits))

Utils.Print("NamedAccounts Name for %d is %s" % (temp, retStr))
return retStr

# pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-public-methods
class Cluster(object):
Expand Down
57 changes: 39 additions & 18 deletions tests/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ def __keyContext(self):
def __contextDesc(self):
return "%s%s" % (self.desc, self.__keyContext())

def add(self, newKey):
def hasKey(self, newKey, subSection = None):
assert isinstance(newKey, str), print("ERROR: Trying to use %s as a key" % (newKey))
subSection=self.sections[-1]
if subSection is None:
subSection=self.sections[-1]
assert isinstance(subSection, dict), print("ERROR: Calling \"add\" method when context is not a dictionary. %s in %s" % (self.__contextDesc(), self.__json()))
assert newKey in subSection, print("ERROR: %s%s does not contain key \"%s\". %s" % (self.__contextDesc(), key, self.__json()))
return newKey in subSection

def add(self, newKey):
subSection=self.sections[-1]
assert self.hasKey(newKey, subSection), print("ERROR: %s does not contain key \"%s\". %s" % (self.__contextDesc(), newKey, self.__json()))
current=subSection[newKey]
self.sections.append(current)
self.keyContext.append(newKey)
Expand All @@ -127,16 +132,28 @@ def getCurrent(self):
@staticmethod
def getTransStatus(trans):
cntxt=Node.Context(trans, "trans")
cntxt.add("processed")
# could be a transaction response
if cntxt.hasKey("processed"):
cntxt.add("processed")
cntxt.add("receipt")
return cntxt.add("status")

# or what the history plugin returns
cntxt.add("trx")
cntxt.add("receipt")
return cntxt.add("status")

@staticmethod
def getTransBlockNum(trans):
cntxt=Node.Context(trans, "trans")
cntxt.add("processed")
cntxt.add("action_traces")
cntxt.index(0)
# could be a transaction response
if cntxt.hasKey("processed"):
cntxt.add("processed")
cntxt.add("action_traces")
cntxt.index(0)
return cntxt.add("block_num")

# or what the history plugin returns
return cntxt.add("block_num")


Expand Down Expand Up @@ -696,7 +713,7 @@ def waitForIrreversibleBlock(self, blockNum, timeout=None, blockType=BlockType.h
return self.waitForBlock(blockNum, timeout=timeout, blockType=blockType)

# Trasfer funds. Returns "transfer" json return object
def transferFunds(self, source, destination, amountStr, memo="memo", force=False, waitForTransBlock=False, exitOnError=True):
def transferFunds(self, source, destination, amountStr, memo="memo", force=False, waitForTransBlock=False, exitOnError=True, reportStatus=True):
assert isinstance(amountStr, str)
assert(source)
assert(isinstance(source, Account))
Expand All @@ -719,7 +736,7 @@ def transferFunds(self, source, destination, amountStr, memo="memo", force=False
if Utils.Debug:
end=time.perf_counter()
Utils.Print("cmd Duration: %.3f sec" % (end-start))
self.trackCmdTransaction(trans)
self.trackCmdTransaction(trans, reportStatus=reportStatus)
except subprocess.CalledProcessError as ex:
end=time.perf_counter()
msg=ex.output.decode("utf-8")
Expand Down Expand Up @@ -996,7 +1013,7 @@ def setPermission(self, account, code, pType, requirement, waitForTransBlock=Fal

return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)

def delegatebw(self, fromAccount, netQuantity, cpuQuantity, toAccount=None, transferTo=False, waitForTransBlock=False, exitOnError=False):
def delegatebw(self, fromAccount, netQuantity, cpuQuantity, toAccount=None, transferTo=False, waitForTransBlock=False, exitOnError=False, reportStatus=True):
if toAccount is None:
toAccount=fromAccount

Expand All @@ -1006,7 +1023,7 @@ def delegatebw(self, fromAccount, netQuantity, cpuQuantity, toAccount=None, tran
cmdDesc, fromAccount.name, toAccount.name, netQuantity, CORE_SYMBOL, cpuQuantity, CORE_SYMBOL, transferStr)
msg="fromAccount=%s, toAccount=%s" % (fromAccount.name, toAccount.name);
trans=self.processCleosCmd(cmd, cmdDesc, exitOnError=exitOnError, exitMsg=msg)
self.trackCmdTransaction(trans)
self.trackCmdTransaction(trans, reportStatus=reportStatus)

return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)

Expand Down Expand Up @@ -1447,24 +1464,28 @@ def launchCmd(self, cmd, nodeId, cachePopen=False):
self.pid=popen.pid
if Utils.Debug: Utils.Print("start Node host=%s, port=%s, pid=%s, cmd=%s" % (self.host, self.port, self.pid, self.cmd))

def trackCmdTransaction(self, trans, ignoreNonTrans=False):
def trackCmdTransaction(self, trans, ignoreNonTrans=False, reportStatus=True):
if trans is None:
if Utils.Debug: Utils.Print(" cmd returned transaction: %s" % (trans))
return

if ignoreNonTrans and not Node.isTrans(trans):
if Utils.Debug: Utils.Print(" cmd returned a non-transaction")
if Utils.Debug: Utils.Print(" cmd returned a non-transaction: %s" % (trans))
return

transId=Node.getTransId(trans)
if Utils.Debug:
if transId in self.transCache.keys():
replaceMsg="replacing previous trans=\n%s" % json.dumps(self.transCache[transId], indent=2, sort_keys=True)
else:
replaceMsg=""

if Utils.Debug and reportStatus:
status=Node.getTransStatus(trans)
blockNum=Node.getTransBlockNum(trans)
if transId in self.transCache.keys():
replaceMsg="replacing previous trans=\n%s" % json.dumps(self.transCache[transId], indent=2, sort_keys=True)
else:
replaceMsg=""
Utils.Print(" cmd returned transaction id: %s, status: %s, (possible) block num: %s %s" % (transId, status, blockNum, replaceMsg))
elif Utils.Debug:
Utils.Print(" cmd returned transaction id: %s %s" % (transId, replaceMsg))

self.transCache[transId]=trans

def reportStatus(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/TestHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def parse_args(includeArgs, applicationSpecificArgs=AppArgs()):
parser.add_argument("-h", "--host", type=str, help="%s host name" % (Utils.EosServerName),
default=TestHelper.LOCAL_HOST)
if "--port" in includeArgs:
parser.add_argument("-p", "--port", type=int, help="%s host port" % Utils.EosServerName,
parser.add_argument("--port", type=int, help="%s host port" % Utils.EosServerName,
default=TestHelper.DEFAULT_PORT)
if "--wallet-host" in includeArgs:
parser.add_argument("--wallet-host", type=str, help="%s host" % Utils.EosWalletName,
Expand Down
2 changes: 1 addition & 1 deletion tests/nodeos_forked_chain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def getBlock(self, blockNum):
Print("Compare Blocklog")
cluster.compareBlockLogs()
Print(Utils.FileDivider)
Print("Compare Blocklog")
Print("Print Blocklog")
cluster.printBlockLog()
Print(Utils.FileDivider)

Expand Down
Loading