@@ -10,13 +10,13 @@ import (
10
10
"testing"
11
11
"time"
12
12
13
- "sigs.k8s.io/e2e-framework/pkg/envconf"
14
- "sigs.k8s.io/e2e-framework/pkg/features"
15
-
16
13
gitpod "github.com/gitpod-io/gitpod/gitpod-protocol"
14
+ supervisorapi "github.com/gitpod-io/gitpod/supervisor/api"
17
15
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
18
16
"github.com/gitpod-io/gitpod/test/pkg/integration"
19
17
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"
20
20
)
21
21
22
22
func TestRegularWorkspaceTasks (t * testing.T ) {
@@ -86,6 +86,44 @@ func TestRegularWorkspaceTasks(t *testing.T) {
86
86
defer rsa .Close ()
87
87
integration .DeferCloser (t , closer )
88
88
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
+
89
127
var ls agent.ListDirResponse
90
128
err = rsa .Call ("WorkspaceAgent.ListDir" , & agent.ListDirRequest {
91
129
Dir : "/workspace" ,
0 commit comments