Skip to content

Commit ac17708

Browse files
committed
WIP
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 4bc4ce6 commit ac17708

File tree

1 file changed

+47
-39
lines changed

1 file changed

+47
-39
lines changed

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

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"sigs.k8s.io/e2e-framework/pkg/envconf"
1919
"sigs.k8s.io/e2e-framework/pkg/features"
2020

21+
"github.com/gitpod-io/gitpod/common-go/log"
2122
csapi "github.com/gitpod-io/gitpod/content-service/api"
2223
gitpod "github.com/gitpod-io/gitpod/gitpod-protocol"
2324
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
@@ -223,7 +224,7 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {
223224
},
224225
}
225226

226-
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(15*len(tests))*time.Minute)
227+
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(10*len(tests))*time.Minute)
227228
defer cancel()
228229

229230
for _, test := range tests {
@@ -238,7 +239,7 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {
238239
req.Type = wsmanapi.WorkspaceType_PREBUILD
239240
req.Spec.Envvars = append(req.Spec.Envvars, &wsmanapi.EnvironmentVariable{
240241
Name: "GITPOD_TASKS",
241-
Value: fmt.Sprintf(`[{ "init": %q }]`, initTask),
242+
Value: `[{ "init": "echo \"some output\" > someFile; sleep 20; exit 1;" }]`,
242243
})
243244
req.Spec.FeatureFlags = test.FF
244245
req.Spec.Initializer = &csapi.WorkspaceInitializer{
@@ -352,53 +353,60 @@ func TestOpenWorkspaceFromPrebuild(t *testing.T) {
352353
checkPrebuildLog = true
353354
break
354355
}
356+
log.Infof("[%d] retry...", i)
355357
time.Sleep(6 * time.Second)
356358
}
357359

358360
if !checkPrebuildLog {
359-
// somehow, the prebuild log message '🤙 This task ran as a workspace prebuild' does not exists
360-
// we fall back to check the the init task message within the /workspace/.gitpod/prebuild-log-* or not
361-
t.Logf("cannot found the prebuild message %s in %s, err:%v, exitCode:%d, stdout:%s", prebuildLog, prebuildLogPath, err, resp.ExitCode, resp.Stdout)
362-
363-
// check the init task message exists
364-
var checkInitTaskMsg bool
365-
err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
366-
Dir: prebuildLogPath,
367-
Command: "bash",
368-
Args: []string{
369-
"-c",
370-
fmt.Sprintf("grep %q *", initTask),
371-
},
372-
}, &resp)
373-
if err == nil && resp.ExitCode == 0 && strings.Trim(resp.Stdout, " \t\n") != "" {
374-
checkInitTaskMsg = true
375-
}
361+
t.Fatalf("cannot found the prebuild message %s in %s, err:%v, exitCode:%d, stdout:%s", prebuildLog, prebuildLogPath, err, resp.ExitCode, resp.Stdout)
362+
}
376363

377-
if !checkInitTaskMsg {
378-
t.Logf("cannot found the init task message %s in %s, err:%v, exitCode:%d, stdout:%s", initTask, prebuildLogPath, err, resp.ExitCode, resp.Stdout)
379-
380-
// somehow, the init task message does not exist within the /workspace/.gitpod/prebuild-log-*
381-
// we fall back to check the file exists or not
382-
var ls agent.ListDirResponse
383-
err = rsa.Call("WorkspaceAgent.ListDir", &agent.ListDirRequest{
384-
Dir: test.WorkspaceRoot,
385-
}, &ls)
386-
if err != nil {
387-
t.Fatal(err)
364+
/*
365+
if !checkPrebuildLog {
366+
// somehow, the prebuild log message '🤙 This task ran as a workspace prebuild' does not exists
367+
// we fall back to check the the init task message within the /workspace/.gitpod/prebuild-log-* or not
368+
t.Logf("cannot found the prebuild message %s in %s, err:%v, exitCode:%d, stdout:%s", prebuildLog, prebuildLogPath, err, resp.ExitCode, resp.Stdout)
369+
370+
// check the init task message exists
371+
var checkInitTaskMsg bool
372+
err = rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
373+
Dir: prebuildLogPath,
374+
Command: "bash",
375+
Args: []string{
376+
"-c",
377+
fmt.Sprintf("grep %q *", initTask),
378+
},
379+
}, &resp)
380+
if err == nil && resp.ExitCode == 0 && strings.Trim(resp.Stdout, " \t\n") != "" {
381+
checkInitTaskMsg = true
388382
}
389383
390-
var found bool
391-
for _, f := range ls.Files {
392-
if filepath.Base(f) == "someFile" {
393-
found = true
394-
break
384+
if !checkInitTaskMsg {
385+
t.Logf("cannot found the init task message %s in %s, err:%v, exitCode:%d, stdout:%s", initTask, prebuildLogPath, err, resp.ExitCode, resp.Stdout)
386+
387+
// somehow, the init task message does not exist within the /workspace/.gitpod/prebuild-log-*
388+
// we fall back to check the file exists or not
389+
var ls agent.ListDirResponse
390+
err = rsa.Call("WorkspaceAgent.ListDir", &agent.ListDirRequest{
391+
Dir: test.WorkspaceRoot,
392+
}, &ls)
393+
if err != nil {
394+
t.Fatal(err)
395+
}
396+
397+
var found bool
398+
for _, f := range ls.Files {
399+
if filepath.Base(f) == "someFile" {
400+
found = true
401+
break
402+
}
403+
}
404+
if !found {
405+
t.Fatal("did not find someFile from previous workspace instance")
395406
}
396-
}
397-
if !found {
398-
t.Fatal("did not find someFile from previous workspace instance")
399407
}
400408
}
401-
}
409+
*/
402410

403411
// write file foobar.txt and stop the workspace
404412
err = rsa.Call("WorkspaceAgent.WriteFile", &agent.WriteFileRequest{

0 commit comments

Comments
 (0)