pytest: slow down test_autoclean.

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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-09-22 13:11:15 +09:30 committed by Christian Decker
parent e0218841c2
commit 651753bbd5

View file

@ -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)
@ -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()