mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
test(codersdk/toolsdk): fix task status race for send/logs (#20682)
Fixes coder/internal#1111
This commit is contained in:
committed by
GitHub
parent
7dc75637a1
commit
db76541522
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/coder/coder/v2/agent/agenttest"
|
||||
"github.com/coder/coder/v2/coderd/coderdtest"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/database/dbfake"
|
||||
"github.com/coder/coder/v2/coderd/database/dbgen"
|
||||
"github.com/coder/coder/v2/coderd/httpapi"
|
||||
@@ -106,8 +107,9 @@ func TestTools(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ReportTask", func(t *testing.T) {
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
tb, err := toolsdk.NewDeps(memberClient, toolsdk.WithTaskReporter(func(args toolsdk.ReportTaskArgs) error {
|
||||
return agentClient.PatchAppStatus(setupCtx, agentsdk.PatchAppStatus{
|
||||
return agentClient.PatchAppStatus(ctx, agentsdk.PatchAppStatus{
|
||||
AppSlug: "some-agent-app",
|
||||
Message: args.Summary,
|
||||
URI: args.Link,
|
||||
@@ -1393,7 +1395,17 @@ func TestTools(t *testing.T) {
|
||||
task := ws.Task
|
||||
|
||||
_ = agenttest.New(t, client.URL, ws.AgentToken)
|
||||
coderdtest.NewWorkspaceAgentWaiter(t, client, ws.Workspace.ID).Wait()
|
||||
coderdtest.NewWorkspaceAgentWaiter(t, client, ws.Workspace.ID).
|
||||
WaitFor(coderdtest.AgentsReady)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
// Ensure the app is healthy (required to send task input).
|
||||
err = store.UpdateWorkspaceAppHealthByID(dbauthz.AsSystemRestricted(ctx), database.UpdateWorkspaceAppHealthByIDParams{
|
||||
ID: task.WorkspaceAppID.UUID,
|
||||
Health: database.WorkspaceAppHealthHealthy,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -1454,8 +1466,6 @@ func TestTools(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tb, err := toolsdk.NewDeps(memberClient)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1525,7 +1535,17 @@ func TestTools(t *testing.T) {
|
||||
task := ws.Task
|
||||
|
||||
_ = agenttest.New(t, client.URL, ws.AgentToken)
|
||||
coderdtest.NewWorkspaceAgentWaiter(t, client, ws.Workspace.ID).Wait()
|
||||
coderdtest.NewWorkspaceAgentWaiter(t, client, ws.Workspace.ID).
|
||||
WaitFor(coderdtest.AgentsReady)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
|
||||
// Ensure the app is healthy (required to read task logs).
|
||||
err = store.UpdateWorkspaceAppHealthByID(dbauthz.AsSystemRestricted(ctx), database.UpdateWorkspaceAppHealthByIDParams{
|
||||
ID: task.WorkspaceAppID.UUID,
|
||||
Health: database.WorkspaceAppHealthHealthy,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -1577,8 +1597,6 @@ func TestTools(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tb, err := toolsdk.NewDeps(memberClient)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user