Commit 52b823c8 authored by Yi Xie's avatar Yi Xie Committed by Chromium LUCI CQ

arc: Add a flag to reduce app install log upload delay

Currently there is a delay of 15 min - 3 hr, which is way too long for
integration test. By adding this flag we can write Tast test to check if
log upload is working properly.

BUG=b:174803045
TEST=None. Will be tested by a Tast test later.

Change-Id: I65447c51519d9758ee17472432d9775e5505a835
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2573896
Commit-Queue: Yi Xie <yixie@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833975}
parent 099da60e
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/check_op.h" #include "base/check_op.h"
#include "base/command_line.h"
#include "base/location.h" #include "base/location.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chromeos/constants/chromeos_switches.h"
namespace policy { namespace policy {
...@@ -24,6 +26,8 @@ namespace { ...@@ -24,6 +26,8 @@ namespace {
// Delay after which a change to the log contents is stored to disk. Further // Delay after which a change to the log contents is stored to disk. Further
// changes during this time window are picked up by the same store operation. // changes during this time window are picked up by the same store operation.
constexpr base::TimeDelta kStoreDelay = base::TimeDelta::FromSeconds(5); constexpr base::TimeDelta kStoreDelay = base::TimeDelta::FromSeconds(5);
// Reduce store delay for integration tests.
constexpr base::TimeDelta kFastStoreDelay = base::TimeDelta::FromSeconds(1);
// Interval between subsequent uploads to the server, if the log is not empty. // Interval between subsequent uploads to the server, if the log is not empty.
constexpr base::TimeDelta kUploadInterval = base::TimeDelta::FromHours(3); constexpr base::TimeDelta kUploadInterval = base::TimeDelta::FromHours(3);
...@@ -33,12 +37,22 @@ constexpr base::TimeDelta kUploadInterval = base::TimeDelta::FromHours(3); ...@@ -33,12 +37,22 @@ constexpr base::TimeDelta kUploadInterval = base::TimeDelta::FromHours(3);
// getting full. // getting full.
constexpr base::TimeDelta kExpeditedUploadDelay = constexpr base::TimeDelta kExpeditedUploadDelay =
base::TimeDelta::FromMinutes(15); base::TimeDelta::FromMinutes(15);
// Reduce upload delay for integration tests.
constexpr base::TimeDelta kFastUploadDelay = base::TimeDelta::FromSeconds(30);
// An expedited upload is scheduled whenever the total number of log entries // An expedited upload is scheduled whenever the total number of log entries
// exceeds |kTotalSizeExpeditedUploadThreshold| or the number of log entries for // exceeds |kTotalSizeExpeditedUploadThreshold| or the number of log entries for
// any single app exceeds |kMaxSizeExpeditedUploadThreshold|. // any single app exceeds |kMaxSizeExpeditedUploadThreshold|.
constexpr int kTotalSizeExpeditedUploadThreshold = 2048; constexpr int kTotalSizeExpeditedUploadThreshold = 2048;
constexpr int kMaxSizeExpeditedUploadThreshold = 512; constexpr int kMaxSizeExpeditedUploadThreshold = 512;
// If install-log-fast-upload-for-tests flag is enabled, upload logs with
// reduced delay.
bool FastUploadForTestsEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kInstallLogFastUploadForTests);
}
} // namespace } // namespace
InstallEventLogManagerBase::LogTaskRunnerWrapper::LogTaskRunnerWrapper() = InstallEventLogManagerBase::LogTaskRunnerWrapper::LogTaskRunnerWrapper() =
...@@ -91,7 +105,7 @@ void InstallEventLogManagerBase::LogUpload::OnLogChange( ...@@ -91,7 +105,7 @@ void InstallEventLogManagerBase::LogUpload::OnLogChange(
FROM_HERE, FROM_HERE,
base::BindOnce(&InstallEventLogManagerBase::LogUpload::StoreLog, base::BindOnce(&InstallEventLogManagerBase::LogUpload::StoreLog,
store_weak_factory_.GetWeakPtr()), store_weak_factory_.GetWeakPtr()),
kStoreDelay); FastUploadForTestsEnabled() ? kFastStoreDelay : kStoreDelay);
} }
EnsureUpload(log_size.total_size > kTotalSizeExpeditedUploadThreshold || EnsureUpload(log_size.total_size > kTotalSizeExpeditedUploadThreshold ||
...@@ -110,11 +124,16 @@ void InstallEventLogManagerBase::LogUpload::EnsureUpload(bool expedited) { ...@@ -110,11 +124,16 @@ void InstallEventLogManagerBase::LogUpload::EnsureUpload(bool expedited) {
upload_scheduled_ = true; upload_scheduled_ = true;
expedited_upload_scheduled_ = expedited; expedited_upload_scheduled_ = expedited;
base::TimeDelta upload_delay =
expedited ? kExpeditedUploadDelay : kUploadInterval;
if (FastUploadForTestsEnabled())
upload_delay = kFastUploadDelay;
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask( base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&InstallEventLogManagerBase::LogUpload::RequestUpload, base::BindOnce(&InstallEventLogManagerBase::LogUpload::RequestUpload,
upload_weak_factory_.GetWeakPtr()), upload_weak_factory_.GetWeakPtr()),
expedited ? kExpeditedUploadDelay : kUploadInterval); upload_delay);
} }
void InstallEventLogManagerBase::LogUpload::RequestUpload() { void InstallEventLogManagerBase::LogUpload::RequestUpload() {
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
#include <algorithm> #include <algorithm>
#include "base/command_line.h"
#include "chromeos/constants/chromeos_switches.h"
namespace policy { namespace policy {
namespace { namespace {
...@@ -17,6 +20,13 @@ namespace { ...@@ -17,6 +20,13 @@ namespace {
const int kMinRetryBackoffMs = 10 * 1000; // 10 seconds const int kMinRetryBackoffMs = 10 * 1000; // 10 seconds
const int kMaxRetryBackoffMs = 24 * 60 * 60 * 1000; // 24 hours const int kMaxRetryBackoffMs = 24 * 60 * 60 * 1000; // 24 hours
// If install-log-fast-upload-for-tests flag is enabled, do not increase retry
// backoff.
bool FastUploadForTestsEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kInstallLogFastUploadForTests);
}
} // namespace } // namespace
InstallEventLogUploaderBase::InstallEventLogUploaderBase( InstallEventLogUploaderBase::InstallEventLogUploaderBase(
...@@ -81,6 +91,8 @@ void InstallEventLogUploaderBase::OnUploadDone(bool success) { ...@@ -81,6 +91,8 @@ void InstallEventLogUploaderBase::OnUploadDone(bool success) {
return; return;
} }
PostTaskForStartSerialization(); PostTaskForStartSerialization();
if (FastUploadForTestsEnabled())
return;
retry_backoff_ms_ = std::min(retry_backoff_ms_ << 1, kMaxRetryBackoffMs); retry_backoff_ms_ = std::min(retry_backoff_ms_ << 1, kMaxRetryBackoffMs);
} }
......
...@@ -418,6 +418,10 @@ const char kIgnoreArcVmDevConf[] = "ignore-arcvm-dev-conf"; ...@@ -418,6 +418,10 @@ const char kIgnoreArcVmDevConf[] = "ignore-arcvm-dev-conf";
const char kIgnoreUserProfileMappingForTests[] = const char kIgnoreUserProfileMappingForTests[] =
"ignore-user-profile-mapping-for-tests"; "ignore-user-profile-mapping-for-tests";
// Decreases delay in uploading installation event logs for integration test.
const char kInstallLogFastUploadForTests[] =
"install-log-fast-upload-for-tests";
// If set, the Chrome settings will not expose the option to enable crostini // If set, the Chrome settings will not expose the option to enable crostini
// unless the enable-experimental-kernel-vm-support flag is set in // unless the enable-experimental-kernel-vm-support flag is set in
// chrome://flags // chrome://flags
......
...@@ -168,6 +168,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kHomedir[]; ...@@ -168,6 +168,8 @@ COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kHomedir[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kIgnoreArcVmDevConf[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kIgnoreArcVmDevConf[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kIgnoreUserProfileMappingForTests[]; extern const char kIgnoreUserProfileMappingForTests[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kInstallLogFastUploadForTests[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kKernelnextRestrictVMs[]; COMPONENT_EXPORT(CHROMEOS_CONSTANTS) extern const char kKernelnextRestrictVMs[];
COMPONENT_EXPORT(CHROMEOS_CONSTANTS) COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kLacrosChromeAdditionalArgs[]; extern const char kLacrosChromeAdditionalArgs[];
......
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