Commit 6b3c3961 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Fix an flaky test for parallel download

This CL fixes an issue in DownloadFileWithError that
when injecting an error on a write offset, we should check if
the offset is overwritten by a write operation, rather than just
the beginning offset.
And then we use this fix to fix the flaky MiddleSliceDelayedError
as the same offset will be overwritten twice by 2 streams.

BUG=1105429, 1106059

Change-Id: Iff9b9d796ed5d86c68b24667096e2089564c4c0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401312Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805605}
parent e1c533b7
...@@ -4311,23 +4311,14 @@ IN_PROC_BROWSER_TEST_F(ParallelDownloadTest, ...@@ -4311,23 +4311,14 @@ IN_PROC_BROWSER_TEST_F(ParallelDownloadTest,
parameters); parameters);
} }
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
defined(OS_ANDROID)
// Flaky https://crbug.com/1105429, https://crbug.com/1106059.
// Windows probably use a large receiving buffer size and cause the first slice
// to start at a offset > 0.
#define MAYBE_MiddleSliceDelayedError DISABLED_MiddleSliceDelayedError
#else
#define MAYBE_MiddleSliceDelayedError MiddleSliceDelayedError
#endif
// Verify that if the second request fails after the beginning request takes // Verify that if the second request fails after the beginning request takes
// over and completes its slice, download should complete. // over and completes its slice, download should complete.
IN_PROC_BROWSER_TEST_F(ParallelDownloadTest, MAYBE_MiddleSliceDelayedError) { IN_PROC_BROWSER_TEST_F(ParallelDownloadTest, MiddleSliceDelayedError) {
scoped_refptr<TestFileErrorInjector> injector( scoped_refptr<TestFileErrorInjector> injector(
TestFileErrorInjector::Create(DownloadManagerForShell(shell()))); TestFileErrorInjector::Create(DownloadManagerForShell(shell())));
TestFileErrorInjector::FileErrorInfo err = { TestFileErrorInjector::FileErrorInfo err = {
TestFileErrorInjector::FILE_OPERATION_WRITE, 0, TestFileErrorInjector::FILE_OPERATION_WRITE, 1,
download::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE}; download::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE};
err.data_write_offset = 1699050; err.data_write_offset = 1699050;
injector->InjectError(err); injector->InjectError(err);
......
...@@ -186,7 +186,9 @@ DownloadFileWithError::ValidateAndWriteDataToFile(int64_t offset, ...@@ -186,7 +186,9 @@ DownloadFileWithError::ValidateAndWriteDataToFile(int64_t offset,
download::DownloadFileImpl::ValidateAndWriteDataToFile( download::DownloadFileImpl::ValidateAndWriteDataToFile(
offset, data, bytes_to_validate, bytes_to_write); offset, data, bytes_to_validate, bytes_to_write);
if (error_info_.data_write_offset == -1 || if (error_info_.data_write_offset == -1 ||
offset == error_info_.data_write_offset) { ((offset <= error_info_.data_write_offset) &&
(offset + bytes_to_write >=
static_cast<size_t>(error_info_.data_write_offset)))) {
return ShouldReturnError(TestFileErrorInjector::FILE_OPERATION_WRITE, return ShouldReturnError(TestFileErrorInjector::FILE_OPERATION_WRITE,
origin_error); origin_error);
} }
......
...@@ -67,7 +67,7 @@ class TestFileErrorInjector ...@@ -67,7 +67,7 @@ class TestFileErrorInjector
download::DownloadInterruptReason error; // Error to inject. download::DownloadInterruptReason error; // Error to inject.
int64_t stream_offset = -1; // Offset of the error stream. int64_t stream_offset = -1; // Offset of the error stream.
int64_t stream_bytes_written = -1; // Bytes written to the error stream. int64_t stream_bytes_written = -1; // Bytes written to the error stream.
// If > 0, only write calls to this offset will generate errors. // If > 0, only write operations covering this offset will generate errors.
// Otherwise, all file writes will generate errors. // Otherwise, all file writes will generate errors.
int64_t data_write_offset = -1; int64_t data_write_offset = -1;
}; };
......
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