Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdb76541

Browse files
authored
test(codersdk/toolsdk): fix task status race for send/logs (#20682)
Fixescoder/internal#1111
1 parent7dc7563 commitdb76541

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

‎codersdk/toolsdk/toolsdk_test.go‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/coder/coder/v2/agent/agenttest"
2929
"github.com/coder/coder/v2/coderd/coderdtest"
3030
"github.com/coder/coder/v2/coderd/database"
31+
"github.com/coder/coder/v2/coderd/database/dbauthz"
3132
"github.com/coder/coder/v2/coderd/database/dbfake"
3233
"github.com/coder/coder/v2/coderd/database/dbgen"
3334
"github.com/coder/coder/v2/coderd/httpapi"
@@ -106,8 +107,9 @@ func TestTools(t *testing.T) {
106107
})
107108

108109
t.Run("ReportTask",func(t*testing.T) {
110+
ctx:=testutil.Context(t,testutil.WaitShort)
109111
tb,err:=toolsdk.NewDeps(memberClient,toolsdk.WithTaskReporter(func(args toolsdk.ReportTaskArgs)error {
110-
returnagentClient.PatchAppStatus(setupCtx, agentsdk.PatchAppStatus{
112+
returnagentClient.PatchAppStatus(ctx, agentsdk.PatchAppStatus{
111113
AppSlug:"some-agent-app",
112114
Message:args.Summary,
113115
URI:args.Link,
@@ -1393,7 +1395,17 @@ func TestTools(t *testing.T) {
13931395
task:=ws.Task
13941396

13951397
_=agenttest.New(t,client.URL,ws.AgentToken)
1396-
coderdtest.NewWorkspaceAgentWaiter(t,client,ws.Workspace.ID).Wait()
1398+
coderdtest.NewWorkspaceAgentWaiter(t,client,ws.Workspace.ID).
1399+
WaitFor(coderdtest.AgentsReady)
1400+
1401+
ctx:=testutil.Context(t,testutil.WaitShort)
1402+
1403+
// Ensure the app is healthy (required to send task input).
1404+
err=store.UpdateWorkspaceAppHealthByID(dbauthz.AsSystemRestricted(ctx), database.UpdateWorkspaceAppHealthByIDParams{
1405+
ID:task.WorkspaceAppID.UUID,
1406+
Health:database.WorkspaceAppHealthHealthy,
1407+
})
1408+
require.NoError(t,err)
13971409

13981410
tests:= []struct {
13991411
namestring
@@ -1454,8 +1466,6 @@ func TestTools(t *testing.T) {
14541466

14551467
for_,tt:=rangetests {
14561468
t.Run(tt.name,func(t*testing.T) {
1457-
t.Parallel()
1458-
14591469
tb,err:=toolsdk.NewDeps(memberClient)
14601470
require.NoError(t,err)
14611471

@@ -1525,7 +1535,17 @@ func TestTools(t *testing.T) {
15251535
task:=ws.Task
15261536

15271537
_=agenttest.New(t,client.URL,ws.AgentToken)
1528-
coderdtest.NewWorkspaceAgentWaiter(t,client,ws.Workspace.ID).Wait()
1538+
coderdtest.NewWorkspaceAgentWaiter(t,client,ws.Workspace.ID).
1539+
WaitFor(coderdtest.AgentsReady)
1540+
1541+
ctx:=testutil.Context(t,testutil.WaitShort)
1542+
1543+
// Ensure the app is healthy (required to read task logs).
1544+
err=store.UpdateWorkspaceAppHealthByID(dbauthz.AsSystemRestricted(ctx), database.UpdateWorkspaceAppHealthByIDParams{
1545+
ID:task.WorkspaceAppID.UUID,
1546+
Health:database.WorkspaceAppHealthHealthy,
1547+
})
1548+
require.NoError(t,err)
15291549

15301550
tests:= []struct {
15311551
namestring
@@ -1577,8 +1597,6 @@ func TestTools(t *testing.T) {
15771597

15781598
for_,tt:=rangetests {
15791599
t.Run(tt.name,func(t*testing.T) {
1580-
t.Parallel()
1581-
15821600
tb,err:=toolsdk.NewDeps(memberClient)
15831601
require.NoError(t,err)
15841602

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp