-
Notifications
You must be signed in to change notification settings - Fork 4
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
Faster downloads #798
Faster downloads #798
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speeding this up will be a huge win. I think we may need to check on some stuff first as this may be a bit more complex than it would first appear, but maybe I'm off - I feel like I'm missing some of this picture. Anyway, some notes here and some in the review comments. At least some of them are relevant.
Numbered for easier referencing:
- Do we really need to update shrinkwrap?
- Added some comments about adding messages to let the author know what's going on.
- Should we add something in the report when the download has succeeded? Before we didn't know if it had succeeded, but now we should.
- I think this would be especially good to add to the changelog as an internal change.
- Does this change handle the timeout running out? Previously, we'd go till the timeout and just continue the tests regardless of what happened (since we couldn't tell what happened). If the files didn't download, there wasn't anything to do about it. Now, though, we may need to handle the timeout if our await goes too long. Not sure if we'd want to error or warn at that point. We may want to add a test for whatever behavior we choose - make a huge image file or something to download.
- When comparing downloads, did we make a provision for if/when the download doesn't exist (since it may not complete in time)?
I'll go check when I have a mo.It looks like we didn't, so we might need to take care of that in another PR fairly soon.
That happens when I run
👍 (I've been waiting for changelog stuff when I put out multiple PRs b/c I don't know which will go out first)
Good points. IMO I'd rather error, since if we tried to download something and didn't download it, something's likely wrong with the server (testing might be hard; even really big stuff will download quickly on the same machine).
This will exist though? It completes in this step (unless there's a timeout, and I that case I think we should error, as mentioned above). |
I think we could start using Another option is to use I wonder if item 4 here indicates that what happened to your shrinkwrap is a bug and may be worth reporting.
Sounds good to me 👍
Yeah, we probably won't be able to write tests that will consistently pass (by failing) until we do some research about implementing throttling.
Good point. I can still see a situation where someone would forget to include a download step before comparing. We might handle that in a different issue, though. |
Not sure if you saw that note about a success message, so just repeating that here. |
I've been a bit lenient about shrinkwrap changes. I'll avoid them more in the future (though this time it's because the version in |
It occurred to me that we can decrease the max timeout for the Step to a fraction of a second and thus trigger a timeout. Would that work for our purposes? It's only one type of error, but that may still be worth testing. |
Good point, I can try that! IMO, we can try to manually and see how it does. I don't think we need to add it to the test suite though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good to me! I think once you feel comfortable with it, we can send it out into the wild!
I did this, and got the following printout in the cucumber report:
The PDF file did actually download fine, because I guess the download had enough time to start. The conflicting states isn't great, but I'm assuming that the presence of a clear "Action did not complete within " message is good enough for people. I tried uploading a larger PDF to do this with, but ran into issues (DA doesn't like too big of files, and it doesn't like PDFs without fields, all of the big PDFs I have don't have fields and it'd be difficult to add them to it). I'll add to the changelog now and merge! |
The existing `content-disposition` doesn't work because there are no content disposition headers. From https://thom4.net/2018/puppeteer-download-file/
* revert shrinkwrap changes * get back more detailed error info from browser download * write both success and failure to download with new method to report
Co-authored-by: plocket <52798256+plocket@users.noreply.github.com>
Co-authored-by: plocket <52798256+plocket@users.noreply.github.com>
06f2bd3
to
35788ad
Compare
Speeds up the downloads by directly downloading the file instead of trying to rely on
response
callbacks, which almost always timeout.I made things a bit resilient; I think things work fine without all of the
failed_to_download
stuff (see https://github.com/SuffolkLITLab/ALKiln/actions/runs/6556325525/job/17806135932, an earlier test run without that code), but figured I'd keep the existing code in, in case there are situations we couldn't foresee. Happy to rip out the old code if we want to though.I tried a lot of different options, none of them seemed to work particularly well:
https.get
doesn't work with http://localhost (might be a me problem, but IMO, it's frustrating), the workaround is hacky and uses bothhttps.get
andhttp.get
.File Not Found
. I think it's because DA by default checks the cookies / logged in status of who's downloading a file (that's why you need to useurl_for(private=False)
). So in general, trying to access the file from outside of the browser session is going to be tricky, if not impossible.In this PR, I have:
Links to any solved or related issues
#492
Any manual testing I have done to ensure my PR is working
Running a test that downloads a PDF (
@o17
) runs in 3.4 seconds now, as opposed to 33 seconds onv5
.