Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/test/tests/ide/jetbrains/gateway_test.go
2500 views
1
// Copyright (c) 2022 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 ide
6
7
import (
8
"context"
9
_ "embed"
10
"fmt"
11
"testing"
12
"time"
13
14
"sigs.k8s.io/e2e-framework/pkg/envconf"
15
"sigs.k8s.io/e2e-framework/pkg/features"
16
17
agent "github.com/gitpod-io/gitpod/test/pkg/agent/workspace/api"
18
"github.com/gitpod-io/gitpod/test/pkg/integration"
19
)
20
21
func TestGoLand(t *testing.T) {
22
BaseGuard(t)
23
t.Parallel()
24
f := features.New("Start a workspace using GoLand").
25
WithLabel("component", "IDE").
26
WithLabel("ide", "GoLand").
27
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
28
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
29
defer cancel()
30
JetBrainsIDETest(ctx, t, cfg, WithIDE("goland"))
31
return testCtx
32
}).
33
Feature()
34
testEnv.Test(t, f)
35
}
36
37
func TestIntellij(t *testing.T) {
38
BaseGuard(t)
39
t.Parallel()
40
f := features.New("Start a workspace using Intellij").
41
WithLabel("component", "IDE").
42
WithLabel("ide", "Intellij").
43
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
44
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
45
defer cancel()
46
47
JetBrainsIDETest(ctx, t, cfg, WithIDE("intellij"))
48
return testCtx
49
}).
50
Feature()
51
testEnv.Test(t, f)
52
}
53
54
func TestPhpStorm(t *testing.T) {
55
BaseGuard(t)
56
t.Parallel()
57
f := features.New("Start a workspace using PhpStorm").
58
WithLabel("component", "IDE").
59
WithLabel("ide", "PhpStorm").
60
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
61
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
62
defer cancel()
63
JetBrainsIDETest(ctx, t, cfg, WithIDE("phpstorm"))
64
return testCtx
65
}).
66
Feature()
67
testEnv.Test(t, f)
68
}
69
70
func TestPyCharm(t *testing.T) {
71
BaseGuard(t)
72
t.Parallel()
73
f := features.New("Start a workspace using Pycharm").
74
WithLabel("component", "IDE").
75
WithLabel("ide", "Pycharm").
76
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
77
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
78
defer cancel()
79
JetBrainsIDETest(ctx, t, cfg, WithIDE("pycharm"))
80
return testCtx
81
}).
82
Feature()
83
testEnv.Test(t, f)
84
}
85
86
func TestRubyMine(t *testing.T) {
87
BaseGuard(t)
88
t.Parallel()
89
f := features.New("Start a workspace using RubyMine").
90
WithLabel("component", "IDE").
91
WithLabel("ide", "RubyMine").
92
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
93
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
94
defer cancel()
95
JetBrainsIDETest(ctx, t, cfg, WithIDE("rubymine"))
96
return testCtx
97
}).
98
Feature()
99
testEnv.Test(t, f)
100
}
101
102
func TestWebStorm(t *testing.T) {
103
BaseGuard(t)
104
t.Parallel()
105
f := features.New("Start a workspace using WebStorm").
106
WithLabel("component", "IDE").
107
WithLabel("ide", "WebStorm").
108
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
109
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
110
defer cancel()
111
JetBrainsIDETest(ctx, t, cfg, WithIDE("webstorm"))
112
return testCtx
113
}).
114
Feature()
115
testEnv.Test(t, f)
116
}
117
118
func TestRider(t *testing.T) {
119
BaseGuard(t)
120
t.Parallel()
121
f := features.New("Start a workspace using Rider").
122
WithLabel("component", "IDE").
123
WithLabel("ide", "Rider").
124
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
125
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
126
defer cancel()
127
JetBrainsIDETest(ctx, t, cfg, WithIDE("rider"))
128
return testCtx
129
}).
130
Feature()
131
testEnv.Test(t, f)
132
}
133
134
func TestCLion(t *testing.T) {
135
BaseGuard(t)
136
t.Parallel()
137
t.Skip("See EXP-414")
138
f := features.New("Start a workspace using CLion").
139
WithLabel("component", "IDE").
140
WithLabel("ide", "CLion").
141
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
142
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
143
defer cancel()
144
JetBrainsIDETest(ctx, t, cfg, WithIDE("clion"))
145
return testCtx
146
}).
147
Feature()
148
testEnv.Test(t, f)
149
}
150
151
func TestRustRover(t *testing.T) {
152
BaseGuard(t)
153
t.Parallel()
154
f := features.New("Start a workspace using RustRover").
155
WithLabel("component", "IDE").
156
WithLabel("ide", "RustRover").
157
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
158
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
159
defer cancel()
160
JetBrainsIDETest(ctx, t, cfg, WithIDE("rustrover"))
161
return testCtx
162
}).
163
Feature()
164
testEnv.Test(t, f)
165
}
166
167
func TestIntellijNotPreconfiguredRepo(t *testing.T) {
168
BaseGuard(t)
169
t.Parallel()
170
f := features.New("Start a workspace using Intellij with not preconfigured repo").
171
WithLabel("component", "IDE").
172
WithLabel("ide", "Intellij").
173
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
174
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
175
defer cancel()
176
// ENT-260
177
// https://github.com/spring-projects/spring-petclinic is not an option because it will prompt to ask user to select project type
178
// which will block integration test (UI tests)
179
JetBrainsIDETest(ctx, t, cfg, WithIDE("intellij"), WithRepo("https://github.com/gitpod-io/empty"))
180
return testCtx
181
}).
182
Feature()
183
testEnv.Test(t, f)
184
}
185
186
//go:embed warmup-indexing.sh
187
var warmupIndexingShell []byte
188
189
func TestIntelliJWarmup(t *testing.T) {
190
BaseGuard(t)
191
t.Parallel()
192
f := features.New("Start a workspace using Intellij and imagebuild to test warmup tasks").
193
WithLabel("component", "IDE").
194
WithLabel("ide", "Intellij").
195
Assess("it can let JetBrains Gateway connect", func(testCtx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
196
ctx, cancel := context.WithTimeout(testCtx, 30*time.Minute)
197
defer cancel()
198
199
testRepo := "https://github.com/gitpod-samples/spring-petclinic"
200
testRepoBranch := "gp/integration-test"
201
202
api, _, papi, _ := MustConnectToServer(ctx, t, cfg)
203
t.Logf("get or create team")
204
teamID, err := api.GetTeam(ctx, papi)
205
if err != nil {
206
t.Fatalf("failed to get or create team: %v", err)
207
}
208
t.Logf("get or create repository for %s", testRepo)
209
projectID, err := api.GetProject(ctx, papi, teamID, "petclinic", testRepo, true)
210
if err != nil {
211
t.Fatalf("failed to get or create project: %v", err)
212
}
213
214
triggerAndWaitForPrebuild := func() error {
215
prebuildID, err := api.TriggerPrebuild(ctx, papi, projectID, testRepoBranch)
216
if err != nil {
217
return fmt.Errorf("failed to trigger prebuild: %v", err)
218
}
219
t.Logf("prebuild triggered, id: %s", prebuildID)
220
ok, err := api.WaitForPrebuild(ctx, papi, prebuildID)
221
if err != nil {
222
return fmt.Errorf("failed to wait for prebuild: %v", err)
223
}
224
if !ok {
225
return fmt.Errorf("prebuild failed")
226
}
227
// EXP-1860
228
// Prebuild is marked as available before content back-up is completed
229
if err := api.WaitForPrebuildWorkspaceToStoppedPhase(ctx, prebuildID); err != nil {
230
return fmt.Errorf("failed to wait for prebuild workspace to be backed-up : %v", err)
231
}
232
return nil
233
}
234
235
t.Logf("trigger prebuild and wait for it")
236
if err := triggerAndWaitForPrebuild(); err != nil {
237
t.Fatalf("failed to trigger prebuild: %v", err)
238
}
239
t.Logf("prebuild available")
240
241
t.Logf("warmup prebuild prepared, org: %s, repository: %s", teamID, projectID)
242
243
JetBrainsIDETest(ctx, t, cfg, WithIDE("intellij"),
244
WithRepo(fmt.Sprintf("%s/tree/%s", testRepo, testRepoBranch)),
245
WithRepositoryID(projectID),
246
WithAdditionRpcCall(func(rsa *integration.RpcClient, jbCtx *JetBrainsTestCtx) error {
247
t.Logf("check if it has warmup.log")
248
var resp agent.ExecResponse
249
err := rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
250
Dir: "/",
251
Command: "bash",
252
Args: []string{
253
"-c",
254
fmt.Sprintf("stat %s/log/warmup/warmup.log", jbCtx.SystemDir),
255
},
256
}, &resp)
257
if err != nil {
258
return fmt.Errorf("warmup.log not found: %v", err)
259
}
260
if resp.ExitCode != 0 {
261
return fmt.Errorf("warmup.log not found: %s, %d", resp.Stderr, resp.ExitCode)
262
}
263
return nil
264
}),
265
WithAdditionRpcCall(func(rsa *integration.RpcClient, jbCtx *JetBrainsTestCtx) error {
266
t.Logf("sleep for 1 minute to wait project open")
267
var resp agent.ExecResponse
268
time.Sleep(1 * time.Minute)
269
t.Logf("checking warmup indexing")
270
err := rsa.Call("WorkspaceAgent.Exec", &agent.ExecRequest{
271
Dir: "/",
272
Command: "bash",
273
Args: []string{
274
"-c",
275
string(warmupIndexingShell),
276
"--",
277
jbCtx.SystemDir,
278
"1",
279
},
280
}, &resp)
281
if err != nil {
282
return fmt.Errorf("failed to warmup indexing: %v", err)
283
}
284
t.Logf("stdout:\n%s", string(resp.Stdout))
285
if resp.ExitCode != 0 {
286
return fmt.Errorf("failed to warmup indexing: %s, %d", resp.Stderr, resp.ExitCode)
287
}
288
return nil
289
}))
290
return testCtx
291
}).
292
Feature()
293
testEnv.Test(t, f)
294
}
295
296