Skip to content

Enable integration test for JetBrains IDEs #9203

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

Merged
merged 2 commits into from
Apr 13, 2022
Merged
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
111 changes: 111 additions & 0 deletions .werft/ide-integration-tests-startup-jetbrains.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
pod:
serviceAccount: werft
nodeSelector:
dev/workload: builds
imagePullSecrets:
- name: eu-gcr-io-pull-secret
volumes:
- name: gcp-sa
secret:
secretName: gcp-sa-gitpod-dev-deployer
- name: config
emptyDir: {}
containers:
- name: gcloud
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:clu-yq4.1
workingDir: /workspace
imagePullPolicy: Always
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: ROBOQUAT_TOKEN
valueFrom:
secretKeyRef:
name: github-roboquat-automatic-changelog
key: token
volumeMounts:
- name: gcp-sa
mountPath: /mnt/secrets/gcp-sa
readOnly: true
- name: config
mountPath: /config
readOnly: false
command:
- bash
- -c
- |
set -euo pipefail

BRANCH="inte-test/"$(date +%Y%m%d%H%M%S)

function cleanup ()
{
git push origin :$BRANCH
}

source ./dev/preview/util/preview-name-from-branch.sh

echo "preparing config." | werft log slice prepare
sudo chown -R gitpod:gitpod /workspace
gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json
export GOOGLE_APPLICATION_CREDENTIALS="/home/gitpod/.config/gcloud/legacy_credentials/[email protected]/adc.json"

git config --global user.name roboquat
git config --global user.email [email protected]
git remote set-url origin https://oauth2:[email protected]/gitpod-io/gitpod.git

echo "copied config..." | werft log slice prepare
go install github.com/csweichel/oci-tool@latest 2>&1 | werft log slice prepare
werft log slice prepare --done

werft log phase "build preview environment" "build preview environment"
echo integration test >> README.md
git checkout -B $BRANCH
git add README.md
git commit -m "integration test"
git push --set-upstream origin $BRANCH
trap cleanup SIGINT SIGTERM EXIT

BUILD_ID=$(werft job list repo.ref==refs/heads/${BRANCH} -o yaml | yq r - "result[0].name")
until [ "$BUILD_ID" != "" ]
do
sleep 1
BUILD_ID=$(werft job list repo.ref==refs/heads/${BRANCH} -o yaml | yq r - "result[0].name")
done
echo "start build preview environment, job name: ${BUILD_ID}, this will take long time" | werft log slice "build test environment"
werft log result -d "build job" url "https://werft.gitpod-dev.com/job/${BUILD_ID}"

if ! werft job logs ${BUILD_ID} | werft log slice "build test environment";
then
echo "build failed" | werft log slice "build test environment"
exit 1
fi
echo "build success" | werft log slice "build test environment"
werft log slice "build test environment" --done

werft log phase "integration test" "integration test"

oci-tool fetch file eu.gcr.io/gitpod-core-dev/build/versions:${BUILD_ID:13} versions.yaml
INTEGRATION_VERSION=$(cat versions.yaml | yq r - 'components.integrationTest.version')

echo "using integration-test image: ${INTEGRATION_VERSION}" | werft log slice "test"

NAMESPACE="$(preview-name-from-branch)"

JETBRAINS_IDE_LIST=(goland intellij phpstorm pycharm)
BUILD_ID_LIST=()

for IDE in "${JETBRAINS_IDE_LIST[@]}"
do
TEST_BUILD_ID=$(werft run github -a version=${INTEGRATION_VERSION} -a namespace=staging-${NAMESPACE} --remote-job-path .werft/ide-run-integration-tests.yaml -a testPattern=jetbrains.test -a jetbrains-ide=${IDE})
echo "running integration for ${IDE}, job name: ${TEST_BUILD_ID}" | werft log slice "test-${IDE}"
werft log result -d "integration test for ${IDE} job" url "https://werft.gitpod-dev.com/job/${TEST_BUILD_ID}"
werft job logs ${TEST_BUILD_ID} | werft log slice "test-${IDE}" &
BUILD_ID_LIST[${#BUILD_ID_LIST[@]}]=$TEST_BUILD_ID
sleep 2
done
wait
plugins:
cron: "0 2 * * *"
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class IdeDownloader @JvmOverloads constructor(private val httpClient: OkHttpClie
"https://data.services.jetbrains.com/products/releases".toHttpUrl()
.newBuilder()
.addQueryParameter("code", ide.feedsCode)
.addQueryParameter("type", "eap,rc,release")
.addQueryParameter("platform", getFeedsOsPropertyName())
.build()
).build()
Expand Down
17 changes: 15 additions & 2 deletions test/tests/ide/jetbrains/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/google/go-github/v42/github"
)

var ideProjectMap map[string]string

type GatewayHostStatus struct {
AppPid int64 `json:"appPid"`
AppVersion string `json:"appVersion"`
Expand All @@ -43,6 +45,14 @@ type GatewayHostStatus struct {
UnattendedMode bool `json:"unattendedMode"`
}

func init() {
ideProjectMap = make(map[string]string)
ideProjectMap["goland"] = "https://github.com/gitpod-io/template-golang-cli"
ideProjectMap["intellij"] = "https://github.com/gitpod-io/spring-petclinic"
ideProjectMap["phpstorm"] = "https://github.com/gitpod-io/template-php-laravel-mysql"
ideProjectMap["pycharm"] = "https://github.com/gitpod-io/template-python-django"
}

func GetHttpContent(url string) ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
Expand All @@ -57,7 +67,10 @@ func TestJetBrainsGatewayWorkspace(t *testing.T) {
userToken, _ := os.LookupEnv("USER_TOKEN")
ideName, ok := annotations["jetbrains-ide"]
if !ok {
t.Skip("not provide a special IDE")
t.Skip("not provide a special IDE name")
}
if _, ok = ideProjectMap[ideName]; !ok {
t.Skip("not support " + ideName + " now")
}
roboquatToken, ok := os.LookupEnv("ROBOQUAT_TOKEN")
if !ok {
Expand Down Expand Up @@ -96,7 +109,7 @@ func TestJetBrainsGatewayWorkspace(t *testing.T) {
t.Logf("connected to server")

t.Logf("starting workspace")
nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(ctx, "referrer:jetbrains-gateway:"+ideName+"/https://github.com/gitpod-io/spring-petclinic", username, api)
nfo, stopWs, err := integration.LaunchWorkspaceFromContextURL(ctx, "referrer:jetbrains-gateway:"+ideName+"/"+ideProjectMap[ideName], username, api)
if err != nil {
t.Fatal(err)
}
Expand Down