chore: Use standardized test timeouts and delays (#3291)

This commit is contained in:
Mathias Fredriksson
2022-08-01 15:45:05 +03:00
committed by GitHub
parent 3d0febdd90
commit 4730c589fe
25 changed files with 198 additions and 109 deletions

View File

@ -56,6 +56,7 @@ import (
"github.com/coder/coder/provisionerd"
"github.com/coder/coder/provisionersdk"
"github.com/coder/coder/provisionersdk/proto"
"github.com/coder/coder/testutil"
)
type Options struct {
@ -180,7 +181,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(),
@ -414,7 +415,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
}
@ -428,7 +429,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
}
@ -452,7 +453,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
}