Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84872d9

Browse files
authored
fix: loadtest/reconnectingpty tweak timeout (#5300)
* flaky * fix: load test increase timeout * Remove flaky * Improvement * only Linux * WaitSuperLong * Fix * Try longer * Try: sleep 120
1 parent 03328d4 commit 84872d9

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

loadtest/reconnectingpty/run_test.go

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package reconnectingpty_test
33
import (
44
"bytes"
55
"context"
6-
"runtime"
76
"testing"
87
"time"
98

@@ -23,9 +22,6 @@ import (
2322

2423
func Test_Runner(t *testing.T) {
2524
t.Parallel()
26-
if runtime.GOOS != "linux" {
27-
t.Skip("PTY is flakey on non-Linux platforms")
28-
}
2925

3026
t.Run("OK", func(t *testing.T) {
3127
t.Parallel()
@@ -40,7 +36,7 @@ func Test_Runner(t *testing.T) {
4036
LogOutput: true,
4137
})
4238

43-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
39+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
4440
defer cancel()
4541

4642
logs := bytes.NewBuffer(nil)
@@ -50,7 +46,9 @@ func Test_Runner(t *testing.T) {
5046
require.NoError(t, err)
5147

5248
require.Contains(t, logStr, "Output:")
53-
require.Contains(t, logStr, "\thello world")
49+
// OSX: Output:\n\thello world\n
50+
// Win: Output:\n\t\x1b[2J\x1b[m\x1b[H\x1b]0;Administrator: C:\\Program Files\\PowerShell\\7\\pwsh.exe\a\x1b[?25hhello world\n
51+
require.Contains(t, logStr, "hello world\n")
5452
})
5553

5654
t.Run("NoLogOutput", func(t *testing.T) {
@@ -66,7 +64,7 @@ func Test_Runner(t *testing.T) {
6664
LogOutput: false,
6765
})
6866

69-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
67+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
7068
defer cancel()
7169

7270
logs := bytes.NewBuffer(nil)
@@ -76,12 +74,10 @@ func Test_Runner(t *testing.T) {
7674
require.NoError(t, err)
7775

7876
require.NotContains(t, logStr, "Output:")
79-
require.NotContains(t, logStr, "\thello world")
8077
})
8178

8279
t.Run("Timeout", func(t *testing.T) {
8380
t.Parallel()
84-
t.Skip("Flaky: https://github.com/coder/coder/issues/5187")
8581

8682
t.Run("NoTimeout", func(t *testing.T) {
8783
t.Parallel()
@@ -93,11 +89,11 @@ func Test_Runner(t *testing.T) {
9389
Init: codersdk.ReconnectingPTYInit{
9490
Command: "echo 'hello world'",
9591
},
96-
Timeout: httpapi.Duration(5 * time.Second),
92+
Timeout: httpapi.Duration(2 * testutil.WaitSuperLong),
9793
LogOutput: true,
9894
})
9995

100-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
96+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
10197
defer cancel()
10298

10399
logs := bytes.NewBuffer(nil)
@@ -115,13 +111,13 @@ func Test_Runner(t *testing.T) {
115111
runner := reconnectingpty.NewRunner(client, reconnectingpty.Config{
116112
AgentID: agentID,
117113
Init: codersdk.ReconnectingPTYInit{
118-
Command: "sleep 5",
114+
Command: "sleep 120",
119115
},
120116
Timeout: httpapi.Duration(2 * time.Second),
121117
LogOutput: true,
122118
})
123119

124-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
120+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
125121
defer cancel()
126122

127123
logs := bytes.NewBuffer(nil)
@@ -144,14 +140,14 @@ func Test_Runner(t *testing.T) {
144140
runner := reconnectingpty.NewRunner(client, reconnectingpty.Config{
145141
AgentID: agentID,
146142
Init: codersdk.ReconnectingPTYInit{
147-
Command: "sleep 5",
143+
Command: "sleep 120",
148144
},
149145
Timeout: httpapi.Duration(2 * time.Second),
150146
ExpectTimeout: true,
151147
LogOutput: true,
152148
})
153149

154-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
150+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
155151
defer cancel()
156152

157153
logs := bytes.NewBuffer(nil)
@@ -171,12 +167,12 @@ func Test_Runner(t *testing.T) {
171167
Init: codersdk.ReconnectingPTYInit{
172168
Command: "echo 'hello world'",
173169
},
174-
Timeout: httpapi.Duration(5 * time.Second),
170+
Timeout: httpapi.Duration(2 * testutil.WaitSuperLong),
175171
ExpectTimeout: true,
176172
LogOutput: true,
177173
})
178174

179-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
175+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
180176
defer cancel()
181177

182178
logs := bytes.NewBuffer(nil)
@@ -190,7 +186,6 @@ func Test_Runner(t *testing.T) {
190186

191187
t.Run("ExpectOutput", func(t *testing.T) {
192188
t.Parallel()
193-
t.Skip("Flaky: https://github.com/coder/coder/issues/5187")
194189

195190
t.Run("Matches", func(t *testing.T) {
196191
t.Parallel()
@@ -206,7 +201,7 @@ func Test_Runner(t *testing.T) {
206201
LogOutput: false,
207202
})
208203

209-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
204+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
210205
defer cancel()
211206

212207
logs := bytes.NewBuffer(nil)
@@ -230,7 +225,7 @@ func Test_Runner(t *testing.T) {
230225
LogOutput: false,
231226
})
232227

233-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
228+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
234229
defer cancel()
235230

236231
logs := bytes.NewBuffer(nil)

testutil/duration.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import "time"
77
// Constants for timing out operations, usable for creating contexts
88
// that timeout or in require.Eventually.
99
const (
10-
WaitShort = 5 * time.Second
11-
WaitMedium = 10 * time.Second
12-
WaitLong = 15 * time.Second
10+
WaitShort = 5 * time.Second
11+
WaitMedium = 10 * time.Second
12+
WaitLong = 15 * time.Second
13+
WaitSuperLong = 60 * time.Second
1314
)
1415

1516
// Constants for delaying repeated operations, e.g. in

testutil/duration_windows.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import "time"
77
//
88
// Windows durations are adjusted for slow CI workers.
99
const (
10-
WaitShort = 10 * time.Second
11-
WaitMedium = 20 * time.Second
12-
WaitLong = 30 * time.Second
10+
WaitShort = 10 * time.Second
11+
WaitMedium = 20 * time.Second
12+
WaitLong = 30 * time.Second
13+
WaitSuperLong = 60 * time.Second
1314
)
1415

1516
// Constants for delaying repeated operations, e.g. in

0 commit comments

Comments
 (0)