Skip to content

Commit

Permalink
[integration-test] Add supervisor test
Browse files Browse the repository at this point in the history
  • Loading branch information
Prince Rachit Sinha authored and roboquat committed May 12, 2022
1 parent 0a31946 commit 3939796
Showing 1 changed file with 41 additions and 3 deletions.
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

0 comments on commit 3939796

Please sign in to comment.