File tree 1 file changed +19
-6
lines changed 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 6
6
"io"
7
7
"net"
8
8
"net/http"
9
+ "os"
9
10
"sync"
10
11
"testing"
11
12
"time"
@@ -22,13 +23,25 @@ import (
22
23
"github.com/coder/coder/peer"
23
24
)
24
25
25
- const (
26
- disconnectedTimeout = 5 * time .Second
27
- failedTimeout = disconnectedTimeout * 5
28
- keepAliveInterval = time .Millisecond * 2
29
- )
30
-
31
26
var (
27
+ disconnectedTimeout = func () time.Duration {
28
+ // Connection state is unfortunately time-based. When resources are
29
+ // contended, a connection can take greater than this timeout to
30
+ // handshake, which results in a test flake.
31
+ //
32
+ // During local testing resources are rarely contended. Reducing this
33
+ // timeout leads to faster local development.
34
+ //
35
+ // In CI resources are frequently contended, so increasing this value
36
+ // results in less flakes.
37
+ if os .Getenv ("CI" ) == "true" {
38
+ return 4 * time .Second
39
+ }
40
+ return 100 * time .Millisecond
41
+ }()
42
+ failedTimeout = disconnectedTimeout * 4
43
+ keepAliveInterval = time .Millisecond * 2
44
+
32
45
// There's a global race in the vnet library allocation code.
33
46
// This mutex locks around the creation of the vnet.
34
47
vnetMutex = sync.Mutex {}
You can’t perform that action at this time.
0 commit comments