Files
Andrei Solntsev c5bb3c9752 16612 download large files (#16627)
* #16612 support downloading large files from Grid

I added a new Grid endpoint "/se/files/:name" which allows downloading the file directly, without encoding it to Base64 and adding to Json. This transformation kills the performance and causes OutOfMemory errors for large files (e.g. 256+ MB).

NB! Be sure that `toString()` method of objects (HttpRequest, HttpResponse, Contents.Supplier) never returns too long string - it spam debug logs and can cause OOM during debugging.

* #16612 extract anonymous implementations of `Contents.Supplier` to separate classes

It makes debugging easier. You can easily see what instances they are and where they come from.

* #16612 optimize method `RemoteWebDriver.downloadFile()`

Instead of reading the whole file to a byte array, just save given InputStream directly to the file.

Now it can download large files (I tried 4GB) while consuming very low memory.

* #16612 just in case, return `Contents.fromStream` only when downloading files.

For json responses, still return `Contents.bytes` which allows re-reading its content multiple times. Just in case.

* #16612 fix flaky test: wait until the downloads folder gets deleted

After stopping a Grid node, the folder is deleted asynchronously (by cache removal listener). So we need to wait for it in test.

* #16612 fix flaky test: wait until the grid node is fully stopped

At least on my machine, stopping the node takes some time, and any checks right after `node.stop(sessionId)` often can fail.

* #16612 fix flaky test LocalNewSessionQueueTest

Gr... This is extremely hard to debug test.

After hours of debugging, I came to a conclusion that we just need to increase the timeout. On my machine, `latch` gets decreased after ~1.2 seconds. So 1 second was not enough.

* #16612 fix flaky test JdkHttpClientTest

I don't know why, but sometimes we receive `HttpTimeoutException` instead of `InterruptedException`. Seems reasonable to consider execution as interrupted in both cases. (?)

* #16612 remove unneeded code

None of `is.readNBytes` implementations returns -1. It always returns 0 or positive number.

* #16612 upload logs in case of test failure

* ignore few more IDEA files

* #16612 slightly improve logging in `W3CHttpResponseCodec.decode`

Don't log the entire response body - just content type and length.
2025-11-28 09:55:04 +01:00
..
2025-11-28 09:55:04 +01:00
2025-05-12 12:32:49 -07:00
2024-03-22 15:47:45 +01:00
2025-07-03 12:40:01 +02:00