Skip to content

chore: Use standardized test timeouts and delays #3291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Commit rest of the modified files
  • Loading branch information
mafredri committed Jul 29, 2022
commit c17a577af343e9fd92676c489129ae3ae6990b83
9 changes: 5 additions & 4 deletions coderd/coderdtest/coderdtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/coder/coder/coderd/util/ptr"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/cryptorand"
"github.com/coder/coder/internal/testutil"
"github.com/coder/coder/provisioner/echo"
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
Expand Down Expand Up @@ -179,7 +180,7 @@ func newWithCloser(t *testing.T, options *Options) (*codersdk.Client, io.Closer)
AgentConnectionUpdateFrequency: 150 * time.Millisecond,
// Force a long disconnection timeout to ensure
// agents are not marked as disconnected during slow tests.
AgentInactiveDisconnectTimeout: 5 * time.Second,
AgentInactiveDisconnectTimeout: testutil.WaitShort,
AccessURL: serverURL,
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),
CacheDir: t.TempDir(),
Expand Down Expand Up @@ -412,7 +413,7 @@ func AwaitTemplateVersionJob(t *testing.T, client *codersdk.Client, version uuid
var err error
templateVersion, err = client.TemplateVersion(context.Background(), version)
return assert.NoError(t, err) && templateVersion.Job.CompletedAt != nil
}, 5*time.Second, 25*time.Millisecond)
}, testutil.WaitShort, testutil.IntervalFast)
return templateVersion
}

Expand All @@ -426,7 +427,7 @@ func AwaitWorkspaceBuildJob(t *testing.T, client *codersdk.Client, build uuid.UU
var err error
workspaceBuild, err = client.WorkspaceBuild(context.Background(), build)
return assert.NoError(t, err) && workspaceBuild.Job.CompletedAt != nil
}, 5*time.Second, 25*time.Millisecond)
}, testutil.WaitShort, testutil.IntervalFast)
return workspaceBuild
}

Expand All @@ -450,7 +451,7 @@ func AwaitWorkspaceAgents(t *testing.T, client *codersdk.Client, build uuid.UUID
}
}
return true
}, 15*time.Second, 50*time.Millisecond)
}, testutil.WaitLong, testutil.IntervalMedium)
return resources
}

Expand Down
3 changes: 2 additions & 1 deletion pty/ptytest/ptytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"

"github.com/coder/coder/internal/testutil"
"github.com/coder/coder/pty"
)

Expand Down Expand Up @@ -85,7 +86,7 @@ type PTY struct {
func (p *PTY) ExpectMatch(str string) string {
p.t.Helper()

timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
timeout, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

var buffer bytes.Buffer
Expand Down