From 1115e29faf1d9a1ed49c3e5744d59675c5d58410 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Thu, 15 Oct 2020 18:32:55 -0700 Subject: [PATCH] adb: fix timeout-related test flakiness. When running tests against cuttlefish, `adb root` sometimes flakes because of a 6 second timeout in wait_for_device, which can get triggered when adbd's restart gets throttled by init. The adb client would notice that the socket went down, try to reconnect and fail because adbd still hasn't started yet, and then wait up to 10 seconds to reconnect, before which the `adb root` invocation would have failed due to timeout. Increase the timeout to be long enough to handle this, and also reduce the interval of reconnections to speed things up when we're in this scenario. Bug: http://b/170707786 Test: while true; do adb root; adb wait-for-device; adb unroot; adb wait-for-device; done Change-Id: I140d721dfcfd635d45813a55990684a25e32228c --- adb/client/commandline.cpp | 2 +- adb/transport.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp index 43772ba45..d9e69f728 100644 --- a/adb/client/commandline.cpp +++ b/adb/client/commandline.cpp @@ -1149,7 +1149,7 @@ static bool adb_root(const char* command) { // If we were using a specific transport ID, there's nothing we can wait for. if (previous_id == 0) { adb_set_transport(previous_type, previous_serial, 0); - wait_for_device("wait-for-device", 6000ms); + wait_for_device("wait-for-device", 12000ms); } return true; diff --git a/adb/transport.cpp b/adb/transport.cpp index c33d5afcb..93b461834 100644 --- a/adb/transport.cpp +++ b/adb/transport.cpp @@ -129,8 +129,8 @@ class ReconnectHandler { }; // Only retry for up to one minute. - static constexpr const std::chrono::seconds kDefaultTimeout = 10s; - static constexpr const size_t kMaxAttempts = 6; + static constexpr const std::chrono::seconds kDefaultTimeout = 3s; + static constexpr const size_t kMaxAttempts = 20; // Protects all members. std::mutex reconnect_mutex_;