Skip to content

Commit

Permalink
tests/test_plugin.py: Test builtin plugins are important.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZmnSCPxj committed Jul 30, 2020
1 parent 377bd9f commit 58c0493
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
expected_channel_features, account_balance,
check_coin_moves, first_channel_id, check_coin_moves_idx
)
from pyln.testing.utils import TailableProc

import json
import os
import pytest
import re
import signal
import sqlite3
import subprocess
import time
Expand Down Expand Up @@ -1576,3 +1578,41 @@ def test_important_plugin(node_factory):
n.rpc.call("die", {})
n.daemon.wait_for_log('Plugin marked as important by --important-plugin=suicidal_plugin.py')
wait_for(lambda: not n.daemon.running)

# Check that if a builtin plugin dies, we fail.
n = node_factory.get_node(may_fail=True, allow_broken_log=True,
# The log message with the bcli PID is printed
# very early in the logs.
start=False)
# Start the daemon directly, not via the node object n.start,
# because the normal n.daemon.start and n.start methods will
# wait for "Starting server with public key" and will execute
# getinfo, both of which are very much after plugins are
# started.
# And the PIDs of plugins are only seen at plugin startup.
TailableProc.start(n.daemon)
assert n.daemon.running
# Extract the pid of bcli.
r = n.daemon.wait_for_log(r'started([0-9]*).*plugins/bcli')
pidstr = re.search(r'.*started\(([0-9]*)\)', r).group(1)
# Kill bcli.
os.kill(int(pidstr), signal.SIGKILL)
# node should die as well.
n.daemon.wait_for_log('Plugin marked as important by --important-plugin=bcli')
wait_for(lambda: not n.daemon.running)

# Check we can kill a builtin plugin if we say it is unimportant.
n = node_factory.get_node(may_fail=True,
options={'unimportant-plugin': 'pay'})
# Start the daemon directly.
TailableProc.start(n.daemon)
assert n.daemon.running
# Extract the pid of pay.
r = n.daemon.wait_for_log(r'started([0-9]*).*plugins/pay')
pidstr = re.search(r'.*started\(([0-9]*)\)', r).group(1)
# Kill pay.
os.kill(int(pidstr), signal.SIGKILL)
# node should go on.
n.daemon.wait_for_log("plugin-pay: Killing plugin")
assert n.daemon.running
TailableProc.stop(n.daemon)

0 comments on commit 58c0493

Please sign in to comment.