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

Add TestHarness python integration scripts to dev package #818

Merged
merged 20 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f81921a
Fix lost force option.
oschwaldp-oci Mar 14, 2023
0a1ec82
Add TestHarness python integration scripts to dev-install package.
oschwaldp-oci Mar 14, 2023
6f16347
Fix install steps to only apply to COMPONENT dev
oschwaldp-oci Mar 14, 2023
d56b97e
Update core_symbol imports to reflect it being part of TestHarness mo…
oschwaldp-oci Mar 15, 2023
b2db52d
Update install mkdir and symbolic linking steps.
oschwaldp-oci Mar 16, 2023
d55b043
Merge branch 'eosio-launcher-python-port' into dev-install-add-testha…
oschwaldp-oci Mar 16, 2023
315874a
DataDir now returns absolute path instead of relative.
oschwaldp-oci Mar 16, 2023
c8d36c2
Merge branch 'eosio-launcher-python-port' into dev-install-add-testha…
oschwaldp-oci Mar 16, 2023
38f8c59
Address peer review comment.
oschwaldp-oci Mar 16, 2023
be154da
Address peer review comments.
oschwaldp-oci Mar 16, 2023
b6007e0
Peer review recommended using sh instead of bash as more likely to ex…
oschwaldp-oci Mar 16, 2023
61b0efe
Address a couple more review comments.
oschwaldp-oci Mar 16, 2023
08b1eb5
Addressing peer review comment.
oschwaldp-oci Mar 16, 2023
8c8ad50
Don't overwrite the env variable so you get both postinst and prerm
oschwaldp-oci Mar 16, 2023
9c066a7
Update package.cmake
oschwaldp-oci Mar 16, 2023
c46400c
Best effort attempt to remove the directorys we may have created duri…
oschwaldp-oci Mar 17, 2023
7d78b88
Merge branch 'dev-install-add-testharness' of ssh://github.com/Antelo…
oschwaldp-oci Mar 17, 2023
e7e66a5
Simplify postinst and prerm scripts
oschwaldp-oci Mar 17, 2023
3e9d098
Merge branch 'eosio-launcher-python-port' into dev-install-add-testha…
oschwaldp-oci Mar 17, 2023
d6e6a93
Fix CORE_SYMBOL import and cleanup other imports.
oschwaldp-oci Mar 17, 2023
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
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,53 @@ configure_file(programs/cleos/LICENSE.CLI11 licen

install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/licenses/leap" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/" COMPONENT base)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libraries/testing/contracts DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/libraries/testing COMPONENT dev EXCLUDE_FROM_ALL
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "Makefile" EXCLUDE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unittests/contracts DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/unittests COMPONENT dev EXCLUDE_FROM_ALL
PATTERN "CMakeFiles" EXCLUDE
PATTERN "*.cmake" EXCLUDE
PATTERN "Makefile" EXCLUDE)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests/TestHarness DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/tests COMPONENT dev EXCLUDE_FROM_ALL
FILES_MATCHING
PATTERN "*.py"
PATTERN "*.json"
PATTERN "__pycache__" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests/launcher.py DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/tests COMPONENT dev EXCLUDE_FROM_ALL)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21)
# Cmake versions < 3.21 did not support installing symbolic links to a directory via install(FILES ...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for putting the very clear explanation around this

# Cmake 3.21 fixed this (https://gitlab.kitware.com/cmake/cmake/-/commit/d71a7cc19d6e03f89581efdaa8d63db216184d40)
# If/when the lowest cmake version supported becomes >= 3.21, the else block as well as the postinit and prerm scripts
# would be a good option to remove in favor of using the facilities in cmake / cpack directly.

add_custom_target(link_target ALL
COMMAND ${CMAKE_COMMAND} -E make_directory lib/python3/dist-packages
COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../share/leap_testing/tests/TestHarness lib/python3/dist-packages/TestHarness
COMMAND ${CMAKE_COMMAND} -E make_directory share/leap_testing
COMMAND ${CMAKE_COMMAND} -E create_symlink ../../bin share/leap_testing/bin)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/python3/dist-packages/TestHarness DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages COMPONENT dev EXCLUDE_FROM_ALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/leap_testing/bin DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing COMPONENT dev EXCLUDE_FROM_ALL)
else()
# The following install(CODE ...) steps are necessary for `make dev-install` to work on cmake versions < 3.21.
# However, it can flag as an error if using `make package` instead of `make dev-install` for installation.
# This is due to those directories and symbolic links being created in the postinit script during the package install instead.

