diff --git a/e2e-saas/mocha-all.opts b/e2e-saas/mocha-all.opts new file mode 100644 index 000000000..16c14a944 --- /dev/null +++ b/e2e-saas/mocha-all.opts @@ -0,0 +1,5 @@ +--timeout 120000 +--reporter 'node_modules/e2e/dist/driver/CheReporter.js' +-u tdd +--spec ./dist/tests/login/Login.spec.js +--spec ./dist/tests/*.spec.js diff --git a/e2e-saas/mocha-java-maven.opts b/e2e-saas/mocha-java-maven.opts index ce008d298..578bbdbd0 100644 --- a/e2e-saas/mocha-java-maven.opts +++ b/e2e-saas/mocha-java-maven.opts @@ -1,4 +1,5 @@ --timeout 120000 --reporter 'node_modules/e2e/dist/driver/CheReporter.js' -u tdd +--spec ./dist/tests/login/Login.spec.js --spec ./dist/tests/JavaMaven.spec.js diff --git a/e2e-saas/mocha-java-vertx.opts b/e2e-saas/mocha-java-vertx.opts new file mode 100644 index 000000000..ec19ad562 --- /dev/null +++ b/e2e-saas/mocha-java-vertx.opts @@ -0,0 +1,5 @@ +--timeout 120000 +--reporter 'node_modules/e2e/dist/driver/CheReporter.js' +-u tdd +--spec ./dist/tests/login/Login.spec.js +--spec ./dist/tests/JavaVertx.spec.js diff --git a/e2e-saas/package.json b/e2e-saas/package.json index 6d093a590..558ac8d29 100644 --- a/e2e-saas/package.json +++ b/e2e-saas/package.json @@ -5,6 +5,8 @@ "main": "index.ts", "scripts": { "test-java-maven": "npm run lint && npm run tsc && mocha --opts mocha-java-maven.opts", + "test-java-vertx": "npm run lint && npm run tsc && mocha --opts mocha-java-vertx.opts", + "test-all": "npm run lint && npm run tsc && mocha --opts mocha-all.opts", "tsc": "rm -rf dist && tsc -p .", "lint": "tslint --fix -p .", "test_without_lint": "npm run tsc && mocha --opts mocha.opts" diff --git a/e2e-saas/tests/JavaMaven.spec.ts b/e2e-saas/tests/JavaMaven.spec.ts index 3648775fb..11ae9c958 100644 --- a/e2e-saas/tests/JavaMaven.spec.ts +++ b/e2e-saas/tests/JavaMaven.spec.ts @@ -8,7 +8,7 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ import 'reflect-metadata'; -import { TYPES, CLASSES, TestConstants, ICheLoginPage, Dashboard, Editor, Ide, NameGenerator , NewWorkspace, ProjectTree, TopMenu, QuickOpenContainer, Terminal, inversifyConfig } from 'e2e'; +import { CLASSES, TestConstants, Dashboard, Editor, Ide, NameGenerator , NewWorkspace, ProjectTree, TopMenu, QuickOpenContainer, Terminal, inversifyConfig } from 'e2e'; import { error, Key } from 'selenium-webdriver'; import * as restClient from 'typed-rest-client/RestClient'; import { RhCheTestConstants } from '../RhCheTestConstants'; @@ -22,7 +22,6 @@ const tabTitle: string = 'HelloWorld.java'; const codeNavigationClassName: string = 'String.class'; const e2eContainer: Container = inversifyConfig.e2eContainer; -const loginPage: ICheLoginPage = e2eContainer.get(TYPES.CheLogin); const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); const newWorkspace: NewWorkspace = e2eContainer.get(CLASSES.NewWorkspace); const ide: Ide = e2eContainer.get(CLASSES.Ide); @@ -32,14 +31,7 @@ const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu); const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer); const terminal: Terminal = e2eContainer.get(CLASSES.Terminal); -suite('RhChe E2E', async () => { - suite('Login and wait dashboard', async () => { - test('Login', async () => { - await loginPage.login(); - await dashboard.waitPage(30000); - }); - }); - +suite('RhChe E2E Java Maven test', async () => { suite('Create and run workspace ' + workspaceName, async () => { test(`Open 'New Workspace' page`, async () => { await newWorkspace.openPageByUI(); diff --git a/e2e-saas/tests/JavaVertx.spec.ts b/e2e-saas/tests/JavaVertx.spec.ts new file mode 100644 index 000000000..24c1f9c40 --- /dev/null +++ b/e2e-saas/tests/JavaVertx.spec.ts @@ -0,0 +1,157 @@ +/********************************************************************* + * 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, TestConstants, CLASSES, inversifyConfig, Dashboard, NewWorkspace, Ide, ProjectTree, Editor, TopMenu, QuickOpenContainer, Terminal } from 'e2e'; +import 'reflect-metadata'; +import { error, Key } from 'selenium-webdriver'; +import * as restClient from 'typed-rest-client/RestClient'; +import { RhCheTestConstants } from '../RhCheTestConstants'; + +const workspaceName: string = NameGenerator.generate('wksp-test-', 5); +const namespace: string = TestConstants.TS_SELENIUM_USERNAME; +const sampleName: string = 'java-web-vertx'; +const fileFolderPath: string = `${sampleName}/src/main/java/io/vertx/examples/spring`; +const tabTitle: string = 'SpringExampleRunner.java'; +const codeNavigationClassName: string = 'ApplicationContext.class'; + +const e2eContainer = inversifyConfig.e2eContainer; +const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); +const newWorkspace: NewWorkspace = e2eContainer.get(CLASSES.NewWorkspace); +const ide: Ide = e2eContainer.get(CLASSES.Ide); +const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); +const editor: Editor = e2eContainer.get(CLASSES.Editor); +const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu); +const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer); +const terminal: Terminal = e2eContainer.get(CLASSES.Terminal); + +suite('RhChe E2E Java Vert.x test', async () => { + suite('Create Java Vert.x workspace ' + workspaceName, async () => { + test('Open \'New Workspace\' page', async () => { + await newWorkspace.openPageByUI(); + }); + + test('Create and open workspace', async () => { + await newWorkspace.createAndOpenWorkspace(workspaceName, 'Java Vert.x'); + }); + }); + + suite('Work with IDE', async () => { + test('Wait IDE availability', async () => { + await ide.waitWorkspaceAndIde(namespace, workspaceName); + }); + + test('Open project tree container', async () => { + await projectTree.openProjectTreeContainer(); + }); + + test('Wait project imported', async () => { + try { + await projectTree.waitProjectImported(sampleName, 'src'); + } catch (err) { + if (!(err instanceof error.TimeoutError)) { + throw err; + } + var rest: restClient.RestClient = new restClient.RestClient('user-agent'); + const workspaceStatusApiUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/api/workspace/${namespace}:${workspaceName}`; + + const response: restClient.IRestResponse = await rest.get(workspaceStatusApiUrl, {additionalHeaders: {'Authorization' : 'Bearer ' + RhCheTestConstants.E2E_SAAS_TESTS_USER_TOKEN } }); + console.log('WORKSPACE DEFINITION: ' + JSON.stringify(response.result)); + throw err; + } + }); + + }); + + suite('Language server validation', async () => { + test('Expand project and open file in editor', async () => { + await projectTree.expandPathAndOpenFileInAssociatedWorkspace(fileFolderPath, tabTitle); + await editor.selectTab(tabTitle); + }); + + test('Java LS initialization', async () => { + await ide.checkLsInitializationStart('Starting Java Language Server'); + await ide.waitStatusBarTextAbsence('Starting Java Language Server', 1800000); + await ide.waitStatusBarTextAbsence('Building workspace', 360000); + }); + + test('Suggestion invoking', async () => { + await ide.closeAllNotifications(); + await editor.waitEditorAvailable(tabTitle); + await editor.clickOnTab(tabTitle); + await editor.waitEditorAvailable(tabTitle); + await editor.waitTabFocused(tabTitle); + await editor.moveCursorToLineAndChar(tabTitle, 19, 11); + await editor.pressControlSpaceCombination(tabTitle); + await editor.waitSuggestion(tabTitle, 'cancelTimer(long arg0) : boolean'); + }); + + test('Error highlighting', async () => { + await editor.type(tabTitle, 'error', 21); + await editor.waitErrorInLine(21); + await editor.performKeyCombination(tabTitle, Key.chord(Key.BACK_SPACE, Key.BACK_SPACE, Key.BACK_SPACE, Key.BACK_SPACE, Key.BACK_SPACE)); + await editor.waitErrorInLineDisappearance(21); + }); + + test('Autocomplete', async () => { + await editor.moveCursorToLineAndChar(tabTitle, 18, 15); + await editor.pressControlSpaceCombination(tabTitle); + await editor.waitSuggestionContainer(); + await editor.waitSuggestion(tabTitle, 'Vertx - io.vertx.core'); + }); + + test('Codenavigation', async () => { + await editor.moveCursorToLineAndChar(tabTitle, 17, 15); + await editor.performKeyCombination(tabTitle, Key.chord(Key.CONTROL, Key.F12)); + await editor.waitEditorAvailable(codeNavigationClassName); + }); + + }); + + suite('Validation of project build', async () => { + test('Build application', async () => { + let taskName: string = 'che: maven build'; + await runTask(taskName); + // uncomment in version higner then 7.1.0 or try to use upstream test, both should be same + // await quickOpenContainer.clickOnContainerItem('Continue without scanning the task output'); + await ide.waitNotification('Task ' + taskName + ' has exited with code 0.', 60000); + }); + + test('Close the terminal tasks', async () => { + await terminal.closeTerminalTab('maven build'); + }); + }); + + suite('Stop and remove workspace', async () => { + test('Stop workspace', async () => { + await dashboard.stopWorkspaceByUI(workspaceName); + }); + + test('Delete workspace', async () => { + await dashboard.deleteWorkspaceByUI(workspaceName); + }); + + }); + + async function runTask(task: string) { + await topMenu.selectOption('Terminal', 'Run Task...'); + try { + await quickOpenContainer.waitContainer(); + } catch (err) { + if (err instanceof error.TimeoutError) { + console.warn(`After clicking to the "Terminal" -> "Run Task ..." the "Quick Open Container" has not been displayed, one more try`); + + await topMenu.selectOption('Terminal', 'Run Task...'); + await quickOpenContainer.waitContainer(); + } + } + + await quickOpenContainer.clickOnContainerItem(task); + } + +}); diff --git a/e2e-saas/tests/login/Login.spec.ts b/e2e-saas/tests/login/Login.spec.ts new file mode 100644 index 000000000..75fe561f3 --- /dev/null +++ b/e2e-saas/tests/login/Login.spec.ts @@ -0,0 +1,23 @@ +/********************************************************************* + * 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 { ICheLoginPage, inversifyConfig, TYPES, CLASSES, Dashboard } from 'e2e'; +import { Container } from 'inversify'; + + const e2eContainer: Container = inversifyConfig.e2eContainer; + const loginPage: ICheLoginPage = e2eContainer.get(TYPES.CheLogin); + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + +suite('Login and wait dashboard', async () => { + test('Login', async () => { + await loginPage.login(); + await dashboard.waitPage(30000); + }); +}); diff --git a/functional-tests/devscripts/run_tests.sh b/functional-tests/devscripts/run_tests.sh index 69bedcfa6..13983823b 100755 --- a/functional-tests/devscripts/run_tests.sh +++ b/functional-tests/devscripts/run_tests.sh @@ -52,12 +52,6 @@ while getopts "hu:p:m:o:r:" opt; do esac done -if [[ "$JOB_NAME" == *"flaky"* ]]; then - TEST_SUITE="flaky.xml" -else - TEST_SUITE="simpleTestSuite.xml" -fi - #Get cluster to be able to get logs. Related to issue: https://github.com/redhat-developer/che-functional-tests/issues/476 if [[ "$USERNAME" == *"preview"* ]] || [[ "$PR_CHECK_BUILD" == "true" ]] || [[ "$JOB_NAME" == *"saas"* ]]; then API_SERVER_URL="https://api.prod-preview.openshift.io" @@ -131,6 +125,7 @@ if [[ "$PR_CHECK_BUILD" == "true" ]]; then -e USERNAME=$RH_CHE_AUTOMATION_CHE_PREVIEW_USERNAME \ -e PASSWORD=$RH_CHE_AUTOMATION_CHE_PREVIEW_PASSWORD \ -e URL=http://$HOST_URL \ + -e TEST_SUITE=test-all \ --shm-size=256m \ $rhche_image RESULT=$? @@ -148,19 +143,31 @@ else if [[ "$HOST_URL" == "che.openshift.io" ]]; then TAG=$(getVersionFromProd) echo "Running test with user $USERNAME against prod environment with version $TAG." - + path="$(pwd)" mkdir report - docker run \ - -v $path/report:/tmp/rh-che/e2e-saas/report:Z \ - -e USERNAME=$USERNAME \ - -e PASSWORD=$PASSWORD \ - -e URL=https://$HOST_URL \ - --shm-size=256m \ - quay.io/openshiftio/rhchestage-rh-che-e2e-tests:$TAG - RESULT=$? - + if [[ "$JOB_NAME" == *"flaky"* ]]; then + docker run \ + -v $path/report:/tmp/rh-che/e2e-saas/report:Z \ + -e USERNAME=$USERNAME \ + -e PASSWORD=$PASSWORD \ + -e URL=https://$HOST_URL \ + -e TEST_SUITE=test-all \ + --shm-size=256m \ + quay.io/openshiftio/rhchestage-rh-che-e2e-tests:$TAG + RESULT=$? + else + docker run \ + -v $path/report:/tmp/rh-che/e2e-saas/report:Z \ + -e USERNAME=$USERNAME \ + -e PASSWORD=$PASSWORD \ + -e URL=https://$HOST_URL \ + --shm-size=256m \ + quay.io/openshiftio/rhchestage-rh-che-e2e-tests:$TAG + RESULT=$? + fi + mkdir -p ./rhche/${JOB_NAME}/${BUILD_NUMBER}/e2e_report cp -r ./report/ ./rhche/${JOB_NAME}/${BUILD_NUMBER}/e2e_report @@ -177,6 +184,7 @@ else -e USERNAME=$USERNAME \ -e PASSWORD=$PASSWORD \ -e URL=https://$HOST_URL \ + -e TEST_SUITE=test-all \ --shm-size=256m \ quay.io/openshiftio/rhchestage-rh-che-e2e-tests:$TAG RESULT=$?