Skip to content

Commit

Permalink
GH-1251 Add integration test that verifies auto oc tierup
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jun 23, 2023
1 parent d4ee46b commit dc00e24
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
2 changes: 2 additions & 0 deletions libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ namespace eosio { namespace chain {
once_is_enough = true;
}
if(cd) {
if (!context.is_applying_block())
tlog("speculatively executing ${h} with eos vm oc", ("h", code_hash));
my->eosvmoc->exec->execute(*cd, my->eosvmoc->mem, context);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ add_test(NAME read-only-trx-basic-test COMMAND tests/read_only_trx_test.py -v -p
set_property(TEST read-only-trx-basic-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --read-only-threads 6 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-eos-vm-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable --read-only-threads 6 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME read-only-trx-parallel-eos-vm-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable all --read-only-threads 6 --num-test-runs 3 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-eos-vm-oc-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME read-only-trx-parallel-no-oc-test COMMAND tests/read_only_trx_test.py -v -p 2 -n 3 --eos-vm-oc-enable none --read-only-threads 6 --num-test-runs 2 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST read-only-trx-parallel-no-oc-test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME subjective_billing_test COMMAND tests/subjective_billing_test.py -v -p 2 -n 4 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
set_property(TEST subjective_billing_test PROPERTY LABELS nonparallelizable_tests)
add_test(NAME get_account_test COMMAND tests/get_account_test.py -v -p 2 ${UNSHARE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down
10 changes: 10 additions & 0 deletions tests/TestHarness/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ def findStderrFiles(path):
files.sort()
return files

def findInLog(self, searchStr):
dataDir=Utils.getNodeDataDir(self.nodeId)
files=Node.findStderrFiles(dataDir)
for file in files:
with open(file, 'r') as f:
for line in f:
if searchStr in line:
return True
return False

def analyzeProduction(self, specificBlockNum=None, thresholdMs=500):
dataDir=Utils.getNodeDataDir(self.nodeId)
files=Node.findStderrFiles(dataDir)
Expand Down
29 changes: 26 additions & 3 deletions tests/read_only_trx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
appArgs=AppArgs()
appArgs.add(flag="--read-only-threads", type=int, help="number of read-only threads", default=0)
appArgs.add(flag="--num-test-runs", type=int, help="number of times to run the tests", default=1)
appArgs.add_bool(flag="--eos-vm-oc-enable", help="enable eos-vm-oc")
appArgs.add(flag="--eos-vm-oc-enable", type=str, help="specify eos-vm-oc-enable option", default="auto")
appArgs.add(flag="--wasm-runtime", type=str, help="if set to eos-vm-oc, must compile with EOSIO_EOS_VM_OC_DEVELOPER", default="eos-vm-jit")

args=TestHelper.parse_args({"-p","-n","-d","-s","--nodes-file","--seed"
Expand All @@ -47,9 +47,12 @@
Utils.Debug=debug
testSuccessful=False
errorInThread=False
noOC = args.eos_vm_oc_enable == "none"
allOC = args.eos_vm_oc_enable == "all"

random.seed(seed) # Use a fixed seed for repeatability.
cluster=Cluster(unshared=args.unshared, keepRunning=True if nodesFile is not None else args.leave_running, keepLogs=args.keep_logs)
# all debuglevel so that "executing ${h} with eos vm oc" is logged
cluster=Cluster(loggingLevel="all", unshared=args.unshared, keepRunning=True if nodesFile is not None else args.leave_running, keepLogs=args.keep_logs)

walletMgr=WalletMgr(True)
EOSIO_ACCT_PRIVATE_DEFAULT_KEY = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
Expand All @@ -61,6 +64,15 @@
userAccountName = "user"
payloadlessAccountName = "payloadless"

def getCodeHash(node, account):
# Example get code result: code hash: 67d0598c72e2521a1d588161dad20bbe9f8547beb5ce6d14f3abd550ab27d3dc
cmd = f"get code {account}"
codeHash = node.processCleosCmd(cmd, cmd, silentErrors=False, returnType=ReturnType.raw)
if codeHash is None: errorExit(f"Unable to get code {account} from node {node.nodeId}")
else: codeHash = codeHash.split(' ')[2].strip()
if Utils.Debug: Utils.Print(f"{account} code hash: {codeHash}")
return codeHash

def startCluster():
global total_nodes
global producerNode
Expand Down Expand Up @@ -91,7 +103,8 @@ def startCluster():
specificExtraNodeosArgs[pnodes]+=" --read-only-threads "
specificExtraNodeosArgs[pnodes]+=str(args.read_only_threads)
if args.eos_vm_oc_enable:
specificExtraNodeosArgs[pnodes]+=" --eos-vm-oc-enable all"
specificExtraNodeosArgs[pnodes]+=" --eos-vm-oc-enable "
specificExtraNodeosArgs[pnodes]+=args.eos_vm_oc_enable
if args.wasm_runtime:
specificExtraNodeosArgs[pnodes]+=" --wasm-runtime "
specificExtraNodeosArgs[pnodes]+=args.wasm_runtime
Expand All @@ -107,6 +120,12 @@ def startCluster():
producerNode = cluster.getNode()
apiNode = cluster.nodes[-1]

eosioCodeHash = getCodeHash(producerNode, "eosio")
# eosio.* should be using oc unless oc tierup disabled
Utils.Print(f"search: executing {eosioCodeHash} with eos vm oc")
found = producerNode.findInLog(f"executing {eosioCodeHash} with eos vm oc")
assert( found or (noOC and not found) )

def deployTestContracts():
Utils.Print("create test accounts")
testAccount = Account(testAccountName)
Expand Down Expand Up @@ -243,6 +262,10 @@ def basicTests():
assert(results[0])
apiNode.waitForTransactionInBlock(results[1]['transaction_id'])

testAccountCodeHash = getCodeHash(producerNode, testAccountName)
found = producerNode.findInLog(f"executing {testAccountCodeHash} with eos vm oc")
assert( (allOC and found) or not found )

# verify the return value (age) from read-only is the same as created.
Print("Send a read-only Get transaction to verify previous Insert")
results = sendTransaction(testAccountName, 'getage', {"user": userAccountName}, opts='--read')
Expand Down

0 comments on commit dc00e24

Please sign in to comment.