Skip to content

Commit

Permalink
tests: Stabilization of TestRegularWorkspaceTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
utam0k authored and roboquat committed Aug 26, 2022
1 parent b2313e6 commit d1d2b3e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/pkg/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func Instrument(component ComponentType, agentName string, namespace string, kub

var res *rpc.Client
var lastError error
waitErr := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (bool, error) {
waitErr := wait.PollImmediate(5*time.Second, 2*time.Minute, func() (bool, error) {
res, lastError = rpc.DialHTTP("tcp", fmt.Sprintf("localhost:%d", localAgentPort))
if lastError != nil {
return false, nil
Expand Down
28 changes: 16 additions & 12 deletions test/pkg/integration/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,47 +316,51 @@ func WaitForWorkspaceStart(ctx context.Context, instanceID string, api *Componen
errStatus := make(chan error)

go func() {
var status *wsmanapi.WorkspaceStatus
var s *wsmanapi.WorkspaceStatus
defer func() {
done <- status
done <- s
close(done)
}()
for {
resp, err := sub.Recv()
if err != nil {
if st, ok := status.FromError(err); ok && st.Code() == codes.Unavailable {
continue
}
errStatus <- xerrors.Errorf("workspace update error: %q", err)
return
}
status = resp.GetStatus()
if status == nil {

s = resp.GetStatus()
if s == nil {
continue
}
if status.Id != instanceID {
if s.Id != instanceID {
continue
}

if cfg.CanFail {
if status.Phase == wsmanapi.WorkspacePhase_STOPPING {
if s.Phase == wsmanapi.WorkspacePhase_STOPPING {
return
}
if status.Phase == wsmanapi.WorkspacePhase_STOPPED {
if s.Phase == wsmanapi.WorkspacePhase_STOPPED {
return
}
} else {
if status.Conditions.Failed != "" {
errStatus <- xerrors.Errorf("workspace instance %s failed: %s", instanceID, status.Conditions.Failed)
if s.Conditions.Failed != "" {
errStatus <- xerrors.Errorf("workspace instance %s failed: %s", instanceID, s.Conditions.Failed)
return
}
if status.Phase == wsmanapi.WorkspacePhase_STOPPING {
if s.Phase == wsmanapi.WorkspacePhase_STOPPING {
errStatus <- xerrors.Errorf("workspace instance %s is stopping", instanceID)
return
}
if status.Phase == wsmanapi.WorkspacePhase_STOPPED {
if s.Phase == wsmanapi.WorkspacePhase_STOPPED {
errStatus <- xerrors.Errorf("workspace instance %s has stopped", instanceID)
return
}
}
if status.Phase != wsmanapi.WorkspacePhase_RUNNING {
if s.Phase != wsmanapi.WorkspacePhase_RUNNING {
// we're still starting
continue
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests/components/ws-manager/content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestMissingBackup(t *testing.T) {
return
}
if testws.LastStatus.Conditions.Failed == "" {
t.Error("restarted workspace did not fail despite missing backup")
t.Errorf("restarted workspace did not fail despite missing backup, %v", testws)
}
})
}
Expand Down
7 changes: 4 additions & 3 deletions test/tests/components/ws-manager/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func TestRegularWorkspaceTasks(t *testing.T) {

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
// t.Parallel()

addInitTask := func(swr *wsmanapi.StartWorkspaceRequest) error {
tasks, err := json.Marshal([]gitpod.TasksItems{test.Task})
if err != nil {
Expand All @@ -76,7 +74,10 @@ func TestRegularWorkspaceTasks(t *testing.T) {
}

t.Cleanup(func() {
_ = integration.DeleteWorkspace(ctx, api, nfo.Req.Id)
err = integration.DeleteWorkspace(ctx, api, nfo.Req.Id)
if err == nil {
_, _ = integration.WaitForWorkspaceStop(ctx, api, nfo.Req.Id)
}
})

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

0 comments on commit d1d2b3e

Please sign in to comment.