Skip to content

Commit

Permalink
pytest: slow down test_autoclean.
Browse files Browse the repository at this point in the history
CI is really slow: it sees all three expire at once.  But making the
timeouts too long is painful in non-VALGRIND, so I ended up making it
conditional.

```
         # First it expires.
        wait_for(lambda: only_one(l3.rpc.listinvoices('inv1')['invoices'])['status'] == 'expired')
        # Now will get autocleaned
        wait_for(lambda: l3.rpc.listinvoices('inv1')['invoices'] == [])
>       assert l3.rpc.autoclean_status()['autoclean']['expiredinvoices']['cleaned'] == 1
E       assert 3 == 1

tests/test_plugin.py:2975: AssertionError
```

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and cdecker committed Sep 22, 2022
1 parent e021884 commit 651753b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2949,10 +2949,19 @@ def test_autoclean(node_factory):
'may_reconnect': True},
wait_for_announce=True)

# Under valgrind in CI, it can 50 seconds between creating invoice
# and restarting.
if node_factory.valgrind:
short_timeout = 10
longer_timeout = 60
else:
short_timeout = 5
longer_timeout = 20

assert l3.rpc.autoclean_status('expiredinvoices')['autoclean']['expiredinvoices']['enabled'] is False
l3.rpc.invoice(amount_msat=12300, label='inv1', description='description1', expiry=5)
l3.rpc.invoice(amount_msat=12300, label='inv2', description='description2', expiry=20)
l3.rpc.invoice(amount_msat=12300, label='inv3', description='description3', expiry=20)
l3.rpc.invoice(amount_msat=12300, label='inv1', description='description1', expiry=short_timeout)
l3.rpc.invoice(amount_msat=12300, label='inv2', description='description2', expiry=longer_timeout)
l3.rpc.invoice(amount_msat=12300, label='inv3', description='description3', expiry=longer_timeout)
inv4 = l3.rpc.invoice(amount_msat=12300, label='inv4', description='description4', expiry=2000)
inv5 = l3.rpc.invoice(amount_msat=12300, label='inv5', description='description5', expiry=2000)

Expand Down Expand Up @@ -2990,11 +2999,14 @@ def test_autoclean(node_factory):

# Same with inv2/3
wait_for(lambda: only_one(l3.rpc.listinvoices('inv2')['invoices'])['status'] == 'expired')
wait_for(lambda: only_one(l3.rpc.listinvoices('inv3')['invoices'])['status'] == 'expired')

# Give it time to notice.
# Give it time to notice (runs every 10 seconds, give it 15)
time.sleep(15)

# They're still there!
assert l3.rpc.listinvoices('inv2')['invoices'] != []
assert l3.rpc.listinvoices('inv3')['invoices'] != []

# Restart keeps it disabled.
l3.restart()
Expand Down

0 comments on commit 651753b

Please sign in to comment.