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

Implement Python Django devfile test #15831

Merged
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
2 changes: 1 addition & 1 deletion tests/.infra/crw-ci/pr-check/k8s/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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' \\
Expand Down
Empty file modified tests/e2e/pageobjects/ide/DialogWindow.ts
100755 → 100644
Empty file.
Empty file modified tests/e2e/pageobjects/ide/Ide.ts
100755 → 100644
Empty file.
Empty file.
6 changes: 3 additions & 3 deletions tests/e2e/tests/devfiles/JavaMaven.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
ScrewTSW marked this conversation as resolved.
Show resolved Hide resolved
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');
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/devfiles/JavaVertx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -32,15 +32,15 @@ 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');
commonLsTests.codeNavigation(tabTitle, 19, 7, codeNavigationClassName);
});

suite('Validation of project build', async () => {
codeExecutionTests.runTask(buildTaskName, 120000);
codeExecutionTests.runTask(buildTaskName, 120_000);
codeExecutionTests.closeTerminal(buildTaskName);
});

Expand Down
53 changes: 53 additions & 0 deletions tests/e2e/tests/devfiles/PythonDjango.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*********************************************************************
* 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 'reflect-metadata';
import * as codeExecutionHelper from '../../testsLibrary/CodeExecutionTests';
import * as workspaceHandler from '../../testsLibrary/WorksapceHandlingTests';
import * as projectManager from '../../testsLibrary/ProjectAndFileTests';

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';
const taskCustomUrlSubpath: string = '/api/';

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 () => {
codeExecutionHelper.runTaskWithDialogShellDjangoWorkaround(taskRunServer, taskExpectedDialogText, taskCustomUrlSubpath, 30_000);
});

suite('Stop and remove workspace', async() => {
workspaceHandler.stopWorkspace(workspaceName);
workspaceHandler.removeWorkspace(workspaceName);
});

});
25 changes: 23 additions & 2 deletions tests/e2e/testsLibrary/CodeExecutionTests.ts
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
* 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 () => {
test(`Run command '${taskName}'`, async () => {
await topMenu.runTask(taskName);
await ide.waitNotification('has exited with code 0.', timeout);
});
Expand All @@ -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 });
ScrewTSW marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down