fix: loadtest/reconnectingpty tweak timeout (#5300)

* flaky

* fix: load test increase timeout

* Remove flaky

* Improvement

* only Linux

* WaitSuperLong

* Fix

* Try longer

* Try: sleep 120
This commit is contained in:
Marcin Tojek 2022-12-06 14:40:38 +01:00 committed by GitHub
parent 03328d4f6d
commit 84872d970d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 26 deletions

View File

@ -3,7 +3,6 @@ package reconnectingpty_test
import (
"bytes"
"context"
"runtime"
"testing"
"time"
@ -23,9 +22,6 @@ import (
func Test_Runner(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("PTY is flakey on non-Linux platforms")
}
t.Run("OK", func(t *testing.T) {
t.Parallel()
@ -40,7 +36,7 @@ func Test_Runner(t *testing.T) {
LogOutput: true,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -50,7 +46,9 @@ func Test_Runner(t *testing.T) {
require.NoError(t, err)
require.Contains(t, logStr, "Output:")
require.Contains(t, logStr, "\thello world")
// OSX: Output:\n\thello world\n
// 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
require.Contains(t, logStr, "hello world\n")
})
t.Run("NoLogOutput", func(t *testing.T) {
@ -66,7 +64,7 @@ func Test_Runner(t *testing.T) {
LogOutput: false,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -76,12 +74,10 @@ func Test_Runner(t *testing.T) {
require.NoError(t, err)
require.NotContains(t, logStr, "Output:")
require.NotContains(t, logStr, "\thello world")
})
t.Run("Timeout", func(t *testing.T) {
t.Parallel()
t.Skip("Flaky: https://github.com/coder/coder/issues/5187")
t.Run("NoTimeout", func(t *testing.T) {
t.Parallel()
@ -93,11 +89,11 @@ func Test_Runner(t *testing.T) {
Init: codersdk.ReconnectingPTYInit{
Command: "echo 'hello world'",
},
Timeout: httpapi.Duration(5 * time.Second),
Timeout: httpapi.Duration(2 * testutil.WaitSuperLong),
LogOutput: true,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -115,13 +111,13 @@ func Test_Runner(t *testing.T) {
runner := reconnectingpty.NewRunner(client, reconnectingpty.Config{
AgentID: agentID,
Init: codersdk.ReconnectingPTYInit{
Command: "sleep 5",
Command: "sleep 120",
},
Timeout: httpapi.Duration(2 * time.Second),
LogOutput: true,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -144,14 +140,14 @@ func Test_Runner(t *testing.T) {
runner := reconnectingpty.NewRunner(client, reconnectingpty.Config{
AgentID: agentID,
Init: codersdk.ReconnectingPTYInit{
Command: "sleep 5",
Command: "sleep 120",
},
Timeout: httpapi.Duration(2 * time.Second),
ExpectTimeout: true,
LogOutput: true,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -171,12 +167,12 @@ func Test_Runner(t *testing.T) {
Init: codersdk.ReconnectingPTYInit{
Command: "echo 'hello world'",
},
Timeout: httpapi.Duration(5 * time.Second),
Timeout: httpapi.Duration(2 * testutil.WaitSuperLong),
ExpectTimeout: true,
LogOutput: true,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -190,7 +186,6 @@ func Test_Runner(t *testing.T) {
t.Run("ExpectOutput", func(t *testing.T) {
t.Parallel()
t.Skip("Flaky: https://github.com/coder/coder/issues/5187")
t.Run("Matches", func(t *testing.T) {
t.Parallel()
@ -206,7 +201,7 @@ func Test_Runner(t *testing.T) {
LogOutput: false,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)
@ -230,7 +225,7 @@ func Test_Runner(t *testing.T) {
LogOutput: false,
})
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
defer cancel()
logs := bytes.NewBuffer(nil)

View File

@ -7,9 +7,10 @@ import "time"
// Constants for timing out operations, usable for creating contexts
// that timeout or in require.Eventually.
const (
WaitShort = 5 * time.Second
WaitMedium = 10 * time.Second
WaitLong = 15 * time.Second
WaitShort = 5 * time.Second
WaitMedium = 10 * time.Second
WaitLong = 15 * time.Second
WaitSuperLong = 60 * time.Second
)
// Constants for delaying repeated operations, e.g. in

View File

@ -7,9 +7,10 @@ import "time"
//
// Windows durations are adjusted for slow CI workers.
const (
WaitShort = 10 * time.Second
WaitMedium = 20 * time.Second
WaitLong = 30 * time.Second
WaitShort = 10 * time.Second
WaitMedium = 20 * time.Second
WaitLong = 30 * time.Second
WaitSuperLong = 60 * time.Second
)
// Constants for delaying repeated operations, e.g. in