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

e2e upgrade #2352

Merged
merged 24 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d0c1aa
merging
ignapas May 20, 2021
2e41616
mattward seems to work
ignapas May 25, 2021
b27f950
improved mattward sequence and some common methods
ignapas May 27, 2021
e564e4a
Merge branch 'master' into e2e
ignapas May 27, 2021
71dffe3
sleepers working
ignapas May 27, 2021
2c531bb
isolvegpu adapted
ignapas May 27, 2021
873a321
Merge branch 'master' into e2e
ignapas Jun 1, 2021
afc9030
Merge branch 'e2e' of github.com:ignapas/osparc-simcore into e2e
ignapas Jun 1, 2021
d59b177
fixed jupyters tutorial and always deleteing study
ignapas Jun 3, 2021
a613ef1
Merge branch 'master' into e2e
ignapas Jun 3, 2021
0a1e412
fixed every tutorial
ignapas Jun 3, 2021
a8e7224
Decrease screenshooter freq
ignapas Jun 3, 2021
bc7642f
modified p2e tests
ignapas Jun 3, 2021
28e9b01
remove study goes to dashboard first
ignapas Jun 3, 2021
f0321af
making check number of files optional
ignapas Jun 3, 2021
e916094
added notification logger
ignapas Jun 3, 2021
e3e8ced
Merge branch 'master' into e2e
ignapas Jun 3, 2021
14f77e8
Merge branch 'master' into e2e
ignapas Jun 10, 2021
e0848b9
removeStudy2 doesnt go to dashboard and waitFor takes no screenshots
ignapas Jun 10, 2021
06e9b07
added screenshooter
ignapas Jun 10, 2021
256e997
Added standard study deletion as backup of interactive one
ignapas Jun 10, 2021
ede6329
Removed duplicated comments and using previous removeStudy
ignapas Jun 10, 2021
8c67625
Merge branch 'master' into e2e
ignapas Jun 11, 2021
4413e43
Merge branch 'master' into e2e
ignapas Jun 15, 2021
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
4,713 changes: 1,721 additions & 2,992 deletions tests/e2e/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"test": "tests"
},
"dependencies": {
"jest": "^26.6.3",
"jest": "^24.9.0",
"jest-puppeteer": "^4.4.0",
"log-timestamp": "^0.3.0",
"log4js": "^6.3.0",
"puppeteer": "^5.5.0"
"puppeteer": "^2.1.1"
},
"devDependencies": {},
"scripts": {
Expand Down
15 changes: 6 additions & 9 deletions tests/e2e/tutorials/isolve-gpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ const templateName = "isolve-gpu";

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

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

// Some time for loading the workbench
Expand All @@ -37,19 +36,17 @@ async function runTutorial() {
"output.h5",
"log.tgz"
];
await tutorial.checkNodeResults(1, outFiles);

await tutorial.toDashboard();

await tutorial.removeStudy(studyId);
await tutorial.openNodeFiles(1)
await tutorial.checkResults2(outFiles);
}
catch(err) {
tutorial.setTutorialFailed(true);
console.log('Tutorial error: ' + err);
}
finally {
await tutorial.toDashboard();
await tutorial.removeStudy2(studyId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@odeimaiz odeimaiz Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the purpose of removeStudy2. Why don't you rename it and move the call to the catch section? (and keep the original way to removeStudy)
Also, removeStudy2 doesn't need to go toDashboard

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @odeimaiz, then we could detect when the remove study fails and still remove the studies

await tutorial.logOut();
tutorial.stopScreenshooter();
await tutorial.close();
}

Expand Down
16 changes: 7 additions & 9 deletions tests/e2e/tutorials/mattward.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ const templateName = "Mattward";

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

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

const workbenchData = utils.extractWorkbenchData(studyData["data"]);
await tutorial.waitForServices(workbenchData["studyId"], [workbenchData["nodeIds"][0]]);

// Wait for the output files to be pushed
await tutorial.waitFor(30000);
await tutorial.waitFor(30000, 'Wait for the output files to be pushed');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, probably then we can remove the duplicated comments.


// This study opens in fullscreen mode
await tutorial.restoreIFrame();
Expand All @@ -42,19 +41,18 @@ async function runTutorial() {
"t_plot.csv",
"tst_plot.csv"
];
await tutorial.checkNodeResults(0, outFiles);

await tutorial.toDashboard();

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

Expand Down
22 changes: 9 additions & 13 deletions tests/e2e/tutorials/sleepers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ const templateName = "Sleepers";

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

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

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

await tutorial.runPipeline();
await tutorial.waitForStudyDone(studyId, 60000);
Expand All @@ -34,22 +32,20 @@ async function runTutorial() {
"logs.zip",
"out_1"
];
await tutorial.checkNodeResults(0, outFiles);

console.log('Checking results for the last sleeper:');
await tutorial.checkNodeResults(4, outFiles);
await tutorial.openNodeFiles(0)
await tutorial.checkResults2(outFiles);

await tutorial.toDashboard();

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

Expand Down
41 changes: 36 additions & 5 deletions tests/e2e/tutorials/tutorialBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,28 @@ class TutorialBase {
await this.takeScreenshot("checkNodeResults_after");
}

async checkResults2(fileNames) {
try {
await this.takeScreenshot("checkResults_before");
const files = await this.__page.$$eval('[osparc-test-id="FolderViewerItem"]',
elements => elements.map(el => el.textContent.trim()));
assert(files.length === fileNames.length, 'Number of files is incorrect')
sanderegg marked this conversation as resolved.
Show resolved Hide resolved
console.log('Number of files is correct')
assert(
fileNames.every(fileName => files.some(file => file.includes(fileName))),
'File names are incorrect'
)
console.log('File names are correct')
}
catch (err) {
throw(err)
}
finally {
await utils.waitAndClick(this.__page, '[osparc-test-id="nodeDataManagerCloseBtn"]');
await this.takeScreenshot("checkResults_after");
}
}

async toDashboard() {
await this.takeScreenshot("toDashboard_before");
this.__responsesQueue.addResponseListener("projects");
Expand Down Expand Up @@ -383,6 +405,17 @@ class TutorialBase {
await this.takeScreenshot("deleteFirstStudy_after");
}

async removeStudy2(studyId) {
console.log(`Removing study ${studyId}`)
const resp = await this.__page.evaluate(async function(studyId) {
return await osparc.data.Resources.fetch('studies', 'delete', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

url: {
projectId: studyId
}
}, studyId);
}, studyId);
}

async logOut() {
await auto.logOut(this.__page);
}
Expand All @@ -392,8 +425,10 @@ class TutorialBase {
await this.__browser.close();
}

async waitFor(waitFor) {
async waitFor(waitFor, reason) {
console.log(`Waiting for ${waitFor}ms. Reason: ${reason}`)
await utils.sleep(waitFor);
await this.takeScreenshot('waitFor_finished')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

}

async takeScreenshot(screenshotTitle) {
Expand All @@ -403,10 +438,6 @@ class TutorialBase {
console.log("Backend Snapshot: ", snapshotUrl)
}

if (this.__demo) {
return;
}

let title = this.__templateName;
if (screenshotTitle) {
title += '_' + screenshotTitle;
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async function openNodeFiles(page) {
await utils.waitAndClick(page, '[osparc-test-id="nodeViewFilesBtn"]')
}

async function checkDataProducedByNode(page, nFiles = 1) {
async function checkDataProducedByNode(page, nFiles = 1, itemSuffix = 'NodeFiles') {
console.log("checking Data produced by Node. Expecting", nFiles, "file(s)");
const iconsContent = await page.waitForSelector('[osparc-test-id="FolderViewerIconsContent"]', {
timeout: 5000
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/utils/startPuppe.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ async function getBrowser(demo) {
headless: false,
devTools: true,
defaultViewport: null, // Defaults to an 800x600 viewport. null disables the default viewport.
slowMo: 80 // Slows down Puppeteer operations by the specified amount of milliseconds.
slowMo: 80, // Slows down Puppeteer operations by the specified amount of milliseconds.
};
Object.assign(options, visibleOptions);
}
else {
const woSandbox = {
defaultViewport: null,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
Expand Down Expand Up @@ -82,11 +83,9 @@ function listenToEvents(page) {
async function getPage(browser) {
const page = await browser.newPage();
page.setCacheEnabled(false);
// NOTE: activate to see what happens in puppeteer evaluate function
// page.on('console', consoleObj => console.log(consoleObj.text()));
await page.setViewport({
width: 1920,
height: 1080
width: 1680,
height: 950
Comment on lines +87 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was too big for my laptop screen to check it in demo mode

});
listenToEvents(page);
return page;
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,14 @@ async function takeScreenshot(page, captureName = "") {
filename = filename.split(":").join("-")
filename = filename + ".jpg";
const path = pathLib.join(__dirname, SCREENSHOTS_DIR, filename);
console.log(path);

try {
await page.screenshot({
fullPage: true,
path: path,
type: 'jpeg',
quality: 15
})
console.log('screenshot taken', path);
}
catch (err) {
console.error("Error taking screenshot", err);
Expand Down