Skip to content

Commit

Permalink
e2e: Add MPI test (#2149)
Browse files Browse the repository at this point in the history
test isolve-mpi.js
  • Loading branch information
odeimaiz authored Feb 15, 2021
1 parent e92177f commit f2c5991
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", {
liveUpdate: true,
placeholder: this.tr("Filter")
});
osparc.utils.Utils.setIdToWidget(textFilterField, "logsFilterField");
toolbar.add(textFilterField, {
flex: 1
});
Expand Down Expand Up @@ -189,6 +190,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", {
toolTipText: this.tr("Copy logs to clipboard"),
appearance: "toolbar-button"
});
osparc.utils.Utils.setIdToWidget(copyToClipboardButton, "copyLogsToClipboardButton");
copyToClipboardButton.addListener("execute", e => {
this.__copyLogsToClipboard();
}, this);
Expand All @@ -212,6 +214,7 @@ qx.Class.define("osparc.component.widget.logger.LoggerView", {
statusBarVisible: false,
showCellFocusIndicator: false
});
osparc.utils.Utils.setIdToWidget(table, "logsViewer");
const colModel = table.getTableColumnModel();
colModel.setDataCellRenderer(0, new qx.ui.table.cellrenderer.Html());
colModel.setDataCellRenderer(1, new osparc.ui.table.cellrenderer.Html().set({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// node isolve.js [url] [user] [password] [--demo]
// node isolve-gpu.js [url] [user] [password] [--demo]

// https://itisfoundation.github.io/osparc-manual-z43/#/Tutorials/GeneralTutorial

Expand Down Expand Up @@ -30,7 +30,7 @@ async function runTutorial() {
await tutorial.waitFor(5000);

await tutorial.runPipeline(studyId, 20000);
console.log('Checking isolve results:');
console.log('Checking isolve-gpu results:');
await tutorial.openNodeFiles(1);
const outFiles = [
"logs.zip",
Expand Down
73 changes: 73 additions & 0 deletions tests/e2e/tutorials/isolve-mpi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// node isolve-mpi.js [url] [user] [password] [--demo]

const utils = require('../utils/utils');
const tutorialBase = require('./tutorialBase');

const args = process.argv.slice(2);
const {
url,
user,
pass,
newUser,
enableDemoMode
} = utils.parseCommandLineArguments(args)

const templateName = "isolve-mpi";

async function runTutorial() {
const tutorial = new tutorialBase.TutorialBase(url, templateName, user, pass, newUser, enableDemoMode);

try {
tutorial.startScreenshooter();
await tutorial.start();
const studyData = await tutorial.openTemplate(1000);
const studyId = studyData["data"]["uuid"];
console.log("Study ID:", studyId);

// Some time for loading the workbench
await tutorial.waitFor(5000);

await tutorial.runPipeline(studyId, 20000);
console.log('Checking isolve-mpi results:');
await tutorial.openNodeFiles(1);
const outFiles = [
"logs.zip",
"output.h5",
"log.tgz"
];
await tutorial.checkResults(outFiles.length);

// check logs
const mustHave = "Running MPI version 3.1 on 2 processes";
const found = await tutorial.findLogMessage(mustHave);
if (found) {
console.log("Running MPI version 3.1 on 2 processes");
}
else {
throw "MPI not working";
}

await tutorial.toDashboard();

await tutorial.removeStudy(studyId);
}
catch(err) {
tutorial.setTutorialFailed(true);
console.log('Tutorial error: ' + err);
}
finally {
await tutorial.logOut();
tutorial.stopScreenshooter();
await tutorial.close();
}

if (tutorial.getTutorialFailed()) {
throw "Tutorial Failed";
}
}

runTutorial()
.catch(error => {
console.log('Puppeteer error: ' + error);
process.exit(1);
});
6 changes: 3 additions & 3 deletions tests/e2e/tutorials/tutorialBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ class TutorialBase {
await auto.restoreIFrame(this.__page);
}

async clickLoggerTitle() {
await auto.clickLoggerTitle(this.__page);
async findLogMessage(text) {
return await auto.findLogMessage(this.__page, text);
}

async runPipeline(studyId, timeout = 60000) {
await this.clickLoggerTitle();
await auto.showLogger(this.__page, true);

await this.takeScreenshot("runStudy_before");
await auto.runStudy(this.__page);
Expand Down
25 changes: 21 additions & 4 deletions tests/e2e/utils/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,25 @@ async function __filterTemplatesByText(page, templateName) {
await page.keyboard.press('Enter')
}

async function clickLoggerTitle(page) {
console.log("Click LoggerTitle");
await utils.waitAndClick(page, '[osparc-test-id="loggerTitleLabel"]')
async function showLogger(page, show = true) {
const isVisible = await utils.isElementVisible(page, '[osparc-test-id="logsViewer"]');

if (show !== isVisible) {
await utils.clickLoggerTitle(page);
}
}

async function findLogMessage(page, text) {
console.log("Finding Log Message");
await this.showLogger(page, true);

await utils.waitAndClick(page, '[osparc-test-id="logsFilterField"]');
await utils.clearInput(page, '[osparc-test-id="logsFilterField"]');
await page.type('[osparc-test-id="logsFilterField"]', text);

const found1 = await page.evaluate((text) => window.find(text), text);
await utils.takeScreenshot(page, 'find_' + text);
return found1;
}

async function runStudy(page) {
Expand Down Expand Up @@ -354,7 +370,8 @@ module.exports = {
dashboardNewStudy,
dashboardOpenFirstTemplate,
dashboardOpenFirstService,
clickLoggerTitle,
showLogger,
findLogMessage,
runStudy,
deleteFirstStudy,
toDashboard,
Expand Down
20 changes: 18 additions & 2 deletions tests/e2e/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,21 @@ function getGrayLogSnapshotUrl(targetUrl, since_secs = 30) {
async function typeInInputElement(page, inputSelector, text) {
const element = await page.waitForSelector(inputSelector);
await element.focus();
await page.keyboard.type(text, { delay: 100 });
await page.keyboard.type(text, {
delay: 100
});
}

function isElementVisible (page, selector) {
return page.evaluate(selector => {
const element = document.querySelector(selector)
return !!(element && (element.offsetWidth || element.offsetHeight || element.getClientRects().length))
}, selector);
}

async function clickLoggerTitle(page) {
console.log("Click LoggerTitle");
await this.waitAndClick(page, '[osparc-test-id="loggerTitleLabel"]')
}


Expand Down Expand Up @@ -384,5 +398,7 @@ module.exports = {
parseCommandLineArguments,
parseCommandLineArgumentsTemplate,
getGrayLogSnapshotUrl,
typeInInputElement
typeInInputElement,
isElementVisible,
clickLoggerTitle,
}

0 comments on commit f2c5991

Please sign in to comment.