Skip to content

Commit d1d2b3e

Browse files
utam0kroboquat
authored andcommitted
tests: Stabilization of TestRegularWorkspaceTasks
1 parent b2313e6 commit d1d2b3e

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

Diff for: test/pkg/integration/integration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func Instrument(component ComponentType, agentName string, namespace string, kub
230230

231231
var res *rpc.Client
232232
var lastError error
233-
waitErr := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) {
233+
waitErr := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
234234
res, lastError = rpc.DialHTTP("tcp", fmt.Sprintf("localhost:%d", localAgentPort))
235235
if lastError != nil {
236236
return false, nil

Diff for: test/pkg/integration/workspace.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -316,47 +316,51 @@ func WaitForWorkspaceStart(ctx context.Context, instanceID string, api *Componen
316316
errStatus := make(chan error)
317317

318318
go func() {
319-
var status *wsmanapi.WorkspaceStatus
319+
var s *wsmanapi.WorkspaceStatus
320320
defer func() {
321-
done <- status
321+
done <- s
322322
close(done)
323323
}()
324324
for {
325325
resp, err := sub.Recv()
326326
if err != nil {
327+
if st, ok := status.FromError(err); ok && st.Code() == codes.Unavailable {
328+
continue
329+
}
327330
errStatus <- xerrors.Errorf("workspace update error: %q", err)
328331
return
329332
}
330-
status = resp.GetStatus()
331-
if status == nil {
333+
334+
s = resp.GetStatus()
335+
if s == nil {
332336
continue
333337
}
334-
if status.Id != instanceID {
338+
if s.Id != instanceID {
335339
continue
336340
}
337341

338342
if cfg.CanFail {
339-
if status.Phase == wsmanapi.WorkspacePhase_STOPPING {
343+
if s.Phase == wsmanapi.WorkspacePhase_STOPPING {
340344
return
341345
}
342-
if status.Phase == wsmanapi.WorkspacePhase_STOPPED {
346+
if s.Phase == wsmanapi.WorkspacePhase_STOPPED {
343347
return
344348
}
345349
} else {
346-
if status.Conditions.Failed != "" {
347-
errStatus <- xerrors.Errorf("workspace instance %s failed: %s", instanceID, status.Conditions.Failed)
350+
if s.Conditions.Failed != "" {
351+
errStatus <- xerrors.Errorf("workspace instance %s failed: %s", instanceID, s.Conditions.Failed)
348352
return
349353
}
350-
if status.Phase == wsmanapi.WorkspacePhase_STOPPING {
354+
if s.Phase == wsmanapi.WorkspacePhase_STOPPING {
351355
errStatus <- xerrors.Errorf("workspace instance %s is stopping", instanceID)
352356
return
353357
}
354-
if status.Phase == wsmanapi.WorkspacePhase_STOPPED {
358+
if s.Phase == wsmanapi.WorkspacePhase_STOPPED {
355359
errStatus <- xerrors.Errorf("workspace instance %s has stopped", instanceID)
356360
return
357361
}
358362
}
359-
if status.Phase != wsmanapi.WorkspacePhase_RUNNING {
363+
if s.Phase != wsmanapi.WorkspacePhase_RUNNING {
360364
// we're still starting
361365
continue
362366
}

Diff for: test/tests/components/ws-manager/content_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func TestMissingBackup(t *testing.T) {
210210
return
211211
}
212212
if testws.LastStatus.Conditions.Failed == "" {
213-
t.Error("restarted workspace did not fail despite missing backup")
213+
t.Errorf("restarted workspace did not fail despite missing backup, %v", testws)
214214
}
215215
})
216216
}

Diff for: test/tests/components/ws-manager/tasks_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ func TestRegularWorkspaceTasks(t *testing.T) {
5656

5757
for _, test := range tests {
5858
t.Run(test.Name, func(t *testing.T) {
59-
// t.Parallel()
60-
6159
addInitTask := func(swr *wsmanapi.StartWorkspaceRequest) error {
6260
tasks, err := json.Marshal([]gitpod.TasksItems{test.Task})
6361
if err != nil {
@@ -76,7 +74,10 @@ func TestRegularWorkspaceTasks(t *testing.T) {
7674
}
7775

7876
t.Cleanup(func() {
79-
_ = integration.DeleteWorkspace(ctx, api, nfo.Req.Id)
77+
err = integration.DeleteWorkspace(ctx, api, nfo.Req.Id)
78+
if err == nil {
79+
_, _ = integration.WaitForWorkspaceStop(ctx, api, nfo.Req.Id)
80+
}
8081
})
8182

8283
rsa, closer, err := integration.Instrument(integration.ComponentWorkspace, "workspace", cfg.Namespace(), kubeconfig, cfg.Client(), integration.WithInstanceID(nfo.Req.Id))

0 commit comments

Comments
 (0)