mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test(scaletest/createworkspaces): fix ctx init in multiple tests (#16177)
This commit is contained in:
@@ -52,9 +52,6 @@ func Test_Runner(t *testing.T) {
|
|||||||
t.Run("OK", func(t *testing.T) {
|
t.Run("OK", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
client := coderdtest.New(t, &coderdtest.Options{
|
client := coderdtest.New(t, &coderdtest.Options{
|
||||||
IncludeProvisionerDaemon: true,
|
IncludeProvisionerDaemon: true,
|
||||||
})
|
})
|
||||||
@@ -109,6 +106,8 @@ func Test_Runner(t *testing.T) {
|
|||||||
version = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
version = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
||||||
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||||
|
|
||||||
|
ctx := testutil.Context(t, testutil.WaitLong)
|
||||||
|
|
||||||
closerCh := goEventuallyStartFakeAgent(ctx, t, client, authToken)
|
closerCh := goEventuallyStartFakeAgent(ctx, t, client, authToken)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -199,9 +198,6 @@ func Test_Runner(t *testing.T) {
|
|||||||
t.Run("CleanupPendingBuild", func(t *testing.T) {
|
t.Run("CleanupPendingBuild", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
// need to include our own logger because the provisioner (rightly) drops error logs when we shut down the
|
// need to include our own logger because the provisioner (rightly) drops error logs when we shut down the
|
||||||
// test with a build in progress.
|
// test with a build in progress.
|
||||||
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
|
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
|
||||||
@@ -253,7 +249,9 @@ func Test_Runner(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ctx := testutil.Context(t, testutil.WaitLong)
|
||||||
cancelCtx, cancelFunc := context.WithCancel(ctx)
|
cancelCtx, cancelFunc := context.WithCancel(ctx)
|
||||||
|
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
logs := bytes.NewBuffer(nil)
|
logs := bytes.NewBuffer(nil)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -287,6 +285,8 @@ func Test_Runner(t *testing.T) {
|
|||||||
cancelFunc()
|
cancelFunc()
|
||||||
<-done
|
<-done
|
||||||
|
|
||||||
|
ctx = testutil.Context(t, testutil.WaitLong) // Reset ctx to avoid timeouts.
|
||||||
|
|
||||||
// When we run the cleanup, it should be canceled
|
// When we run the cleanup, it should be canceled
|
||||||
cleanupLogs := bytes.NewBuffer(nil)
|
cleanupLogs := bytes.NewBuffer(nil)
|
||||||
cancelCtx, cancelFunc = context.WithCancel(ctx)
|
cancelCtx, cancelFunc = context.WithCancel(ctx)
|
||||||
@@ -340,9 +340,6 @@ func Test_Runner(t *testing.T) {
|
|||||||
t.Run("NoCleanup", func(t *testing.T) {
|
t.Run("NoCleanup", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
client := coderdtest.New(t, &coderdtest.Options{
|
client := coderdtest.New(t, &coderdtest.Options{
|
||||||
IncludeProvisionerDaemon: true,
|
IncludeProvisionerDaemon: true,
|
||||||
})
|
})
|
||||||
@@ -397,6 +394,7 @@ func Test_Runner(t *testing.T) {
|
|||||||
version = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
version = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
|
||||||
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||||
|
|
||||||
|
ctx := testutil.Context(t, testutil.WaitLong)
|
||||||
closeCh := goEventuallyStartFakeAgent(ctx, t, client, authToken)
|
closeCh := goEventuallyStartFakeAgent(ctx, t, client, authToken)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -484,9 +482,6 @@ func Test_Runner(t *testing.T) {
|
|||||||
t.Run("FailedBuild", func(t *testing.T) {
|
t.Run("FailedBuild", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
|
logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
|
||||||
client := coderdtest.New(t, &coderdtest.Options{
|
client := coderdtest.New(t, &coderdtest.Options{
|
||||||
IncludeProvisionerDaemon: true,
|
IncludeProvisionerDaemon: true,
|
||||||
@@ -534,6 +529,8 @@ func Test_Runner(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ctx := testutil.Context(t, testutil.WaitLong)
|
||||||
|
|
||||||
logs := bytes.NewBuffer(nil)
|
logs := bytes.NewBuffer(nil)
|
||||||
err := runner.Run(ctx, "1", logs)
|
err := runner.Run(ctx, "1", logs)
|
||||||
logsStr := logs.String()
|
logsStr := logs.String()
|
||||||
|
|||||||
Reference in New Issue
Block a user