mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
fix: Add timeouts to every tailnet ping (#4986)
A ping isn't guaranteed to deliver, so these need to have a tight timeout for tests to not flake.
This commit is contained in:
@ -499,7 +499,9 @@ func TestAgent(t *testing.T) {
|
|||||||
|
|
||||||
conn, _ := setupAgent(t, codersdk.WorkspaceAgentMetadata{}, 0)
|
conn, _ := setupAgent(t, codersdk.WorkspaceAgentMetadata{}, 0)
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
_, err := conn.Ping(context.Background())
|
ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.IntervalFast)
|
||||||
|
defer cancelFunc()
|
||||||
|
_, err := conn.Ping(ctx)
|
||||||
return err == nil
|
return err == nil
|
||||||
}, testutil.WaitMedium, testutil.IntervalFast)
|
}, testutil.WaitMedium, testutil.IntervalFast)
|
||||||
conn1, err := conn.DialContext(context.Background(), l.Addr().Network(), l.Addr().String())
|
conn1, err := conn.DialContext(context.Background(), l.Addr().Network(), l.Addr().String())
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"cdr.dev/slog"
|
"cdr.dev/slog"
|
||||||
"github.com/coder/coder/codersdk"
|
"github.com/coder/coder/codersdk"
|
||||||
|
@ -72,6 +72,8 @@ func TestWorkspaceAgent(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer dialer.Close()
|
defer dialer.Close()
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
|
ctx, cancelFunc := context.WithTimeout(ctx, testutil.IntervalFast)
|
||||||
|
defer cancelFunc()
|
||||||
_, err := dialer.Ping(ctx)
|
_, err := dialer.Ping(ctx)
|
||||||
return err == nil
|
return err == nil
|
||||||
}, testutil.WaitMedium, testutil.IntervalFast)
|
}, testutil.WaitMedium, testutil.IntervalFast)
|
||||||
@ -133,6 +135,8 @@ func TestWorkspaceAgent(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer dialer.Close()
|
defer dialer.Close()
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
|
ctx, cancelFunc := context.WithTimeout(ctx, testutil.IntervalFast)
|
||||||
|
defer cancelFunc()
|
||||||
_, err := dialer.Ping(ctx)
|
_, err := dialer.Ping(ctx)
|
||||||
return err == nil
|
return err == nil
|
||||||
}, testutil.WaitMedium, testutil.IntervalFast)
|
}, testutil.WaitMedium, testutil.IntervalFast)
|
||||||
@ -194,6 +198,8 @@ func TestWorkspaceAgent(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer dialer.Close()
|
defer dialer.Close()
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
|
ctx, cancelFunc := context.WithTimeout(ctx, testutil.IntervalFast)
|
||||||
|
defer cancelFunc()
|
||||||
_, err := dialer.Ping(ctx)
|
_, err := dialer.Ping(ctx)
|
||||||
return err == nil
|
return err == nil
|
||||||
}, testutil.WaitMedium, testutil.IntervalFast)
|
}, testutil.WaitMedium, testutil.IntervalFast)
|
||||||
|
@ -179,6 +179,8 @@ func TestWorkspaceAgentListen(t *testing.T) {
|
|||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
}()
|
}()
|
||||||
require.Eventually(t, func() bool {
|
require.Eventually(t, func() bool {
|
||||||
|
ctx, cancelFunc := context.WithTimeout(ctx, testutil.IntervalFast)
|
||||||
|
defer cancelFunc()
|
||||||
_, err := conn.Ping(ctx)
|
_, err := conn.Ping(ctx)
|
||||||
return err == nil
|
return err == nil
|
||||||
}, testutil.WaitLong, testutil.IntervalFast)
|
}, testutil.WaitLong, testutil.IntervalFast)
|
||||||
|
Reference in New Issue
Block a user