Skip to content

Commit 3939796

Browse files
Prince Rachit Sinharoboquat
Prince Rachit Sinha
authored andcommitted
[integration-test] Add supervisor test
1 parent 0a31946 commit 3939796

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

test/tests/components/ws-manager/tasks_test.go

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"testing"
1111
"time"
1212

13-
"sigs.k8s.io/e2e-framework/pkg/envconf"
14-
"sigs.k8s.io/e2e-framework/pkg/features"
15-
1613
gitpod "github.com/gitpod-io/gitpod/gitpod-protocol"
14+
supervisorapi "github.com/gitpod-io/gitpod/supervisor/api"
1715
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
1816
"github.com/gitpod-io/gitpod/test/pkg/integration"
1917
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
18+
"sigs.k8s.io/e2e-framework/pkg/envconf"
19+
"sigs.k8s.io/e2e-framework/pkg/features"
2020
)
2121

2222
func TestRegularWorkspaceTasks(t *testing.T) {
@@ -86,6 +86,44 @@ func TestRegularWorkspaceTasks(t *testing.T) {
8686
defer rsa.Close()
8787
integration.DeferCloser(t, closer)
8888

89+
var parsedResp struct {
90+
Result struct {
91+
Tasks []*struct {
92+
State string `json:"state,omitempty"`
93+
} `json:"tasks,omitempty"`
94+
} `json:"result"`
95+
}
96+
supervisorTaskStatusCompleted := false
97+
for i := 1; i < 10; i++ {
98+
var res agent.ExecResponse
99+
err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
100+
Dir: "/workspace",
101+
Command: "curl",
102+
// nftable rule only forwards to this ip address
103+
Args: []string{"10.0.5.2:22999/_supervisor/v1/status/tasks"},
104+
}, &res)
105+
if err != nil {
106+
t.Fatal(err)
107+
}
108+
err = json.Unmarshal([]byte(res.Stdout), &parsedResp)
109+
if err != nil {
110+
t.Fatalf("cannot decode supervisor status response: %s", err)
111+
}
112+
113+
if len(parsedResp.Result.Tasks) != 1 {
114+
t.Fatalf("expected one task to run, but got %d", len(parsedResp.Result.Tasks))
115+
}
116+
if parsedResp.Result.Tasks[0].State == supervisorapi.TaskState_name[int32(supervisorapi.TaskState_closed)] {
117+
supervisorTaskStatusCompleted = true
118+
break
119+
}
120+
// sleep before next attempt hoping that the task completed meanwhile
121+
time.Sleep(6 * time.Second)
122+
}
123+
if !supervisorTaskStatusCompleted {
124+
t.Fatal("tasks did not complete in time")
125+
}
126+
89127
var ls agent.ListDirResponse
90128
err = rsa.Call("WorkspaceAgent.ListDir", &agent.ListDirRequest{
91129
Dir: "/workspace",

0 commit comments

Comments
 (0)