From 534dd3ece1af84d9673cb3b0f2e37ac280ff66b1 Mon Sep 17 00:00:00 2001 From: Tibor Dancs Date: Wed, 15 Jan 2020 15:19:48 +0100 Subject: [PATCH 1/5] Implemented new Python Django devfile test Signed-off-by: Tibor Dancs --- tests/e2e/mocha-python-django.opts | 8 +++ tests/e2e/package.json | 1 + tests/e2e/pageobjects/ide/DialogWindow.ts | 0 tests/e2e/pageobjects/ide/Ide.ts | 0 tests/e2e/tests/devfiles/Go.spec.ts | 0 tests/e2e/tests/devfiles/JavaMaven.spec.ts | 6 +- tests/e2e/tests/devfiles/JavaVertx.spec.ts | 6 +- tests/e2e/tests/devfiles/PythonDjango.spec.ts | 63 +++++++++++++++++++ tests/e2e/testsLibrary/CodeExecutionTests.ts | 2 +- 9 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 tests/e2e/mocha-python-django.opts mode change 100755 => 100644 tests/e2e/pageobjects/ide/DialogWindow.ts mode change 100755 => 100644 tests/e2e/pageobjects/ide/Ide.ts create mode 100644 tests/e2e/tests/devfiles/Go.spec.ts create mode 100644 tests/e2e/tests/devfiles/PythonDjango.spec.ts mode change 100755 => 100644 tests/e2e/testsLibrary/CodeExecutionTests.ts diff --git a/tests/e2e/mocha-python-django.opts b/tests/e2e/mocha-python-django.opts new file mode 100644 index 00000000000..cbc1584de96 --- /dev/null +++ b/tests/e2e/mocha-python-django.opts @@ -0,0 +1,8 @@ +--timeout 2200000 +--reporter 'dist/driver/CheReporter.js' +-u tdd +--bail +--full-trace +--spec dist/tests/login/Login.spec.js +--spec dist/tests/devfiles/PythonDjango.spec.js +--require source-map-support/register diff --git a/tests/e2e/package.json b/tests/e2e/package.json index b2ae4bb8451..30ec4f63d88 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -14,6 +14,7 @@ "test-operatorhub-installation": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-che-operatorhub.opts", "test-wkspc-creation-and-ls": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-wkspc-creation-and-ls.opts", "test-java-vertx": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-java-vertx.opts", + "test-python-django": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-python-django.opts", "test-all-devfiles": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-all-devfiles.opts", "lint": "tslint --fix -p .", "tsc": "tsc -p ." diff --git a/tests/e2e/pageobjects/ide/DialogWindow.ts b/tests/e2e/pageobjects/ide/DialogWindow.ts old mode 100755 new mode 100644 diff --git a/tests/e2e/pageobjects/ide/Ide.ts b/tests/e2e/pageobjects/ide/Ide.ts old mode 100755 new mode 100644 diff --git a/tests/e2e/tests/devfiles/Go.spec.ts b/tests/e2e/tests/devfiles/Go.spec.ts new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/e2e/tests/devfiles/JavaMaven.spec.ts b/tests/e2e/tests/devfiles/JavaMaven.spec.ts index 54970a6315d..4b4da6ac8ea 100644 --- a/tests/e2e/tests/devfiles/JavaMaven.spec.ts +++ b/tests/e2e/tests/devfiles/JavaMaven.spec.ts @@ -22,20 +22,20 @@ const codeNavigationClassName: string = 'String.class'; const stack : string = 'Java Maven'; const taskName: string = 'maven build'; -suite('Java Maven test', async () => { +suite(`${stack} test`, async () => { suite (`Create ${stack} workspace ${workspaceName}`, async () => { workspaceHandling.createAndOpenWorkspace(workspaceName, stack); projectAndFileTests.waitWorkspaceReadiness(workspaceName, sampleName, 'src'); }); suite('Validation of workspace build and run', async () => { - codeExecutionTests.runTask(taskName, 120000); + codeExecutionTests.runTask(taskName, 120_000); codeExecutionTests.closeTerminal(taskName); }); suite('Language server validation', async () => { projectAndFileTests.openFile(fileFolderPath, tabTitle); - commonLsTests.waitLSInitialization('Activating Language Support for Java', 1800000, 360000); + commonLsTests.waitLSInitialization('Activating Language Support for Java', 1_800_000, 360_000); commonLsTests.suggestionInvoking(tabTitle, 10, 20, 'append(char c) : PrintStream'); commonLsTests.errorHighlighting(tabTitle, 'error', 11); commonLsTests.autocomplete(tabTitle, 10, 11, 'System - java.lang'); diff --git a/tests/e2e/tests/devfiles/JavaVertx.spec.ts b/tests/e2e/tests/devfiles/JavaVertx.spec.ts index 04c7ecdec12..aac271a3343 100644 --- a/tests/e2e/tests/devfiles/JavaVertx.spec.ts +++ b/tests/e2e/tests/devfiles/JavaVertx.spec.ts @@ -23,7 +23,7 @@ const buildTaskName: string = 'maven build'; const LSstarting: string = 'Activating Language Support for Java'; const stack: string = 'Java Vert.x'; -suite('Java Vert.x test', async () => { +suite(`${stack} test`, async () => { suite (`Create ${stack} workspace ${workspaceName}`, async () => { workspaceHandling.createAndOpenWorkspace(workspaceName, stack); @@ -32,7 +32,7 @@ suite('Java Vert.x test', async () => { suite('Language server validation', async () => { projectAndFileTests.openFile(fileFolderPath, tabTitle); - commonLsTests.waitLSInitialization(LSstarting, 1800000, 360000); + commonLsTests.waitLSInitialization(LSstarting, 1_800_000, 360_000); commonLsTests.suggestionInvoking(tabTitle, 19, 31, 'router(Vertx vertx) : Router'); commonLsTests.errorHighlighting(tabTitle, 'error', 20); commonLsTests.autocomplete(tabTitle, 19, 7, 'Router - io.vertx.ext.web'); @@ -40,7 +40,7 @@ suite('Java Vert.x test', async () => { }); suite('Validation of project build', async () => { - codeExecutionTests.runTask(buildTaskName, 120000); + codeExecutionTests.runTask(buildTaskName, 120_000); codeExecutionTests.closeTerminal(buildTaskName); }); diff --git a/tests/e2e/tests/devfiles/PythonDjango.spec.ts b/tests/e2e/tests/devfiles/PythonDjango.spec.ts new file mode 100644 index 00000000000..fe22eb89475 --- /dev/null +++ b/tests/e2e/tests/devfiles/PythonDjango.spec.ts @@ -0,0 +1,63 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +import { NameGenerator } from '../../utils/NameGenerator'; +import { error } from 'selenium-webdriver'; +import 'reflect-metadata'; +import * as codeExecutionHelper from '../../testsLibrary/CodeExecutionTests'; +import * as workspaceHandler from '../../testsLibrary/WorksapceHandlingTests'; +import * as projectManager from '../../testsLibrary/ProjectAndFileTests'; +import { Logger } from '../../utils/Logger'; + +const workspaceName: string = NameGenerator.generate('wksp-test-', 5); +const workspaceStack: string = 'Python Django'; +const workspaceSampleName: string = 'django-realworld-example-app'; +const workspaceRootFolderName: string = 'conduit'; + +const taskInstallDependencies: string = 'install dependencies'; +const taskMigrate: string = 'migrate'; +const taskRunServer: string = 'run server'; +const taskExpectedDialogText: string = 'A process is now listening on port 7000'; + +suite(`${workspaceStack} test`, async () => { + + suite(`Create ${workspaceStack} workspace ${workspaceName}`, async () => { + workspaceHandler.createAndOpenWorkspace(workspaceName, workspaceStack); + projectManager.waitWorkspaceReadiness(workspaceName, workspaceSampleName, workspaceRootFolderName); + }); + + suite('Install dependencies', async () => { + codeExecutionHelper.runTask(taskInstallDependencies, 60_000); + codeExecutionHelper.closeTerminal(taskInstallDependencies); + }); + + suite('Migrate Django application project', async () => { + codeExecutionHelper.runTask(taskMigrate, 30_000); + codeExecutionHelper.closeTerminal(taskMigrate); + }); + + suite('Run django server', async () => { + //todo: fix try catch block. exception is not being caught for some reason + try { + codeExecutionHelper.runTaskWithDialogShellAndOpenLink(taskRunServer, taskExpectedDialogText, 30_000); + } catch (err) { + Logger.debug(`Caught an exception while trying to run the Django example application server.`); + if (err instanceof error.TimeoutError) { + console.log(` ⚠️ Python Django failed to load deployed example application server.`); + console.log(` ⚠️ This issue is being reported here: `); + } else { throw err; } + } + }); + + suite('Stop and remove workspace', async() => { + workspaceHandler.stopWorkspace(workspaceName); + workspaceHandler.removeWorkspace(workspaceName); + }); + +}); diff --git a/tests/e2e/testsLibrary/CodeExecutionTests.ts b/tests/e2e/testsLibrary/CodeExecutionTests.ts old mode 100755 new mode 100644 index 572563a2639..11063651a83 --- a/tests/e2e/testsLibrary/CodeExecutionTests.ts +++ b/tests/e2e/testsLibrary/CodeExecutionTests.ts @@ -17,7 +17,7 @@ const ide: Ide = e2eContainer.get(CLASSES.Ide); const dialogWindow: DialogWindow = e2eContainer.get(CLASSES.DialogWindow); export function runTask(taskName: string, timeout: number) { - test( `Run command '${taskName}'`, async () => { + test(`Run command '${taskName}'`, async () => { await topMenu.runTask(taskName); await ide.waitNotification('has exited with code 0.', timeout); }); From c98fc20557d0ef53fef9bdf0f095e9bc3686fc6e Mon Sep 17 00:00:00 2001 From: Tibor Dancs Date: Thu, 30 Jan 2020 17:05:46 +0100 Subject: [PATCH 2/5] Added workaround for preview page not being displayed Signed-off-by: Tibor Dancs --- tests/e2e/tests/devfiles/PythonDjango.spec.ts | 14 ++--------- tests/e2e/testsLibrary/CodeExecutionTests.ts | 23 ++++++++++++++++++- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/e2e/tests/devfiles/PythonDjango.spec.ts b/tests/e2e/tests/devfiles/PythonDjango.spec.ts index fe22eb89475..874d83a960b 100644 --- a/tests/e2e/tests/devfiles/PythonDjango.spec.ts +++ b/tests/e2e/tests/devfiles/PythonDjango.spec.ts @@ -8,12 +8,10 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ import { NameGenerator } from '../../utils/NameGenerator'; -import { error } from 'selenium-webdriver'; import 'reflect-metadata'; import * as codeExecutionHelper from '../../testsLibrary/CodeExecutionTests'; import * as workspaceHandler from '../../testsLibrary/WorksapceHandlingTests'; import * as projectManager from '../../testsLibrary/ProjectAndFileTests'; -import { Logger } from '../../utils/Logger'; const workspaceName: string = NameGenerator.generate('wksp-test-', 5); const workspaceStack: string = 'Python Django'; @@ -24,6 +22,7 @@ const taskInstallDependencies: string = 'install dependencies'; const taskMigrate: string = 'migrate'; const taskRunServer: string = 'run server'; const taskExpectedDialogText: string = 'A process is now listening on port 7000'; +const taskCustomUrlSubpath: string = '/api/'; suite(`${workspaceStack} test`, async () => { @@ -43,16 +42,7 @@ suite(`${workspaceStack} test`, async () => { }); suite('Run django server', async () => { - //todo: fix try catch block. exception is not being caught for some reason - try { - codeExecutionHelper.runTaskWithDialogShellAndOpenLink(taskRunServer, taskExpectedDialogText, 30_000); - } catch (err) { - Logger.debug(`Caught an exception while trying to run the Django example application server.`); - if (err instanceof error.TimeoutError) { - console.log(` ⚠️ Python Django failed to load deployed example application server.`); - console.log(` ⚠️ This issue is being reported here: `); - } else { throw err; } - } + codeExecutionHelper.runTaskWithDialogShellDjangoWorkaround(taskRunServer, taskExpectedDialogText, taskCustomUrlSubpath, 30_000); }); suite('Stop and remove workspace', async() => { diff --git a/tests/e2e/testsLibrary/CodeExecutionTests.ts b/tests/e2e/testsLibrary/CodeExecutionTests.ts index 11063651a83..3cd1c8c8db8 100644 --- a/tests/e2e/testsLibrary/CodeExecutionTests.ts +++ b/tests/e2e/testsLibrary/CodeExecutionTests.ts @@ -8,13 +8,16 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -import { CLASSES, Terminal, TopMenu, Ide, DialogWindow } from '..'; +import { CLASSES, Terminal, TopMenu, Ide, DialogWindow, DriverHelper } from '..'; import { e2eContainer } from '../inversify.config'; +import Axios from 'axios'; +import https from 'https'; const terminal: Terminal = e2eContainer.get(CLASSES.Terminal); const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu); const ide: Ide = e2eContainer.get(CLASSES.Ide); const dialogWindow: DialogWindow = e2eContainer.get(CLASSES.DialogWindow); +const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); export function runTask(taskName: string, timeout: number) { test(`Run command '${taskName}'`, async () => { @@ -30,6 +33,24 @@ export function runTaskWithDialogShellAndOpenLink(taskName: string, expectedDial }); } +export function runTaskWithDialogShellDjangoWorkaround(taskName: string, expectedDialogText: string, urlSubPath: string, timeout: number) { + test(`Run command '${taskName}' expecting dialog shell`, async () => { + await topMenu.runTask(taskName); + await dialogWindow.waitDialog(timeout, expectedDialogText); + const dialogRedirectUrl: string = await dialogWindow.getApplicationUrlFromDialog(expectedDialogText); + const augmentedPreviewUrl: string = dialogRedirectUrl + urlSubPath; + await dialogWindow.closeDialog(); + await dialogWindow.waitDialogDissappearance(); + await driverHelper.getDriver().wait(async () => { + try { + const agent = new https.Agent({ rejectUnauthorized: false }); + const res = await Axios.get(augmentedPreviewUrl, { httpsAgent: agent }); + if (res.status === 200) { return true; } + } catch (error) { await driverHelper.wait(1_000); } + }, timeout); + }); +} + export function runTaskWithDialogShellAndClose(taskName: string, expectedDialogText: string, timeout: number) { test(`Run command '${taskName}' expecting dialog shell`, async () => { await topMenu.runTask(taskName); From 182a4f74d19c55a3bbfa506f66cd4b2ec3014b35 Mon Sep 17 00:00:00 2001 From: Tibor Dancs Date: Wed, 19 Feb 2020 10:43:30 +0100 Subject: [PATCH 3/5] Removing mocha opts for Python Django test, keeping tests in 'all-devfiles' mocha Signed-off-by: Tibor Dancs --- tests/e2e/mocha-python-django.opts | 8 -------- tests/e2e/package.json | 1 - 2 files changed, 9 deletions(-) delete mode 100644 tests/e2e/mocha-python-django.opts diff --git a/tests/e2e/mocha-python-django.opts b/tests/e2e/mocha-python-django.opts deleted file mode 100644 index cbc1584de96..00000000000 --- a/tests/e2e/mocha-python-django.opts +++ /dev/null @@ -1,8 +0,0 @@ ---timeout 2200000 ---reporter 'dist/driver/CheReporter.js' --u tdd ---bail ---full-trace ---spec dist/tests/login/Login.spec.js ---spec dist/tests/devfiles/PythonDjango.spec.js ---require source-map-support/register diff --git a/tests/e2e/package.json b/tests/e2e/package.json index 30ec4f63d88..b2ae4bb8451 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -14,7 +14,6 @@ "test-operatorhub-installation": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-che-operatorhub.opts", "test-wkspc-creation-and-ls": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-wkspc-creation-and-ls.opts", "test-java-vertx": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-java-vertx.opts", - "test-python-django": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-python-django.opts", "test-all-devfiles": "./generateIndex.sh && npm run lint && npm run tsc && mocha --opts mocha-all-devfiles.opts", "lint": "tslint --fix -p .", "tsc": "tsc -p ." From 58fb0430e8187b56f52d99fae57fa6faf3c665d7 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 19 Feb 2020 15:20:34 +0200 Subject: [PATCH 4/5] Increase start workspace timeout --- tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile b/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile index e62b1ef06e4..74c5e3eb236 100644 --- a/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile +++ b/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile @@ -312,6 +312,7 @@ pipeline { -e TS_SELENIUM_USERNAME="admin" \\ -e TS_SELENIUM_PASSWORD="admin" \\ -e TEST_SUITE="${e2eTestToRun}" \\ + -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=900000 \\ -v ${WORKSPACE}/tests/e2e:/tmp/e2e:Z \\ quay.io/eclipse/che-e2e:nightly """ From 8fc00a3943f6f5d8b37ccc371a9d7d03f97c62ee Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 20 Feb 2020 16:04:36 +0200 Subject: [PATCH 5/5] Increase TS_SELENIUM_LOAD_PAGE_TIMEOUT to 6 minutes for the sake of stabilization --- tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile b/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile index 74c5e3eb236..64050b654a1 100644 --- a/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile +++ b/tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile @@ -304,7 +304,7 @@ pipeline { docker run --shm-size=1g --net=host --ipc=host \\ -p 5920:5920 \\ -e TS_SELENIUM_DEFAULT_TIMEOUT=300000 \\ - -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=240000 \\ + -e TS_SELENIUM_LOAD_PAGE_TIMEOUT=420000 \\ -e TS_SELENIUM_WORKSPACE_STATUS_POLLING=20000 \\ -e TS_SELENIUM_BASE_URL=\${CHE_URL} \\ -e TS_SELENIUM_LOG_LEVEL='DEBUG' \\ @@ -312,7 +312,6 @@ pipeline { -e TS_SELENIUM_USERNAME="admin" \\ -e TS_SELENIUM_PASSWORD="admin" \\ -e TEST_SUITE="${e2eTestToRun}" \\ - -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=900000 \\ -v ${WORKSPACE}/tests/e2e:/tmp/e2e:Z \\ quay.io/eclipse/che-e2e:nightly """