# Note If/when doing `make package`, it is not a true error if you see:
# Error creating directory "/<leap_install_dir>/lib/python3/dist-packages".
# CMake Error: failed to create symbolic link '/<leap_install_dir>/lib/python3/dist-packages/TestHarness': no such file or directory
# CMake Error: failed to create symbolic link '/<leap_install_dir>/share/leap_testing/bin': no such file or directory

install(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages)" COMPONENT dev EXCLUDE_FROM_ALL)
install(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../share/leap_testing/tests/TestHarness ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages/TestHarness)" COMPONENT dev EXCLUDE_FROM_ALL)
install(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ../../bin ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/bin)" COMPONENT dev EXCLUDE_FROM_ALL)

# The `make package` installation of symlinks happens via the `postinst` script installed in cmake.package via the line below
endif()

configure_file(${CMAKE_SOURCE_DIR}/libraries/cli11/bash-completion/completions/leap-util
${CMAKE_BINARY_DIR}/programs/leap-util/bash-completion/completions/leap-util COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/cli11/bash-completion/completions/cleos
Expand Down
3 changes: 2 additions & 1 deletion package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ set(CPACK_DEBIAN_BASE_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.deb")
string(REGEX REPLACE "^(${CMAKE_PROJECT_NAME})" "\\1-dev" CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_BASE_FILE_NAME}")

#deb package tooling will be unable to detect deps for the dev package. llvm is tricky since we don't know what package could have been used; try to figure it out
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "libboost-all-dev, libssl-dev, libgmp-dev")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "libboost-all-dev, libssl-dev, libgmp-dev, python3-numpy")
find_program(DPKG_QUERY "dpkg-query")
if(DPKG_QUERY AND OS_RELEASE MATCHES "\n?ID=\"?ubuntu" AND LLVM_CMAKE_DIR)
execute_process(COMMAND "${DPKG_QUERY}" -S "${LLVM_CMAKE_DIR}" COMMAND cut -d: -f1 RESULT_VARIABLE LLVM_PKG_FIND_RESULT OUTPUT_VARIABLE LLVM_PKG_FIND_OUTPUT)
Expand All @@ -70,6 +70,7 @@ if(DPKG_QUERY AND OS_RELEASE MATCHES "\n?ID=\"?ubuntu" AND LLVM_CMAKE_DIR)
string(APPEND CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ", ${LLVM_PKG_FIND_OUTPUT}")
endif()
endif()
set(CPACK_DEBIAN_DEV_PACKAGE_CONTROL_EXTRA ${CMAKE_BINARY_DIR}/scripts/postinst;${CMAKE_BINARY_DIR}/scripts/prerm)
oschwaldp-oci marked this conversation as resolved.
Show resolved Hide resolved

#since rpm packages aren't component based, make sure description picks up more detailed description instead of just summary
set(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_COMPONENT_BASE_DESCRIPTION}")
Expand Down
2 changes: 1 addition & 1 deletion programs/nodeos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if( UNIX AND NOT APPLE )
endif()

configure_file(config.hpp.in config.hpp ESCAPE_QUOTES)
configure_file(logging.json ${CMAKE_BINARY_DIR}/logging.json COPYONLY)
configure_file(logging.json ${CMAKE_BINARY_DIR}/tests/TestHarness/logging-template.json)

target_include_directories(${NODE_EXECUTABLE_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

Expand Down
2 changes: 2 additions & 0 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ configure_file(eosio-tn_down.sh eosio-tn_down.sh COPYONLY)
configure_file(eosio-tn_roll.sh eosio-tn_roll.sh COPYONLY)
configure_file(eosio-tn_up.sh eosio-tn_up.sh COPYONLY)
configure_file(abi_is_json.py abi_is_json.py COPYONLY)
configure_file(postinst .)
configure_file(prerm .)
13 changes: 13 additions & 0 deletions scripts/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -e

if [ ! -L ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages/TestHarness ]; then
mkdir -p ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages
ln -s ../../../share/leap_testing/tests/TestHarness ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages/TestHarness
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages, would ${Python_SITELIB} be more appropriate since the system python installation directory doesn't depend on the installation path of leap?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spoonincode

Per our discussion:

So, from what I can tell there are a couple caveats here:

It's populated for free after executing FindPackage(Python), but only since CMake 3.12.
So that leaves me having to do something in the cmake file like:
execute_process(COMMAND python3 -c "from distutils import sysconfig;print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))" OUTPUT_VARIABLE Python_SITELIB)

But am not sure if finding Python_SITELIB from cmake is a good idea.
Which means we could push that into the preinst and prerm scripts. But then we lose the ability to use relative paths in the symbolic link we're creating. Which then causes some additional weirdness for the make install path vs. the make package path.

From our discussion, sounds like the thought is to:

Leave it as is for now. Then when dropping support for ubuntu18 and bumping cmake we can tend to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur, finding Python_SITELIB on the host is probably not optimal.

But we could potentially use /usr/lib/python3/dist-packages. It would work for Debian Bookworm and Ubuntu 18 through 23.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created to investigate this in the future: #839

fi

if [ ! -L ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/bin ]; then
mkdir -p ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing
ln -s ../../bin ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/bin
ScottBailey marked this conversation as resolved.
Show resolved Hide resolved
fi
4 changes: 4 additions & 0 deletions scripts/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

rm -f ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages/TestHarness
rm -f ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/bin
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have caught this before.

Suggested change
rm -f ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages/TestHarness
rm -f ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing/bin
rm -rf ${CMAKE_INSTALL_FULL_LIBDIR}/python3/dist-packages
rm -rf ${CMAKE_INSTALL_FULL_DATAROOTDIR}/leap_testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm nervous about this change. What if it is installed into a common location where python3/dist-packages/ could have non-leap owner resources we don't want to just destroy. I almost think I need to check at each level and only remove if the dir is empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I agree, I don't think we should touch anything other then the symlinks we created. I would even consider not mkdiring these: leap_testing is created & removed by way of the package anyways. dist-packages isn't really ours to own; and our dependency on python3-numpy (ergo python3) guarantees it exists before us anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about dist packages. You could do a combination 'rmdir -p' for the directors and rm -r for the symlinks, and that would protect us, I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to make it as simple as possible, I'd suggest removing the mkdirs since afaict they're guaranteed to be there by the time the postinst script runs. Then you're only responsible for removing the symlinks in prerm (unchanged from how it is now).

That allows the postinst & prerm to be 100% the opposite of each other without worrying about removing directories and whatnot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the solution I implemented and tested: c46400c

Best effort attempt to remove the directories we may have created during the install.

Can ignore failed directory deletion as they may be installing to location that has more than leap in it, for instance the ~/lib/python3/dist-packages, however if it is empty it is a safe assumption that it is in the location the install created it and can be removed as the inverse uninstall operation.

2 changes: 0 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ target_include_directories( plugin_test PUBLIC
${CMAKE_SOURCE_DIR}/unittests
${CMAKE_BINARY_DIR}/unittests/include/ )

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core_symbol.py.in ${CMAKE_CURRENT_BINARY_DIR}/core_symbol.py)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/dawn_515/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/dawn_515/test.sh COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/block_log_util_test.py ${CMAKE_CURRENT_BINARY_DIR}/block_log_util_test.py COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/block_log_retain_blocks_test.py ${CMAKE_CURRENT_BINARY_DIR}/block_log_retain_blocks_test.py COPYONLY)
Expand Down
1 change: 1 addition & 0 deletions tests/TestHarness/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
configure_file(__init__.py . COPYONLY)
configure_file(core_symbol.py.in core_symbol.py)
configure_file(testUtils.py . COPYONLY)
configure_file(WalletMgr.py . COPYONLY)
configure_file(Node.py . COPYONLY)
Expand Down
20 changes: 12 additions & 8 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import socket
from pathlib import Path

