mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-20 06:34:20 +01:00
backup: Fix flaky test due to logs being dropped on shutdown
We were writing logs directly before killing `lightningd` which resulted in the logs being lost. The subsequent check for the log-lines then would fail obviously.
This commit is contained in:
@@ -10,6 +10,7 @@ import os
|
|||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
plugin = Plugin()
|
plugin = Plugin()
|
||||||
@@ -252,6 +253,7 @@ def get_backend(destination, create=False, require_init=False):
|
|||||||
|
|
||||||
def abort(reason: str) -> None:
|
def abort(reason: str) -> None:
|
||||||
plugin.log(reason)
|
plugin.log(reason)
|
||||||
|
time.sleep(1)
|
||||||
plugin.rpc.stop()
|
plugin.rpc.stop()
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
||||||
|
|||||||
@@ -177,16 +177,24 @@ def test_failing_restore(nf, directory):
|
|||||||
'plugin': plugin_path,
|
'plugin': plugin_path,
|
||||||
'backup-destination': bdest,
|
'backup-destination': bdest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def section(comment):
|
||||||
|
print("="*25, comment, "="*25)
|
||||||
|
|
||||||
|
section("Starting node for the first time")
|
||||||
l1 = nf.get_node(options=opts, cleandir=False)
|
l1 = nf.get_node(options=opts, cleandir=False)
|
||||||
l1.stop()
|
l1.stop()
|
||||||
|
|
||||||
# Now fudge the data_version:
|
# Now fudge the data_version:
|
||||||
|
section("Simulating a restore of an old version")
|
||||||
l1.db.execute("UPDATE vars SET intval = intval - 2 WHERE name = 'data_version'")
|
l1.db.execute("UPDATE vars SET intval = intval - 2 WHERE name = 'data_version'")
|
||||||
|
|
||||||
|
section("Restarting node, should fail")
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
l1.start()
|
l1.start()
|
||||||
|
|
||||||
l1.daemon.proc.wait()
|
l1.daemon.proc.wait()
|
||||||
|
section("Verifying the node died with an error")
|
||||||
assert(l1.daemon.is_in_log(r'lost some state') is not None)
|
assert(l1.daemon.is_in_log(r'lost some state') is not None)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user