From f2c599100a3d3c6abe5e36840213a5053d7b264d Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Mon, 15 Feb 2021 16:51:51 +0100 Subject: [PATCH] e2e: Add MPI test (#2149) test isolve-mpi.js --- .../component/widget/logger/LoggerView.js | 3 + .../tutorials/{isolve.js => isolve-gpu.js} | 4 +- tests/e2e/tutorials/isolve-mpi.js | 73 +++++++++++++++++++ tests/e2e/tutorials/tutorialBase.js | 6 +- tests/e2e/utils/auto.js | 25 ++++++- tests/e2e/utils/utils.js | 20 ++++- 6 files changed, 120 insertions(+), 11 deletions(-) rename tests/e2e/tutorials/{isolve.js => isolve-gpu.js} (93%) create mode 100644 tests/e2e/tutorials/isolve-mpi.js diff --git a/services/web/client/source/class/osparc/component/widget/logger/LoggerView.js b/services/web/client/source/class/osparc/component/widget/logger/LoggerView.js index ce241b5fc13..3d683c831c3 100644 --- a/services/web/client/source/class/osparc/component/widget/logger/LoggerView.js +++ b/services/web/client/source/class/osparc/component/widget/logger/LoggerView.js @@ -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 }); @@ -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); @@ -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({ diff --git a/tests/e2e/tutorials/isolve.js b/tests/e2e/tutorials/isolve-gpu.js similarity index 93% rename from tests/e2e/tutorials/isolve.js rename to tests/e2e/tutorials/isolve-gpu.js index 03c8ef3685e..32f005edd90 100644 --- a/tests/e2e/tutorials/isolve.js +++ b/tests/e2e/tutorials/isolve-gpu.js @@ -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 @@ -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", diff --git a/tests/e2e/tutorials/isolve-mpi.js b/tests/e2e/tutorials/isolve-mpi.js new file mode 100644 index 00000000000..159d380904e --- /dev/null +++ b/tests/e2e/tutorials/isolve-mpi.js @@ -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); + }); \ No newline at end of file diff --git a/tests/e2e/tutorials/tutorialBase.js b/tests/e2e/tutorials/tutorialBase.js index de10a6d06ce..0c1e828efee 100644 --- a/tests/e2e/tutorials/tutorialBase.js +++ b/tests/e2e/tutorials/tutorialBase.js @@ -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); diff --git a/tests/e2e/utils/auto.js b/tests/e2e/utils/auto.js index 6ca2a93913e..0b0d06c4bb7 100644 --- a/tests/e2e/utils/auto.js +++ b/tests/e2e/utils/auto.js @@ -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) { @@ -354,7 +370,8 @@ module.exports = { dashboardNewStudy, dashboardOpenFirstTemplate, dashboardOpenFirstService, - clickLoggerTitle, + showLogger, + findLogMessage, runStudy, deleteFirstStudy, toDashboard, diff --git a/tests/e2e/utils/utils.js b/tests/e2e/utils/utils.js index c1732c995e4..c807294fa3b 100644 --- a/tests/e2e/utils/utils.js +++ b/tests/e2e/utils/utils.js @@ -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"]') } @@ -384,5 +398,7 @@ module.exports = { parseCommandLineArguments, parseCommandLineArgumentsTemplate, getGrayLogSnapshotUrl, - typeInInputElement + typeInInputElement, + isElementVisible, + clickLoggerTitle, }