Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion invoices/test_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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(60 * time.Second):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use named constant

err := pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
if err != nil {
panic(fmt.Sprintf("error writing to std out "+
Expand Down
26 changes: 22 additions & 4 deletions watchtower/wtclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2354,10 +2366,16 @@ 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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we check that the error is what we expect?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, because if something else is wrong we wait for no good reason

h.server.addr.IdentityKey, nil,
)

return err == nil
}, waitTime)
require.NoError(h.t, err)

// Add a new tower.
Expand Down
Loading