Commit 70430b99 authored by Eugene But's avatar Eugene But Committed by Commit Bot

[ios] Speculative fix for DownloadManagerTestCase flakiness

DownloadManagerTestCase is flaky on the bots with slow CPU but works
fine on the bot with fast CPU. So it is possible that flakiness is
related to test server performance.

Before this CL test server would produce a 50KB download file by yielding
blocks of 1 byte size. This CL updates the server to yield 1KB blocks
to improve performance, and introduces 100ms delay between yielding each
block to keep the download realistically slow.

Bug: 1066150, 914113
Change-Id: Ib3a35eb1e849e82dd47cda45b68261634813114e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2130817
Commit-Queue: Eugene But <eugenebut@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755403}
parent f6af9e1f
......@@ -50,7 +50,9 @@ class DownloadResponse : public net::test_server::BasicHttpResponse {
}
private:
// Sends "0" |count| times.
// Sends "0" |count| times using 1KB blocks. Using blocks with smaller size is
// performance inefficient and can cause unnecessary delays especially when
// multiple tests run in parallel on a single machine.
static void Send(const net::test_server::SendBytesCallback& send,
net::test_server::SendCompleteCallback done,
int count) {
......@@ -59,10 +61,13 @@ class DownloadResponse : public net::test_server::BasicHttpResponse {
return;
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(send, "0",
base::BindOnce(&DownloadResponse::Send, send,
std::move(done), count - 1)));
const int block_size = std::min(count, 1000);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(send, std::string(block_size, 0),
base::BindOnce(&DownloadResponse::Send, send,
std::move(done), count - block_size)),
base::TimeDelta::FromMilliseconds(100));
}
int length_ = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment