mirror of
https://github.com/basicswap/basicswap.git
synced 2026-05-30 07:41:41 +02:00
test: print xmr daemon logs on ci failure
This commit is contained in:
@@ -94,12 +94,22 @@ jobs:
|
|||||||
export XMR_BINDIR="$BIN_DIR/monero"
|
export XMR_BINDIR="$BIN_DIR/monero"
|
||||||
pytest tests/basicswap/test_btc_xmr.py::TestBTC -k "test_003_api or test_02_a_leader_recover_a_lock_tx"
|
pytest tests/basicswap/test_btc_xmr.py::TestBTC -k "test_003_api or test_02_a_leader_recover_a_lock_tx"
|
||||||
- name: Run test_encrypted_xmr_reload
|
- name: Run test_encrypted_xmr_reload
|
||||||
|
id: test_encrypted_xmr_reload
|
||||||
run: |
|
run: |
|
||||||
export PYTHONPATH=$(pwd)
|
export PYTHONPATH=$(pwd)
|
||||||
export TEST_PATH=${TEST_RELOAD_PATH}
|
export TEST_PATH=${TEST_RELOAD_PATH}
|
||||||
mkdir -p ${TEST_PATH}/bin
|
mkdir -p ${TEST_PATH}/bin
|
||||||
cp -r $BIN_DIR/* ${TEST_PATH}/bin/
|
cp -r $BIN_DIR/* ${TEST_PATH}/bin/
|
||||||
pytest tests/basicswap/extended/test_encrypted_xmr_reload.py
|
pytest tests/basicswap/extended/test_encrypted_xmr_reload.py
|
||||||
|
- name: Print log files on failure
|
||||||
|
if: ${{ failure() && steps.test_encrypted_xmr_reload.conclusion == 'failure' }}
|
||||||
|
run: |
|
||||||
|
for i in 0 1 2; do
|
||||||
|
for logname in core_stderr core_stdout wallet_stderr wallet_stdout; do
|
||||||
|
echo "=== client${i} ${logname}.log ==="
|
||||||
|
cat /tmp/test_basicswap/client${i}/monero/${logname}.log || true
|
||||||
|
done
|
||||||
|
done
|
||||||
- name: Run selenium tests
|
- name: Run selenium tests
|
||||||
id: selenium_tests
|
id: selenium_tests
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ def prepare_nodes(
|
|||||||
|
|
||||||
class TestBase(unittest.TestCase):
|
class TestBase(unittest.TestCase):
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestBase, cls).setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
cls.delay_event = threading.Event()
|
cls.delay_event = threading.Event()
|
||||||
signal.signal(
|
signal.signal(
|
||||||
@@ -645,7 +645,7 @@ class XmrTestBase(TestBase):
|
|||||||
prepare_nodes(3, "monero")
|
prepare_nodes(3, "monero")
|
||||||
|
|
||||||
def start_processes(self):
|
def start_processes(self):
|
||||||
multiprocessing.set_start_method("fork")
|
multiprocessing.set_start_method("spawn")
|
||||||
self.delay_event.clear()
|
self.delay_event.clear()
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ def updateThreadDCR(cls):
|
|||||||
if "double spend" in str(e):
|
if "double spend" in str(e):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
logging.warning("updateThreadDCR purchaseticket {}".format(e))
|
logging.warning(f"updateThreadDCR purchaseticket {e}")
|
||||||
cls.delay_event.wait(0.5)
|
cls.delay_event.wait(0.5)
|
||||||
try:
|
try:
|
||||||
if num_passed >= 5:
|
if num_passed >= 5:
|
||||||
@@ -260,7 +260,7 @@ def updateThreadDCR(cls):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning("updateThreadDCR generate {}".format(e))
|
logging.warning(f"updateThreadDCR generate {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("updateThreadDCR error", str(e))
|
print("updateThreadDCR error", str(e))
|
||||||
cls.delay_event.wait(random.uniform(cls.dcr_update_min, cls.dcr_update_max))
|
cls.delay_event.wait(random.uniform(cls.dcr_update_min, cls.dcr_update_max))
|
||||||
@@ -272,7 +272,7 @@ def signal_handler(self, sig, frame):
|
|||||||
|
|
||||||
|
|
||||||
def run_process(client_id):
|
def run_process(client_id):
|
||||||
client_path = os.path.join(test_path, "client{}".format(client_id))
|
client_path = os.path.join(test_path, f"client{client_id}")
|
||||||
testargs = [
|
testargs = [
|
||||||
"basicswap-run",
|
"basicswap-run",
|
||||||
"-datadir=" + client_path,
|
"-datadir=" + client_path,
|
||||||
@@ -299,15 +299,24 @@ def start_processes(self):
|
|||||||
for i in range(NUM_NODES):
|
for i in range(NUM_NODES):
|
||||||
waitForServer(self.delay_event, UI_PORT + i)
|
waitForServer(self.delay_event, UI_PORT + i)
|
||||||
|
|
||||||
wallets = read_json_api(UI_PORT + 1, "wallets")
|
|
||||||
|
|
||||||
if "monero" in self.test_coins_list:
|
if "monero" in self.test_coins_list:
|
||||||
|
try:
|
||||||
|
for i in range(8):
|
||||||
|
wallets = read_json_api(UI_PORT + 1, "wallets")
|
||||||
|
if "XMR" in wallets and "main_address" in wallets["XMR"]:
|
||||||
|
break
|
||||||
|
logging.info("Waiting for wallets output")
|
||||||
|
self.delay_event.wait(1.0)
|
||||||
|
self.xmr_addr = wallets["XMR"]["main_address"]
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("{} - wallets json: {}".format(str(e), json.dumps(wallets)))
|
||||||
|
raise
|
||||||
|
|
||||||
xmr_auth = None
|
xmr_auth = None
|
||||||
if os.getenv("XMR_RPC_USER", "") != "":
|
if os.getenv("XMR_RPC_USER", "") != "":
|
||||||
xmr_auth = (os.getenv("XMR_RPC_USER", ""), os.getenv("XMR_RPC_PWD", ""))
|
xmr_auth = (os.getenv("XMR_RPC_USER", ""), os.getenv("XMR_RPC_PWD", ""))
|
||||||
|
|
||||||
self.xmr_addr = wallets["XMR"]["main_address"]
|
num_blocks: int = 100
|
||||||
num_blocks = 100
|
|
||||||
if (
|
if (
|
||||||
callrpc_xmr(XMR_BASE_RPC_PORT + 1, "get_block_count", auth=xmr_auth)[
|
callrpc_xmr(XMR_BASE_RPC_PORT + 1, "get_block_count", auth=xmr_auth)[
|
||||||
"count"
|
"count"
|
||||||
@@ -322,10 +331,11 @@ def start_processes(self):
|
|||||||
auth=xmr_auth,
|
auth=xmr_auth,
|
||||||
)
|
)
|
||||||
logging.info(
|
logging.info(
|
||||||
"XMR blocks: %d",
|
"XMR blocks: {}".format(
|
||||||
callrpc_xmr(XMR_BASE_RPC_PORT + 1, "get_block_count", auth=xmr_auth)[
|
callrpc_xmr(XMR_BASE_RPC_PORT + 1, "get_block_count", auth=xmr_auth)[
|
||||||
"count"
|
"count"
|
||||||
],
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.btc_addr = callbtcrpc(0, "getnewaddress", ["mining_addr", "bech32"])
|
self.btc_addr = callbtcrpc(0, "getnewaddress", ["mining_addr", "bech32"])
|
||||||
@@ -402,9 +412,7 @@ def start_processes(self):
|
|||||||
have_blocks: int = callfirorpc(0, "getblockcount")
|
have_blocks: int = callfirorpc(0, "getblockcount")
|
||||||
if have_blocks < num_blocks:
|
if have_blocks < num_blocks:
|
||||||
logging.info(
|
logging.info(
|
||||||
"Mining %d Firo blocks to %s",
|
f"Mining {num_blocks - have_blocks} Firo blocks to {self.firo_addr}"
|
||||||
num_blocks - have_blocks,
|
|
||||||
self.firo_addr,
|
|
||||||
)
|
)
|
||||||
callfirorpc(
|
callfirorpc(
|
||||||
0,
|
0,
|
||||||
@@ -420,9 +428,7 @@ def start_processes(self):
|
|||||||
have_blocks: int = callbchrpc(0, "getblockcount")
|
have_blocks: int = callbchrpc(0, "getblockcount")
|
||||||
if have_blocks < num_blocks:
|
if have_blocks < num_blocks:
|
||||||
logging.info(
|
logging.info(
|
||||||
"Mining %d Bitcoincash blocks to %s",
|
f"Mining {num_blocks - have_blocks} Bitcoincash blocks to {self.bch_addr}"
|
||||||
num_blocks - have_blocks,
|
|
||||||
self.bch_addr,
|
|
||||||
)
|
)
|
||||||
callbchrpc(
|
callbchrpc(
|
||||||
0,
|
0,
|
||||||
@@ -437,9 +443,7 @@ def start_processes(self):
|
|||||||
have_blocks: int = calldogerpc(0, "getblockcount")
|
have_blocks: int = calldogerpc(0, "getblockcount")
|
||||||
if have_blocks < num_blocks:
|
if have_blocks < num_blocks:
|
||||||
logging.info(
|
logging.info(
|
||||||
"Mining %d Dogecoin blocks to %s",
|
f"Mining {num_blocks - have_blocks} Dogecoin blocks to {self.doge_addr}"
|
||||||
num_blocks - have_blocks,
|
|
||||||
self.doge_addr,
|
|
||||||
)
|
)
|
||||||
calldogerpc(
|
calldogerpc(
|
||||||
0, "generatetoaddress", [num_blocks - have_blocks, self.doge_addr]
|
0, "generatetoaddress", [num_blocks - have_blocks, self.doge_addr]
|
||||||
@@ -557,7 +561,10 @@ class BaseTestWithPrepare(unittest.TestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(BaseTestWithPrepare, cls).setUpClass()
|
cls.addClassCleanup(
|
||||||
|
cls.finalise
|
||||||
|
) # tearDownClass is not run if setUpClass fails
|
||||||
|
super().setUpClass()
|
||||||
|
|
||||||
random.seed(time.time())
|
random.seed(time.time())
|
||||||
|
|
||||||
@@ -577,7 +584,7 @@ class BaseTestWithPrepare(unittest.TestCase):
|
|||||||
waitForServer(cls.delay_event, UI_PORT + 1)
|
waitForServer(cls.delay_event, UI_PORT + 1)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def finalise(cls):
|
||||||
logging.info("Stopping test")
|
logging.info("Stopping test")
|
||||||
cls.delay_event.set()
|
cls.delay_event.set()
|
||||||
if cls.update_thread:
|
if cls.update_thread:
|
||||||
@@ -598,7 +605,6 @@ class BaseTestWithPrepare(unittest.TestCase):
|
|||||||
|
|
||||||
class Test(BaseTestWithPrepare):
|
class Test(BaseTestWithPrepare):
|
||||||
def test_persistent(self):
|
def test_persistent(self):
|
||||||
|
|
||||||
while not self.delay_event.is_set():
|
while not self.delay_event.is_set():
|
||||||
logging.info("Looping indefinitely, ctrl+c to exit.")
|
logging.info("Looping indefinitely, ctrl+c to exit.")
|
||||||
self.delay_event.wait(10)
|
self.delay_event.wait(10)
|
||||||
|
|||||||
Reference in New Issue
Block a user