Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JetBrains] Improve integration tests #15513

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:mads-leeway-v0.7.3.4
image: eu.gcr.io/gitpod-core-dev/build/installer:dev-image-dockerfile.1
workspaceLocation: gitpod/gitpod-ws.code-workspace
checkoutLocation: gitpod
ports:
Expand Down
47 changes: 28 additions & 19 deletions .werft/installer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,31 @@ const WORKSPACES_TESTS: { [name: string]: InfraConfig } = {
},
};

const SSH_TEST = {
phase: "run-ssh-tests",
makeTarget: "run-ssh-tests",
description: "SSH Gateway tests",
slackhook: slackHook.get("ide-jobs"),
};

const VSCODE_IDE_TEST = {
phase: "run-vscode-ide-tests",
makeTarget: "run-vscode-ide-tests",
description: "vscode IDE tests",
slackhook: slackHook.get("ide-jobs"),
};

const JB_IDE_TEST = {
phase: "run-jb-ide-tests",
makeTarget: "run-jb-ide-tests",
description: "jetbrains IDE tests",
slackhook: slackHook.get("ide-jobs"),
}

const IDE_TESTS: { [name: string]: InfraConfig } = {
SSH_TEST: {
phase: "run-ssh-tests",
makeTarget: "run-ssh-tests",
description: "SSH Gateway tests",
slackhook: slackHook.get("ide-jobs"),
},
VSCODE_IDE_TEST: {
phase: "run-vscode-ide-tests",
makeTarget: "run-vscode-ide-tests",
description: "vscode IDE tests",
slackhook: slackHook.get("ide-jobs"),
},
JB_IDE_TEST: {
phase: "run-jb-ide-tests",
makeTarget: "run-jb-ide-tests",
description: "jetbrains IDE tests",
slackhook: slackHook.get("ide-jobs"),
},
SSH_TEST,
VSCODE_IDE_TEST,
JB_IDE_TEST,
}


Expand Down Expand Up @@ -274,6 +280,9 @@ const WEBAPP_TESTS: { [name: string]: InfraConfig } = {
const TestMap = {
"workspaces": WORKSPACES_TESTS,
"ide": IDE_TESTS,
"ssh": SSH_TEST,
"vscode": VSCODE_IDE_TEST,
"jetbrains": JB_IDE_TEST,
"webapp": WEBAPP_TESTS,
}

Expand Down Expand Up @@ -427,7 +436,7 @@ async function runIntegrationTests() {

const componentTests = TestMap[testSuite.toLowerCase()]
if(componentTests === undefined) {
console.log("'%s' is not a valid testSuite name, options are: 'workspaces', 'ide', 'webapp'", testSuite)
console.log("'%s' is not a valid testSuite name, options are: 'workspaces', 'ide', 'ssh', 'vscode', 'jetbrains', 'webapp'", testSuite)
werft.fail(`run-${testSuite}-integration-tests`, "Error finding the testSuite")
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ optarg=""
while getopts rs-: opt; do
optarg="${!OPTIND}"
[[ "$opt" = - ]] && opt="-$OPTARG"

# shellcheck disable=SC2214
case "-$opt" in
-r|--report)
REPORT=${optarg}
Expand Down
181 changes: 34 additions & 147 deletions test/tests/ide/jetbrains/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -47,11 +47,13 @@ type GatewayHostStatus struct {
var (
userToken string
roboquatToken string
jetBrainsIDEs []string
)

func init() {
userToken, _ = os.LookupEnv("USER_TOKEN")
roboquatToken, _ = os.LookupEnv("ROBOQUAT_TOKEN")
jetBrainsIDEs = []string{"goland", "rubymine", "phpstorm", "pycharm", "intellij", "webstorm", "rider", "clion"}
}

func GetHttpContent(url string) ([]byte, error) {
Expand All @@ -60,7 +62,7 @@ func GetHttpContent(url string) ([]byte, error) {
return nil, err
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
return b, err
}

Expand Down Expand Up @@ -174,6 +176,7 @@ func JetBrainsIDETest(ctx context.Context, t *testing.T, cfg *envconf.Config, id
if err != nil {
continue
}

if len(status.Projects) == 1 && status.Projects[0].ControllerConnected {
testStatus = true
break
Expand All @@ -184,154 +187,38 @@ func JetBrainsIDETest(ctx context.Context, t *testing.T, cfg *envconf.Config, id
}
}

func TestGoLand(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New("Start a workspace using GoLand").
WithLabel("component", "IDE").
WithLabel("ide", "GoLand").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "goland", "https://github.com/gitpod-samples/template-golang-cli")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestIntellij(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New("Start a workspace using Intellij").
WithLabel("component", "IDE").
WithLabel("ide", "Intellij").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "intellij", "https://github.com/gitpod-samples/spring-petclinic")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestPhpStorm(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New("Start a workspace using PhpStorm").
WithLabel("component", "IDE").
WithLabel("ide", "PhpStorm").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "phpstorm", "https://github.com/gitpod-samples/template-php-laravel-mysql")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestPyCharm(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New("Start a workspace using Pycharm").
WithLabel("component", "IDE").
WithLabel("ide", "Pycharm").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "pycharm", "https://github.com/gitpod-samples/template-python-django")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestRubyMine(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New("Start a workspace using RubyMine").
WithLabel("component", "IDE").
WithLabel("ide", "RubyMine").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "rubymine", "https://github.com/gitpod-samples/template-ruby-on-rails-postgres")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestWebStorm(t *testing.T) {
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
func shouldSkip(ideName string) bool {
ideIndex := -1
for i, name := range jetBrainsIDEs {
if name == ideName {
ideIndex = i
break
}
}
f := features.New("Start a workspace using WebStorm").
WithLabel("component", "IDE").
WithLabel("ide", "WebStorm").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "webstorm", "https://github.com/gitpod-samples/template-typescript-react")
return ctx
}).
Feature()
testEnv.Test(t, f)
}

func TestRider(t *testing.T) {
if roboquatToken == "" {
t.Skip("this test need github action run permission")
}
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
f := features.New("Start a workspace using Rider").
WithLabel("component", "IDE").
WithLabel("ide", "Rider").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "Rider", "https://github.com/gitpod-samples/template-dotnet-core-cli-csharp")
return ctx
}).
Feature()
testEnv.Test(t, f)
return time.Now().Day()%len(jetBrainsIDEs) != ideIndex
}

func TestCLion(t *testing.T) {
if roboquatToken == "" {
t.Skip("this test need github action run permission")
func TestJetBrainsIDEs(t *testing.T) {
for _, ideName := range jetBrainsIDEs {
if shouldSkip(ideName) {
// continue
}
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
if roboquatToken == "" {
t.Fatal("this test need github action run permission")
}
f := features.New(fmt.Sprintf("Workspace running with %s", ideName)).
WithLabel("component", "IDE").
WithLabel("ide", ideName).
Assess("JetBrains Gateway connection", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, ideName, "https://github.com/gitpod-io/empty")
return ctx
}).
Feature()
testEnv.Test(t, f)
}
integration.SkipWithoutUsername(t, username)
integration.SkipWithoutUserToken(t, userToken)
f := features.New("Start a workspace using CLion").
WithLabel("component", "IDE").
WithLabel("ide", "CLion").
Assess("it can let JetBrains Gateway connect", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()
JetBrainsIDETest(ctx, t, cfg, "CLion", "https://github.com/gitpod-samples/template-cpp")
return ctx
}).
Feature()
testEnv.Test(t, f)
}