Commit a0fb7719 authored by Xi Han's avatar Xi Han Committed by Commit Bot

Fix...

Fix ServicificationBackgroundServiceTest::testHistogramsPersistedWithServiceManagerOnlyStart fails on official bot.

The test fails on the official bot due to the active field trial group size is
0. In this CL, we force a field trial "Foo/Bar" in the test. Thus, it guarantees
at least there is one active field trial.

Bug: 965482
Change-Id: Icdd84dd2e4ff22a17da3d7a7c9dd048529ac9ae0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1752245Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarTommy Nyquist <nyquist@chromium.org>
Commit-Queue: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686456}
parent 7bfcef30
......@@ -19,6 +19,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.init.ServiceManagerStartupUtils;
......@@ -118,6 +119,7 @@ public final class ServicificationBackgroundServiceTest {
@Test
@LargeTest
@Feature({"ServicificationStartup"})
@CommandLineFlags.Add("force-fieldtrials=*Foo/Bar")
public void testHistogramsPersistedWithServiceManagerOnlyStart() {
createBrowserMetricsSpareFile();
Assert.assertTrue(mSpareFile.exists());
......
......@@ -52,36 +52,58 @@ JNI_ServicificationBackgroundService_TestPersistentHistogramsOnDiskSystemProfile
std::move(mapped), 0, 0, base::StringPiece(), /* read_only */ true);
if (memory_allocator->GetMemoryState() ==
base::PersistentMemoryAllocator::MEMORY_DELETED) {
LOG(ERROR) << "The memory allocator state shouldn't be MEMORY_DELETED!";
return false;
}
if (memory_allocator->IsCorrupt())
if (memory_allocator->IsCorrupt()) {
LOG(ERROR) << "The memory allocator is corrupt!";
return false;
}
if (!metrics::PersistentSystemProfile::HasSystemProfile(*memory_allocator))
if (!metrics::PersistentSystemProfile::HasSystemProfile(*memory_allocator)) {
LOG(ERROR) << "There isn't a System Profile!";
return false;
}
metrics::SystemProfileProto system_profile_proto;
if (!metrics::PersistentSystemProfile::GetSystemProfile(
*memory_allocator, &system_profile_proto))
*memory_allocator, &system_profile_proto)) {
LOG(ERROR) << "Failed to get the System Profile!";
return false;
}
if (!system_profile_proto.has_os())
if (!system_profile_proto.has_os()) {
LOG(ERROR) << "The os info isn't set!";
return false;
}
const metrics::SystemProfileProto_OS& os = system_profile_proto.os();
if (!os.has_version())
if (!os.has_version()) {
LOG(ERROR) << "The os version isn't set!";
return false;
}
if (base::SysInfo::OperatingSystemVersion().compare(os.version()) != 0)
if (base::SysInfo::OperatingSystemVersion().compare(os.version()) != 0) {
LOG(ERROR) << "The os version doesn't match!";
return false;
}
std::vector<variations::ActiveGroupId> field_trial_ids;
variations::GetFieldTrialActiveGroupIds("", &field_trial_ids);
int expected_size = static_cast<int>(field_trial_ids.size());
int expeceted_size = static_cast<int>(field_trial_ids.size());
// The active field trial "PersistentHistograms" is guaranteed in the list.
if (expeceted_size <= 0)
// The active field trial "Foo" is guaranteed in the list.
if (expected_size <= 0) {
LOG(ERROR) << "Expect at least one active field trial!";
return false;
}
if (system_profile_proto.field_trial_size() != expected_size) {
LOG(ERROR) << "The size of field trials recorded in the System Profile"
<< " doesn't match the size of active field trials!";
return false;
}
return system_profile_proto.field_trial_size() == expeceted_size;
return true;
}
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