Skip to content

[integration-test] Add supervisor task status test #9968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions test/tests/components/ws-manager/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"testing"
"time"

"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"

gitpod "github.com/gitpod-io/gitpod/gitpod-protocol"
supervisorapi "github.com/gitpod-io/gitpod/supervisor/api"
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
"github.com/gitpod-io/gitpod/test/pkg/integration"
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"
)

func TestRegularWorkspaceTasks(t *testing.T) {
Expand Down Expand Up @@ -86,6 +86,44 @@ func TestRegularWorkspaceTasks(t *testing.T) {
defer rsa.Close()
integration.DeferCloser(t, closer)

var parsedResp struct {
Result struct {
Tasks []*struct {
State string `json:"state,omitempty"`
} `json:"tasks,omitempty"`
} `json:"result"`
}
supervisorTaskStatusCompleted := false
for i := 1; i < 10; i++ {
var res agent.ExecResponse
err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
Dir: "/workspace",
Command: "curl",
// nftable rule only forwards to this ip address
Args: []string{"10.0.5.2:22999/_supervisor/v1/status/tasks"},
}, &res)
if err != nil {
t.Fatal(err)
}
err = json.Unmarshal([]byte(res.Stdout), &parsedResp)
if err != nil {
t.Fatalf("cannot decode supervisor status response: %s", err)
}

if len(parsedResp.Result.Tasks) != 1 {
t.Fatalf("expected one task to run, but got %d", len(parsedResp.Result.Tasks))
}
if parsedResp.Result.Tasks[0].State == supervisorapi.TaskState_name[int32(supervisorapi.TaskState_closed)] {
supervisorTaskStatusCompleted = true
break
}
// sleep before next attempt hoping that the task completed meanwhile
time.Sleep(6 * time.Second)
}
if !supervisorTaskStatusCompleted {
t.Fatal("tasks did not complete in time")
}

var ls agent.ListDirResponse
err = rsa.Call("WorkspaceAgent.ListDir", &agent.ListDirRequest{
Dir: "/workspace",
Expand Down