Skip to content

Conversation

calbach
Copy link
Contributor

@calbach calbach commented Apr 5, 2022

Previous test would occasionally fail when uploading to this speedtest site, this is a flaky external dependency. Instead, we now create a six 30MB dummy files and download them in serial.

Also: update prompt handling logic within notebooks to cleanup its own handlers

@calbach calbach requested a review from aweng98 April 5, 2022 22:27
Copy link
Contributor

@aweng98 aweng98 left a comment

Choose a reason for hiding this comment

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

LGTM! I have few minor and non-blocking comments. Also, do we want to clean up notebook/runtime/workspace at the end of test?

.then((e) => e.click());
await findAndClickCheckbox();

const handleDialog = (d) => this.acceptDataUseDownloadDialog(treePage, d);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: since acceptDataUseDownloadDialog is an async func, I believe this func need to be async like const handleDialog = asyc (d) => await this.acceptDataUseDownloadDialog(treePage, d);?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You need the async keyword if you want to use await in your function, that's it. In this case, there is no need to use the await keyword, therefore we don't need it to be an async function. What you've written is functionally equivalent to what I wrote, but with extra steps.

It will be difficult to explain this in a comment - lets stay on and talk through it after eng sync, if you want.

await findAndClickCheckbox();

const handleDialog = (d) => this.acceptDataUseDownloadDialog(treePage, d);
treePage.on('dialog', handleDialog);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: treePage.once is a good alternative to treePage.on and treePage.off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good find, thanks - I hadn't seen once. That said, on/off is slightly more hermetic. There is no guarantee that your handler actually gets called within the scope of this method, e.g. if the alert stopped showing up in certain cases, or there was a product change that removed it. If that were to occur, with once you would be leaking a dialog listener into unrelated sections of the test.

once/off may be an improvement here. I'm also thinking the off should be further down.. I'm slightly concerned now about a race condition between the dialog showing up, and the off call.

Another alternative would be once + assert that your listener was invoked. That could be the best option if what we're trying to do here is actually test the modal behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏻 I like once + assert too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to this, and it exposed the fact that indeed we're not always getting the modal on upload/download. I suspect this is a race condition between clicking upload, and when the Jupyter extension (which adds the modal) is installed. I added another unfortunate sleep here to cover this situation.

Open to other suggestions. I also filed https://precisionmedicineinitiative.atlassian.net/browse/RW-8144 which will give generic support for page.waitForNetworkIdle(), which is something I wanted to try here.

{ visible: true }
)
.then((e) => e.click());
await findAndClickCheckbox();
Copy link
Contributor

Choose a reason for hiding this comment

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

I ran this test locally several times. 1 time it had failed. Unfortunately, after e.click((), it needs a short sleep for improved event synchronization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for testing this out locally. Do you still have the test logs from when you saw this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, are you sure it was this line and not L143? I see a pretty clear potential race condition there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not anymore. It was overwritten after I made few local changes. I thought it could happen again if I rerun again. But failure only happened once.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, it was at line 143: after click Download button. my comment was at the wrong line.


// Upload button that triggers file selection dialog.
const handleDialog = (d) => this.acceptDataUseUploadDialog(newPage, d);
newPage.on('dialog', handleDialog);
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Use newPage.once.

@calbach
Copy link
Contributor Author

calbach commented Apr 7, 2022

RE cleanup runtime: there might be complications doing this since the user will be security suspended at that point in the test. For now I'd like to avoid adding more points of failure and just let the cron handle these.

@calbach calbach merged commit 8a2ca41 into main Apr 7, 2022
@calbach calbach deleted the ch/egress-nightly-fix branch April 7, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants