Commit 72367a88 authored by Salvador Guerrero's avatar Salvador Guerrero Committed by Chromium LUCI CQ

Removed per database params in leveldb_proto experiment

This CL removes the option of setting up migrations for each database
individually, now if the migration experiment is on all databases will
be migrated (except by those in a blocklist).

This makes it simpler to launch the experiment to stable, as we will no
longer need to specify each database name on the experiment params.

Bug: 870813
Change-Id: I00259f5ceeae14790a40546d9fab064eac1aea29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630734Reviewed-by: default avatarssid <ssid@chromium.org>
Commit-Queue: Salvador Guerrero <salg@google.com>
Cr-Commit-Position: refs/heads/master@{#843846}
parent bca5f7be
...@@ -12,21 +12,12 @@ ...@@ -12,21 +12,12 @@
namespace leveldb_proto { namespace leveldb_proto {
namespace {
const char kTestClientName[] = "TestDatabase1";
}
class SharedProtoDatabaseClientListTest : public testing::Test { class SharedProtoDatabaseClientListTest : public testing::Test {
public: public:
void SetUpExperimentParam(std::string key, std::string value) { void SetUpExperiment(bool isExperimentOn) {
std::map<std::string, std::string> params = { scoped_feature_list_.InitWithFeatureState(kProtoDBSharedMigration,
{"migrate_TestDatabase0", "true"}, isExperimentOn);
{"migrate_" + key, value},
{"migrate_TestDatabase2", "false"},
};
scoped_feature_list_.InitAndEnableFeatureWithParameters(
kProtoDBSharedMigration, params);
} }
private: private:
...@@ -34,8 +25,8 @@ class SharedProtoDatabaseClientListTest : public testing::Test { ...@@ -34,8 +25,8 @@ class SharedProtoDatabaseClientListTest : public testing::Test {
}; };
TEST_F(SharedProtoDatabaseClientListTest, ShouldUseSharedDBTest) { TEST_F(SharedProtoDatabaseClientListTest, ShouldUseSharedDBTest) {
// Parameter value is case sensitive // Set experiment to use Shared DB.
SetUpExperimentParam(kTestClientName, "true"); SetUpExperiment(true);
bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB( bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB(
ProtoDbType::TEST_DATABASE1); ProtoDbType::TEST_DATABASE1);
...@@ -44,8 +35,9 @@ TEST_F(SharedProtoDatabaseClientListTest, ShouldUseSharedDBTest) { ...@@ -44,8 +35,9 @@ TEST_F(SharedProtoDatabaseClientListTest, ShouldUseSharedDBTest) {
} }
TEST_F(SharedProtoDatabaseClientListTest, TEST_F(SharedProtoDatabaseClientListTest,
ShouldUseSharedDBTest_OnlyWhenParamMatchesName) { ShouldUseSharedDBTest_OnlyWhenExperimentIsOn) {
SetUpExperimentParam("TestDatabase10", "true"); // Set experiment to use Unique DB.
SetUpExperiment(false);
bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB( bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB(
ProtoDbType::TEST_DATABASE1); ProtoDbType::TEST_DATABASE1);
...@@ -54,11 +46,13 @@ TEST_F(SharedProtoDatabaseClientListTest, ...@@ -54,11 +46,13 @@ TEST_F(SharedProtoDatabaseClientListTest,
} }
TEST_F(SharedProtoDatabaseClientListTest, TEST_F(SharedProtoDatabaseClientListTest,
ShouldUseSharedDBTest_OnlyWhenParamValueIsTrue) { ShouldUseSharedDBTest_ExceptIfDbIsBlocklisted) {
SetUpExperimentParam(kTestClientName, "false"); SetUpExperiment(true);
// GCM_KEY_STORE is blocklisted, it won't use a shared DB, regardless of
// experiment state.
bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB( bool use_shared = SharedProtoDatabaseClientList::ShouldUseSharedDB(
ProtoDbType::TEST_DATABASE1); ProtoDbType::GCM_KEY_STORE);
ASSERT_FALSE(use_shared); ASSERT_FALSE(use_shared);
} }
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
namespace leveldb_proto { namespace leveldb_proto {
namespace {
const char* const kDBNameParamPrefix = "migrate_";
} // namespace
// static // static
std::string SharedProtoDatabaseClientList::ProtoDbTypeToString( std::string SharedProtoDatabaseClientList::ProtoDbTypeToString(
...@@ -100,18 +97,15 @@ std::string SharedProtoDatabaseClientList::ProtoDbTypeToString( ...@@ -100,18 +97,15 @@ std::string SharedProtoDatabaseClientList::ProtoDbTypeToString(
// static // static
bool SharedProtoDatabaseClientList::ShouldUseSharedDB(ProtoDbType db_type) { bool SharedProtoDatabaseClientList::ShouldUseSharedDB(ProtoDbType db_type) {
for (size_t i = 0; kWhitelistedDbForSharedImpl[i] != ProtoDbType::LAST; ++i) { for (size_t i = 0; kBlocklistedDbForSharedImpl[i] != ProtoDbType::LAST; ++i) {
if (kWhitelistedDbForSharedImpl[i] == db_type) if (kBlocklistedDbForSharedImpl[i] == db_type)
return true; return false;
} }
if (!base::FeatureList::IsEnabled(kProtoDBSharedMigration)) if (!base::FeatureList::IsEnabled(kProtoDBSharedMigration))
return false; return false;
std::string name = return true;
SharedProtoDatabaseClientList::ProtoDbTypeToString(db_type);
return base::GetFieldTrialParamByFeatureAsBool(
kProtoDBSharedMigration, kDBNameParamPrefix + name, false);
} }
} // namespace leveldb_proto } // namespace leveldb_proto
...@@ -59,21 +59,15 @@ enum class ProtoDbType { ...@@ -59,21 +59,15 @@ enum class ProtoDbType {
LAST, LAST,
}; };
// List of databases that were introduced after shared db implementation was // List of databases that need to keep using unique db instances. New databases
// created. These will be forced to use shared database implementation. // shouldn't be here unless they have a good reason.
constexpr ProtoDbType kWhitelistedDbForSharedImpl[]{ constexpr ProtoDbType kBlocklistedDbForSharedImpl[]{
ProtoDbType::NOTIFICATION_SCHEDULER_ICON_STORE, // DB is not tied to a profile, will always be unique.
ProtoDbType::NOTIFICATION_SCHEDULER_IMPRESSION_STORE, ProtoDbType::GCM_KEY_STORE,
ProtoDbType::NOTIFICATION_SCHEDULER_NOTIFICATION_STORE, // DB Used by shared database, will always be unique.
ProtoDbType::PRINT_JOB_DATABASE, ProtoDbType::SHARED_DB_METADATA,
ProtoDbType::FEED_STREAM_DATABASE, // Marks the end of list.
ProtoDbType::PERSISTED_STATE_DATABASE, ProtoDbType::LAST,
ProtoDbType::UPBOARDING_QUERY_TILE_STORE,
ProtoDbType::NEARBY_SHARE_PUBLIC_CERTIFICATE_DATABASE,
ProtoDbType::VIDEO_TUTORIALS_DATABASE,
ProtoDbType::FEED_KEY_VALUE_DATABASE,
ProtoDbType::CART_DATABASE,
ProtoDbType::LAST, // Marks the end of list.
}; };
// Add any obsolete databases in this list so that, if the data is no longer // Add any obsolete databases in this list so that, if the data is no longer
......
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