Skip to content

Commit d97c012

Browse files
committed
9
1 parent 5316af6 commit d97c012

File tree

2 files changed

+73
-196
lines changed

2 files changed

+73
-196
lines changed

components/ws-manager-mk2/controllers/maintenance_controller_test.go

Lines changed: 0 additions & 196 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License.AGPL.txt in the project root for license information.
4+
5+
package wsmanager
6+
7+
import (
8+
"context"
9+
"testing"
10+
"time"
11+
12+
csapi "github.com/gitpod-io/gitpod/content-service/api"
13+
"github.com/gitpod-io/gitpod/test/pkg/integration"
14+
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
15+
"sigs.k8s.io/e2e-framework/pkg/envconf"
16+
"sigs.k8s.io/e2e-framework/pkg/features"
17+
)
18+
19+
func TestMaintenance(t *testing.T) {
20+
testRepo := "https://github.com/gitpod-io/empty"
21+
testRepoName := "empty"
22+
23+
f := features.New("ws-manager").
24+
WithLabel("component", "ws-manager").
25+
WithLabel("type", "maintenance").
26+
Assess("should display maintenance message", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
27+
ctx, cancel := context.WithTimeout(testCtx, time.Duration(5*time.Minute))
28+
defer cancel()
29+
30+
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
31+
t.Cleanup(func() {
32+
api.Done(t)
33+
})
34+
35+
addInitTask := func(swr *wsmanapi.StartWorkspaceRequest) error {
36+
swr.Spec.Initializer = &csapi.WorkspaceInitializer{
37+
Spec: &csapi.WorkspaceInitializer_Git{
38+
Git: &csapi.GitInitializer{
39+
RemoteUri: testRepo,
40+
CheckoutLocation: testRepoName,
41+
Config: &csapi.GitConfig{},
42+
},
43+
},
44+
}
45+
swr.Spec.WorkspaceLocation = testRepoName
46+
return nil
47+
}
48+
49+
nfo, stopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api, integration.WithRequestModifier(addInitTask))
50+
if err != nil {
51+
t.Fatal(err)
52+
}
53+
54+
t.Logf("status: %v", nfo.LastStatus)
55+
56+
t.Cleanup(func() {
57+
sctx, scancel := context.WithTimeout(context.Background(), 5*time.Minute)
58+
defer scancel()
59+
60+
sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
61+
defer sapi.Done(t)
62+
63+
if _, err = stopWs(true, sapi); err != nil {
64+
t.Errorf("cannot stop workspace: %q", err)
65+
}
66+
})
67+
68+
return testCtx
69+
}).
70+
Feature()
71+
72+
testEnv.Test(t, f)
73+
}

0 commit comments

Comments
 (0)