Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

[E2E] Add Java Vertx test #1619

Merged
merged 1 commit into from
Sep 17, 2019
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
5 changes: 5 additions & 0 deletions e2e-saas/mocha-all.opts
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions e2e-saas/mocha-java-maven.opts
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions e2e-saas/mocha-java-vertx.opts
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions e2e-saas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 2 additions & 10 deletions e2e-saas/tests/JavaMaven.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -22,7 +22,6 @@ const tabTitle: string = 'HelloWorld.java';
const codeNavigationClassName: string = 'String.class';

const e2eContainer: Container = inversifyConfig.e2eContainer;
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
const newWorkspace: NewWorkspace = e2eContainer.get(CLASSES.NewWorkspace);
const ide: Ide = e2eContainer.get(CLASSES.Ide);
Expand All @@ -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();
Expand Down
157 changes: 157 additions & 0 deletions e2e-saas/tests/JavaVertx.spec.ts
Original file line number Diff line number Diff line change
@@ -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<any> = 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);
}

});
23 changes: 23 additions & 0 deletions e2e-saas/tests/login/Login.spec.ts
Original file line number Diff line number Diff line change
@@ -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<ICheLoginPage>(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);
});
});
40 changes: 24 additions & 16 deletions functional-tests/devscripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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=$?
Expand All @@ -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

Expand All @@ -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=$?
Expand Down