Commit 915a3e2f authored by Gustav Sennton's avatar Gustav Sennton Committed by Commit Bot

[Minidump uploader] fix flaky test in MinidumpUploaderImplTest

Fix MinidumpUploaderImplTest#testCancelFailedUploadCausesReschedule by
waiting for the minidump uploads worker thread to finish before ending
the testCancelFailedUploadCausesReschedule test.

BUG=786310

Change-Id: I2cd1cde84faf2f44bd69018ed17bbecaa09d6fb8
Reviewed-on: https://chromium-review.googlesource.com/840682Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Gustav Sennton <gsennton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525982}
parent 9c0e4f94
...@@ -11,6 +11,7 @@ import org.junit.Rule; ...@@ -11,6 +11,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.components.minidump_uploader.CrashTestRule.MockCrashReportingPermissionManager; import org.chromium.components.minidump_uploader.CrashTestRule.MockCrashReportingPermissionManager;
import org.chromium.components.minidump_uploader.util.CrashReportingPermissionManager; import org.chromium.components.minidump_uploader.util.CrashReportingPermissionManager;
...@@ -251,6 +252,16 @@ public class MinidumpUploaderImplTest { ...@@ -251,6 +252,16 @@ public class MinidumpUploaderImplTest {
// Ensure we tell JobScheduler to reschedule the job. // Ensure we tell JobScheduler to reschedule the job.
Assert.assertTrue(minidumpUploader.cancelUploads()); Assert.assertTrue(minidumpUploader.cancelUploads());
stopStallingLatch.countDown(); stopStallingLatch.countDown();
// Wait for the MinidumpUploader worker thread to finish before ending the test. This is to
// ensure the worker thread doesn't continue running after the test finishes - trying to
// access directories or minidumps set up and deleted by the test framework.
ThreadUtils.runOnUiThreadBlocking(() -> {
try {
minidumpUploader.joinWorkerThreadForTesting();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
} }
private interface MinidumpUploadCallableCreator { private interface MinidumpUploadCallableCreator {
......
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