from core_symbol import CORE_SYMBOL
from .core_symbol import CORE_SYMBOL
from .testUtils import Account
from .testUtils import BlockLogAction
from .testUtils import Utils
Expand Down Expand Up @@ -133,6 +133,10 @@ def __init__(self, walletd=False, localCluster=True, host="localhost", port=8888
self.nodeosVers=nodeosVers
self.nodeosLogPath=Path(Utils.TestLogRoot) / Path(f'{Path(sys.argv[0]).stem}{os.getpid()}')

self.launcherPath = Path(__file__).resolve().parents[1] / "launcher.py"
self.libTestingContractsPath = Path(__file__).resolve().parents[2] / "libraries" / "testing" / "contracts"
self.unittestsContractsPath = Path(__file__).resolve().parents[2] / "unittests" / "contracts"

if unshared:
unshare(CLONE_NEWNET)
for index, name in socket.if_nameindex():
Expand Down Expand Up @@ -259,7 +263,7 @@ def launch(self, pnodes=1, unstartedNodes=0, totalNodes=1, prodCount=1, topo="me
time.sleep(2)
loggingLevelDictString = json.dumps(self.loggingLevelDict, separators=(',', ':'))
cmd="%s %s -p %s -n %s -d %s -i %s -f %s --unstarted-nodes %s --logging-level %s --logging-level-map %s" % (
sys.executable, "tests/launcher.py", pnodes, totalNodes, delay, datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3],
sys.executable, str(self.launcherPath), pnodes, totalNodes, delay, datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3],
producerFlag, unstartedNodes, self.loggingLevel, loggingLevelDictString)
cmdArr=cmd.split()
if self.staging:
Expand Down Expand Up @@ -1083,11 +1087,11 @@ def bootstrap(self, biosNode, totalNodes, prodCount, totalProducers, pfSetupPoli
return None

contract="eosio.bios"
contractDir="libraries/testing/contracts/%s" % (contract)
contractDir= str(self.libTestingContractsPath / contract)
if PFSetupPolicy.hasPreactivateFeature(pfSetupPolicy):
contractDir="libraries/testing/contracts/old_versions/v1.7.0-develop-preactivate_feature/%s" % (contract)
contractDir=str(self.libTestingContractsPath / "old_versions" / "v1.7.0-develop-preactivate_feature" / contract)
else:
contractDir="libraries/testing/contracts/old_versions/v1.6.0-rc3/%s" % (contract)
contractDir=str(self.libTestingContractsPath / "old_versions" / "v1.6.0-rc3" / contract)
wasmFile="%s.wasm" % (contract)
abiFile="%s.abi" % (contract)
Utils.Print("Publish %s contract" % (contract))
Expand Down Expand Up @@ -1203,7 +1207,7 @@ def createSystemAccount(accountName):
eosioTokenAccount = copy.deepcopy(eosioAccount)
eosioTokenAccount.name = 'eosio.token'
contract="eosio.token"
contractDir="unittests/contracts/%s" % (contract)
contractDir=str(self.unittestsContractsPath / contract)
wasmFile="%s.wasm" % (contract)
abiFile="%s.abi" % (contract)
Utils.Print("Publish %s contract" % (contract))
Expand Down Expand Up @@ -1259,7 +1263,7 @@ def createSystemAccount(accountName):

if loadSystemContract:
contract="eosio.system"
contractDir="unittests/contracts/%s" % (contract)
contractDir=str(self.unittestsContractsPath / contract)
wasmFile="%s.wasm" % (contract)
abiFile="%s.abi" % (contract)
Utils.Print("Publish %s contract" % (contract))
Expand Down Expand Up @@ -1443,7 +1447,7 @@ def dumpErrorDetails(self):
def killall(self, kill=True, silent=True, allInstances=False):
"""Kill cluster nodeos instances. allInstances will kill all nodeos instances running on the system."""
signalNum=9 if kill else 15
cmd="%s -k %d --nogen -p 1 -n 1 --nodeos-log-path %s" % ("python3 tests/launcher.py", signalNum, self.nodeosLogPath)
cmd="%s -k %d --nogen -p 1 -n 1 --nodeos-log-path %s" % (f"python3 {str(self.launcherPath)}", signalNum, self.nodeosLogPath)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
if 0 != subprocess.call(cmd.split(), stdout=Utils.FNull):
if not silent: Utils.Print("Launcher failed to shut down eos cluster.")
Expand Down
2 changes: 1 addition & 1 deletion tests/TestHarness/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from datetime import datetime
from datetime import timedelta
from core_symbol import CORE_SYMBOL
from .core_symbol import CORE_SYMBOL
from .queries import NodeosQueries, BlockType
from .transactions import Transactions
from .testUtils import Utils
Expand Down
3 changes: 2 additions & 1 deletion tests/TestHarness/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ['Node', 'Cluster', 'WalletMgr', 'logging', 'depresolver', 'testUtils', 'TestHelper', 'queries', 'transactions', 'launch_transaction_generators', 'TransactionGeneratorsLauncher', 'TpsTrxGensConfig']
__all__ = ['Node', 'Cluster', 'WalletMgr', 'logging', 'depresolver', 'testUtils', 'TestHelper', 'queries', 'transactions', 'launch_transaction_generators', 'TransactionGeneratorsLauncher', 'TpsTrxGensConfig', 'core_symbol']

from .Cluster import Cluster
from .Node import Node
Expand All @@ -9,3 +9,4 @@
from .Node import ReturnType
from .TestHelper import TestHelper
from .launch_transaction_generators import TransactionGeneratorsLauncher, TpsTrxGensConfig
from .core_symbol import CORE_SYMBOL
5 changes: 5 additions & 0 deletions tests/TestHarness/core_symbol.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

sys_core_symbol = os.environ.get('CORE_SYMBOL_NAME')

CORE_SYMBOL=sys_core_symbol if sys_core_symbol else '${CORE_SYMBOL_NAME}'
2 changes: 1 addition & 1 deletion tests/TestHarness/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import urllib.parse
import urllib.error

from core_symbol import CORE_SYMBOL
from .core_symbol import CORE_SYMBOL
from .testUtils import Account
from .testUtils import EnumType
from .testUtils import addEnum
Expand Down
20 changes: 11 additions & 9 deletions tests/TestHarness/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import traceback
import shutil
import sys
from pathlib import Path

###########################################################################################

Expand Down Expand Up @@ -55,29 +56,30 @@ class Utils:
Debug=False
FNull = open(os.devnull, 'w')

EosClientPath="programs/cleos/cleos"
testBinPath = Path(__file__).resolve().parents[2] / 'bin'

EosClientPath=str(testBinPath / "cleos")
MiscEosClientArgs="--no-auto-keosd"

LeapClientPath="programs/leap-util/leap-util"
LeapClientPath=str(testBinPath / "leap-util")

EosWalletName="keosd"
EosWalletPath="programs/keosd/"+ EosWalletName
EosWalletPath=str(testBinPath / EosWalletName)

EosServerName="nodeos"
EosServerPath="programs/nodeos/"+ EosServerName
EosServerPath=str(testBinPath / EosServerName)

EosLauncherPath="programs/eosio-launcher/eosio-launcher"
ShuttingDown=False

EosBlockLogPath="programs/eosio-blocklog/eosio-blocklog"

FileDivider="================================================================="
TestLogRoot="TestLogs"
TestLogRoot=f"{str(Path.cwd().resolve())}/TestLogs"
DataRoot=os.path.basename(sys.argv[0]).rsplit('.',maxsplit=1)[0]
PID = os.getpid()
DataPath= f"{TestLogRoot}/{DataRoot}{PID}"
DataDir= f"{DataPath}/"
ConfigDir="etc/eosio/"
ConfigDir=f"{str(Path.cwd().resolve())}/etc/eosio/"

TimeFmt='%Y-%m-%dT%H:%M:%S.%f'

Expand All @@ -90,10 +92,10 @@ def checkOutputFileWrite(time, cmd, output, error):
stop=Utils.timestamp()
if not hasattr(Utils, "checkOutputFile"):
if not os.path.isdir(Utils.TestLogRoot):
if Utils.Debug: Utils.Print("creating dir %s in dir: %s" % (Utils.TestLogRoot, os.getcwd()))
if Utils.Debug: Utils.Print("TestLogRoot creating dir %s in dir: %s" % (Utils.TestLogRoot, os.getcwd()))
os.mkdir(Utils.TestLogRoot)
if not os.path.isdir(Utils.DataPath):
if Utils.Debug: Utils.Print("creating dir %s in dir: %s" % (Utils.DataPath, os.getcwd()))
if Utils.Debug: Utils.Print("DataPath creating dir %s in dir: %s" % (Utils.DataPath, os.getcwd()))
os.mkdir(Utils.DataPath)
filename=f"{Utils.DataPath}/subprocess_results.log"
if Utils.Debug: Utils.Print("opening %s in dir: %s" % (filename, os.getcwd()))
Expand Down
6 changes: 4 additions & 2 deletions tests/TestHarness/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
import time

from core_symbol import CORE_SYMBOL
from .core_symbol import CORE_SYMBOL
from .depresolver import dep
from .queries import NodeosQueries
from .testUtils import Account
Expand Down Expand Up @@ -220,13 +220,15 @@ def pushTransaction(self, trans, opts="", silentErrors=False, permissions=None):
return (False, msg)

# returns tuple with transaction execution status and transaction
def pushMessage(self, account, action, data, opts, silentErrors=False, signatures=None, expectTrxTrace=True):
def pushMessage(self, account, action, data, opts, silentErrors=False, signatures=None, expectTrxTrace=True, force=False):
cmd="%s %s push action -j %s %s" % (Utils.EosClientPath, self.eosClientArgs(), account, action)
cmdArr=cmd.split()
# not using sign_str, since cmdArr messes up the string
if signatures is not None:
cmdArr.append("--sign-with")
cmdArr.append("[ \"%s\" ]" % ("\", \"".join(signatures)))
if force:
cmdArr.append("-f")
if data is not None:
cmdArr.append(data)
if opts is not None:
Expand Down
2 changes: 0 additions & 2 deletions tests/block_log_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
Print=Utils.Print
errorExit=Utils.errorExit

from core_symbol import CORE_SYMBOL

def verifyBlockLog(expected_block_num, trimmedBlockLog):
firstBlockNum = expected_block_num
for block in trimmedBlockLog:
Expand Down
3 changes: 1 addition & 2 deletions tests/compute_transaction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import random

from TestHarness import Account, Cluster, ReturnType, TestHelper, Utils, WalletMgr
from core_symbol import CORE_SYMBOL
from TestHarness import Account, Cluster, ReturnType, TestHelper, Utils, WalletMgr, CORE_SYMBOL

###############################################################
# compute_transaction_tests
Expand Down
1 change: 0 additions & 1 deletion tests/core_symbol.py.in

This file was deleted.

1 change: 0 additions & 1 deletion tests/get_account_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import random

from TestHarness import Account, Cluster, ReturnType, TestHelper, Utils, WalletMgr
from core_symbol import CORE_SYMBOL

###############################################################
# get_account_test
Expand Down
2 changes: 1 addition & 1 deletion tests/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def write_logging_config_file(self, node):
dex = str(node.index).zfill(2)
if dex in self.args.logging_level_map:
ll = self.args.logging_level_map[dex]
with open(Path(os.getcwd()) / 'logging.json', 'r') as default:
with open(Path(__file__).resolve().parents[0] / 'TestHarness' / 'logging-template.json', 'r') as default:
cfg = json.load(default)
for logger in cfg['loggers']:
logger['level'] = ll
Expand Down
3 changes: 1 addition & 2 deletions tests/launcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import os

from TestHarness import Cluster, Node, TestHelper, Utils, WalletMgr
from TestHarness import Cluster, Node, TestHelper, Utils, WalletMgr, CORE_SYMBOL
from pathlib import Path

###############################################################
Expand All @@ -17,7 +17,6 @@
Print=Utils.Print
errorExit=Utils.errorExit
cmdError=Utils.cmdError
from core_symbol import CORE_SYMBOL

args = TestHelper.parse_args({"--defproducera_prvt_key","--dump-error-details","--dont-launch","--keep-logs",
"-v","--leave-running","--clean-run","--unshared"})
Expand Down
3 changes: 1 addition & 2 deletions tests/nodeos_contrl_c_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import signal
import time

from TestHarness import Cluster, Node, TestHelper, Utils, WalletMgr
from core_symbol import CORE_SYMBOL
from TestHarness import Cluster, Node, TestHelper, Utils, WalletMgr, CORE_SYMBOL

###############################################################
# nodeos_contrl_c_lr_test
Expand Down
Loading