Merge pull request #10464 from gijswijs/fix-itest-flakes
Fix flaky watchtower and invoice tests
This commit is contained in:
2 files changed
+34
-5
No files matched your search
@@ -100,6 +100,8 @@ const (
|
||||
var (
|
||||
testTimeout = 5 * time.Second
|
||||
|
||||
testTimeoutLong = time.Minute
|
||||
|
||||
testTime = time.Date(2018, time.February, 2, 14, 0, 0, 0, time.UTC)
|
||||
|
||||
testInvoicePreimage = lntypes.Preimage{1}
|
||||
@@ -255,7 +257,9 @@ func timeout() func() {
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-time.After(10 * time.Second):
|
||||
// Use a longer timeout to accommodate slow Postgres database
|
||||
// setup and migrations when running tests in parallel.
|
||||
case <-time.After(testTimeoutLong):
|
||||
err := pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error writing to std out "+
|
||||
|
||||
@@ -1811,8 +1811,10 @@ var clientTests = []clientTest{
|
||||
require.NoError(h.t, err)
|
||||
|
||||
cancel := make(chan struct{})
|
||||
dialStarted := make(chan struct{})
|
||||
h.net.registerConnCallback(
|
||||
h.server.addr, func(peer wtserver.Peer) {
|
||||
close(dialStarted)
|
||||
select {
|
||||
case <-h.quit:
|
||||
case <-cancel:
|
||||
@@ -1847,6 +1849,16 @@ var clientTests = []clientTest{
|
||||
err = h.clientMgr.AddTower(towerAddr)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Wait for the dial to start so that we know the
|
||||
// session negotiation has begun and the address is
|
||||
// locked.
|
||||
select {
|
||||
case <-dialStarted:
|
||||
|
||||
case <-time.After(waitTime):
|
||||
h.t.Fatal("timeout waiting for dial to start")
|
||||
}
|
||||
|
||||
// Assert that if the client attempts to remove the
|
||||
// tower's first address, then it will error due to
|
||||
// address currently being locked for session
|
||||
@@ -2354,10 +2366,23 @@ var clientTests = []clientTest{
|
||||
}, waitTime)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Now remove the tower.
|
||||
err = h.clientMgr.RemoveTower(
|
||||
h.server.addr.IdentityKey, nil,
|
||||
)
|
||||
// Now remove the tower. We use wait.Predicate here
|
||||
// because the address may still be locked by an active
|
||||
// session.
|
||||
err = wait.Predicate(func() bool {
|
||||
err := h.clientMgr.RemoveTower(
|
||||
h.server.addr.IdentityKey, nil,
|
||||
)
|
||||
if err != nil {
|
||||
require.ErrorIs(
|
||||
h.t, err, wtclient.ErrAddrInUse,
|
||||
)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}, waitTime)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Add a new tower.
|
||||
|
||||
Reference in new issue
Block a user