Skip to content

Commit 0334145

Browse files
committed
test: Add a handling if the workspace already has gone when try to delete it
1 parent 70931c1 commit 0334145

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

test/pkg/integration/workspace.go

+20-17
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,27 @@ func stopWsF(t *testing.T, instanceID string, api *ComponentAPI) stopWorkspaceFu
301301
break
302302
}
303303

304-
if !waitForStop {
305-
wm, err := api.WorkspaceManager()
306-
if err != nil {
307-
return nil, err
308-
}
304+
wm, err := api.WorkspaceManager()
305+
if err != nil {
306+
return nil, err
307+
}
309308

310-
dr, err := wm.DescribeWorkspace(sctx, &wsmanapi.DescribeWorkspaceRequest{
311-
Id: instanceID,
312-
})
313-
if err != nil {
314-
return nil, err
315-
}
309+
dr, err := wm.DescribeWorkspace(sctx, &wsmanapi.DescribeWorkspaceRequest{
310+
Id: instanceID,
311+
})
312+
s, ok := status.FromError(err)
313+
if ok && s.Code() == codes.NotFound {
314+
t.Log("the workspace is already gone")
315+
return &wsmanapi.WorkspaceStatus{
316+
Id: instanceID,
317+
Phase: wsmanapi.WorkspacePhase_STOPPED,
318+
}, nil
319+
} else if err != nil {
320+
return nil, err
321+
}
316322

317-
s, ok := status.FromError(err)
318-
if ok && s.Code() == codes.NotFound {
319-
return nil, err
320-
}
321-
return dr.Status, err
323+
if !waitForStop {
324+
return dr.Status, nil
322325
}
323326

324327
var lastStatus *wsmanapi.WorkspaceStatus
@@ -335,7 +338,7 @@ func stopWsF(t *testing.T, instanceID string, api *ComponentAPI) stopWorkspaceFu
335338
}
336339
break
337340
}
338-
return lastStatus, err
341+
return lastStatus, nil
339342
}
340343
}
341344

0 commit comments

Comments
 (0)