Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: chrome/test/live_sync/migration_errors_test.cc

Issue 7655055: [Sync] Make BackendMigrator not wait for full sync cycles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address more comments Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/live_sync/live_sync_test.cc ('k') | chrome/test/sync/engine/test_user_share.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(akalin): Rename this file to migration_test.cc.
6
5 #include "chrome/browser/prefs/scoped_user_pref_update.h" 7 #include "chrome/browser/prefs/scoped_user_pref_update.h"
6 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/sync/profile_sync_service_harness.h" 9 #include "chrome/browser/sync/profile_sync_service_harness.h"
8 #include "chrome/browser/translate/translate_prefs.h" 10 #include "chrome/browser/translate/translate_prefs.h"
9 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
11 #include "chrome/test/live_sync/bookmarks_helper.h" 13 #include "chrome/test/live_sync/bookmarks_helper.h"
12 #include "chrome/test/live_sync/live_sync_test.h" 14 #include "chrome/test/live_sync/live_sync_test.h"
13 #include "chrome/test/live_sync/preferences_helper.h" 15 #include "chrome/test/live_sync/preferences_helper.h"
14 16
15 using bookmarks_helper::AddURL; 17 using bookmarks_helper::AddURL;
16 using bookmarks_helper::IndexedURL; 18 using bookmarks_helper::IndexedURL;
17 using bookmarks_helper::IndexedURLTitle; 19 using bookmarks_helper::IndexedURLTitle;
18 20
19 using preferences_helper::BooleanPrefMatches; 21 using preferences_helper::BooleanPrefMatches;
20 using preferences_helper::ChangeBooleanPref; 22 using preferences_helper::ChangeBooleanPref;
21 23
22 // Tests to make sure that the migration cycle works properly, 24 namespace {
23 // i.e. doesn't stall. 25
24 26 // Utility functions to make a model type set out of a small number of
25 class MigrationCycleTest : public LiveSyncTest { 27 // model types.
28
29 syncable::ModelTypeSet MakeSet(syncable::ModelType type) {
30 syncable::ModelTypeSet model_types;
31 model_types.insert(type);
32 return model_types;
33 }
34
35 syncable::ModelTypeSet MakeSet(syncable::ModelType type1,
36 syncable::ModelType type2) {
37 syncable::ModelTypeSet model_types;
38 model_types.insert(type1);
39 model_types.insert(type2);
40 return model_types;
41 }
42
43 // An ordered list of model types sets to migrate. Used by
44 // RunMigrationTest().
45 typedef std::deque<syncable::ModelTypeSet> MigrationList;
46
47 // Utility functions to make a MigrationList out of a small number of
48 // model types / model type sets.
49
50 MigrationList MakeList(const syncable::ModelTypeSet& model_types) {
51 return MigrationList(1, model_types);
52 }
53
54 MigrationList MakeList(const syncable::ModelTypeSet& model_types1,
55 const syncable::ModelTypeSet& model_types2) {
56 MigrationList migration_list;
57 migration_list.push_back(model_types1);
58 migration_list.push_back(model_types2);
59 return migration_list;
60 }
61
62 MigrationList MakeList(syncable::ModelType type) {
63 return MakeList(MakeSet(type));
64 }
65
66 MigrationList MakeList(syncable::ModelType type1,
67 syncable::ModelType type2) {
68 return MakeList(MakeSet(type1), MakeSet(type2));
69 }
70
71 class MigrationTest : public LiveSyncTest {
26 public: 72 public:
27 MigrationCycleTest() : LiveSyncTest(SINGLE_CLIENT) {} 73 explicit MigrationTest(TestType test_type) : LiveSyncTest(test_type) {}
28 virtual ~MigrationCycleTest() {} 74 virtual ~MigrationTest() {}
75
76 // TODO(akalin): Add more MODIFY_(data type) trigger methods, as
77 // well as a poll-based trigger method.
78 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION };
79
80 syncable::ModelTypeSet GetPreferredDataTypes() {
81 syncable::ModelTypeSet preferred_data_types;
82 GetClient(0)->service()->GetPreferredDataTypes(&preferred_data_types);
83 // Make sure all clients have the same preferred data types.
84 for (int i = 1; i < num_clients(); ++i) {
85 syncable::ModelTypeSet other_preferred_data_types;
86 GetClient(i)->service()->GetPreferredDataTypes(
87 &other_preferred_data_types);
88 EXPECT_EQ(preferred_data_types, other_preferred_data_types);
89 }
90 return preferred_data_types;
91 }
92
93 // Returns a MigrationList with every enabled data type in its own
94 // set.
95 MigrationList GetPreferredDataTypesList() {
96 MigrationList migration_list;
97 const syncable::ModelTypeSet& preferred_data_types =
98 GetPreferredDataTypes();
99 for (syncable::ModelTypeSet::const_iterator it =
100 preferred_data_types.begin();
101 it != preferred_data_types.end(); ++it) {
102 migration_list.push_back(MakeSet(*it));
103 }
104 return migration_list;
105 }
106
107 // Trigger a migration for the given types with the given method.
108 void TriggerMigration(const syncable::ModelTypeSet& model_types,
109 TriggerMethod trigger_method) {
110 switch (trigger_method) {
111 case MODIFY_PREF:
112 // Unlike MODIFY_BOOKMARK, MODIFY_PREF doesn't cause a
113 // notification to happen (since model association on a
114 // boolean pref clobbers the local value), so it doesn't work
115 // for anything but single-client tests.
116 ASSERT_EQ(1, num_clients());
117 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
118 ChangeBooleanPref(0, prefs::kShowHomeButton);
119 break;
120 case MODIFY_BOOKMARK:
121 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))));
122 break;
123 case TRIGGER_NOTIFICATION:
124 TriggerNotification(model_types);
125 break;
126 default:
127 ADD_FAILURE();
128 }
129 }
130
131 // Block until all clients have completed migration for the given
132 // types.
133 void AwaitMigration(const syncable::ModelTypeSet& migrate_types) {
134 for (int i = 0; i < num_clients(); ++i) {
135 ASSERT_TRUE(GetClient(i)->AwaitMigration(migrate_types));
136 }
137 }
138
139 bool ShouldRunMigrationTest() const {
140 if (!ServerSupportsNotificationControl() ||
141 !ServerSupportsErrorTriggering()) {
142 LOG(WARNING) << "Test skipped in this server environment.";
143 return false;
144 }
145 return true;
146 }
147
148 // Makes sure migration works with the given migration list and
149 // trigger method.
150 void RunMigrationTest(const MigrationList& migration_list,
151 TriggerMethod trigger_method) {
152 ASSERT_TRUE(ShouldRunMigrationTest());
153
154 // If we have only one client, turn off notifications to avoid the
155 // possibility of spurious sync cycles.
156 bool do_test_without_notifications =
157 (trigger_method != TRIGGER_NOTIFICATION && num_clients() == 1);
158
159 if (do_test_without_notifications) {
160 DisableNotifications();
161 }
162
163 // Phase 1: Trigger the migrations on the server.
164 for (MigrationList::const_iterator it = migration_list.begin();
165 it != migration_list.end(); ++it) {
166 TriggerMigrationDoneError(*it);
167 }
168
169 // Phase 2: Trigger each migration individually and wait for it to
170 // complete. (Multiple migrations may be handled by each
171 // migration cycle, but there's no guarantee of that, so we have
172 // to trigger each migration individually.)
173 for (MigrationList::const_iterator it = migration_list.begin();
174 it != migration_list.end(); ++it) {
175 TriggerMigration(*it, trigger_method);
176 AwaitMigration(*it);
177 }
178
179 // Phase 3: Wait for all clients to catch up.
180 AwaitQuiescence();
181
182 // Re-enable notifications if we disabled it.
183 if (do_test_without_notifications) {
184 EnableNotifications();
185 }
186 }
29 187
30 private: 188 private:
31 DISALLOW_COPY_AND_ASSIGN(MigrationCycleTest); 189 DISALLOW_COPY_AND_ASSIGN(MigrationTest);
32 }; 190 };
33 191
34 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, PrefsOnly) { 192 class MigrationSingleClientTest : public MigrationTest {
35 if (!ServerSupportsNotificationControl() ||
36 !ServerSupportsErrorTriggering()) {
37 LOG(WARNING) << "Test skipped in this server environment.";
38 return;
39 }
40
41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
42
43 DisableNotifications();
44
45 // Phase 1: Trigger a preference migration on the server.
46 syncable::ModelTypeSet migrate_types;
47 migrate_types.insert(syncable::PREFERENCES);
48 TriggerMigrationDoneError(migrate_types);
49
50 // Phase 2: Modify a pref (to trigger migration) and wait for a sync
51 // cycle.
52 // TODO(akalin): Shouldn't need to wait for full sync cycle; see
53 // 93167.
54 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
55 ChangeBooleanPref(0, prefs::kShowHomeButton);
56 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration"));
57 }
58
59 // TODO(akalin): Fails (times out) due to http://crbug.com/92928.
60 IN_PROC_BROWSER_TEST_F(MigrationCycleTest,
61 DISABLED_PrefsOnlyTriggerNotification) {
62 if (!ServerSupportsNotificationControl() ||
63 !ServerSupportsErrorTriggering()) {
64 LOG(WARNING) << "Test skipped in this server environment.";
65 return;
66 }
67
68 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
69
70 // Phase 1: Trigger a preference migration on the server.
71 syncable::ModelTypeSet migrate_types;
72 migrate_types.insert(syncable::PREFERENCES);
73 TriggerMigrationDoneError(migrate_types);
74
75 // Phase 2: Synthesize a notification (to trigger migration) and
76 // wait for a sync cycle.
77 // TODO(akalin): Shouldn't need to wait for full sync cycle; see
78 // 93167.
79 TriggerNotification(migrate_types);
80 ASSERT_TRUE(GetClient(0)->AwaitNextSyncCycleCompletion("Migration"));
81 }
82
83 // TODO(akalin): Fails (times out) due to http://crbug.com/92928.
84 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_PrefsNigori) {
85 if (!ServerSupportsNotificationControl() ||
86 !ServerSupportsErrorTriggering()) {
87 LOG(WARNING) << "Test skipped in this server environment.";
88 return;
89 }
90
91 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
92
93 DisableNotifications();
94
95 // Phase 1: Trigger a preference and nigori migration on the server.
96 {
97 syncable::ModelTypeSet migrate_types;
98 migrate_types.insert(syncable::PREFERENCES);
99 TriggerMigrationDoneError(migrate_types);
100 }
101 {
102 syncable::ModelTypeSet migrate_types;
103 migrate_types.insert(syncable::NIGORI);
104 TriggerMigrationDoneError(migrate_types);
105 }
106
107 // Phase 2: Modify a pref (to trigger migration) and wait for a sync
108 // cycle.
109 // TODO(akalin): Shouldn't need to wait for full sync cycle; see
110 // 93167.
111 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
112 ChangeBooleanPref(0, prefs::kShowHomeButton);
113 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration"));
114 }
115
116 // TODO(akalin): Fails (times out) due to http://crbug.com/92928.
117 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, DISABLED_BookmarksPrefs) {
118 if (!ServerSupportsNotificationControl() ||
119 !ServerSupportsErrorTriggering()) {
120 LOG(WARNING) << "Test skipped in this server environment.";
121 return;
122 }
123
124 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
125
126 DisableNotifications();
127
128 // Phase 1: Trigger a bookmark and preference migration on the
129 // server.
130 {
131 syncable::ModelTypeSet migrate_types;
132 migrate_types.insert(syncable::BOOKMARKS);
133 TriggerMigrationDoneError(migrate_types);
134 }
135 {
136 syncable::ModelTypeSet migrate_types;
137 migrate_types.insert(syncable::PREFERENCES);
138 TriggerMigrationDoneError(migrate_types);
139 }
140
141 // Phase 2: Modify a bookmark (to trigger migration) and wait for a
142 // sync cycle.
143 // TODO(akalin): Shouldn't need to wait for full sync cycle; see
144 // 93167.
145 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
146 ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Migration"));
147 }
148
149 // TODO(akalin): Add tests where the migration trigger is a poll.
150
151 class MigrationErrorsTest : public LiveSyncTest {
152 public: 193 public:
153 MigrationErrorsTest() : LiveSyncTest(TWO_CLIENT) {} 194 MigrationSingleClientTest() : MigrationTest(SINGLE_CLIENT) {}
154 virtual ~MigrationErrorsTest() {} 195 virtual ~MigrationSingleClientTest() {}
196
197 void RunSingleClientMigrationTest(const MigrationList& migration_list,
198 TriggerMethod trigger_method) {
199 if (!ShouldRunMigrationTest()) {
200 return;
201 }
202 ASSERT_TRUE(SetupSync());
203 RunMigrationTest(migration_list, trigger_method);
204 }
155 205
156 private: 206 private:
157 DISALLOW_COPY_AND_ASSIGN(MigrationErrorsTest); 207 DISALLOW_COPY_AND_ASSIGN(MigrationSingleClientTest);
158 }; 208 };
159 209
160 // Easiest possible test of migration errors: triggers a server migration on 210 // The simplest possible migration tests -- a single data type.
161 // one datatype, then modifies some other datatype. 211
162 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 212 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsOnlyModifyPref) {
163 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 213 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES), MODIFY_PREF);
164 DISABLED_MigratePrefsThenModifyBookmark) { 214 }
165 if (!ServerSupportsErrorTriggering()) { 215
166 LOG(WARNING) << "Test skipped in this server environment."; 216 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsOnlyModifyBookmark) {
167 return; 217 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
168 } 218 MODIFY_BOOKMARK);
169 219 }
170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 220
171 221 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
172 // Phase 1: Before migrating anything, create & sync a preference. 222 PrefsOnlyTriggerNotification) {
173 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 223 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
174 ChangeBooleanPref(0, prefs::kShowHomeButton); 224 TRIGGER_NOTIFICATION);
175 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 225 }
176 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 226
177 227 // Nigori is handled specially, so we test that separately.
178 // Phase 2: Trigger a preference migration on the server. 228
179 syncable::ModelTypeSet migrate_types; 229 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, NigoriOnly) {
180 migrate_types.insert(syncable::PREFERENCES); 230 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
181 TriggerMigrationDoneError(migrate_types); 231 TRIGGER_NOTIFICATION);
182 232 }
183 // Phase 3: Modify a bookmark and wait for it to sync. 233
184 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); 234 // A little more complicated -- two data types.
185 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 235
186 236 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
187 // Phase 4: Verify that preferences can still be synchronized. 237 BookmarksPrefsIndividually) {
188 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 238 RunSingleClientMigrationTest(
189 ChangeBooleanPref(0, prefs::kShowHomeButton); 239 MakeList(syncable::BOOKMARKS, syncable::PREFERENCES),
190 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 240 MODIFY_PREF);
191 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 241 }
242
243 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, BookmarksPrefsBoth) {
244 RunSingleClientMigrationTest(
245 MakeList(MakeSet(syncable::BOOKMARKS, syncable::PREFERENCES)),
246 MODIFY_BOOKMARK);
247 }
248
249 // Two data types with one being nigori.
250
251 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriIndividiaully) {
252 RunSingleClientMigrationTest(
253 MakeList(syncable::PREFERENCES, syncable::NIGORI),
254 TRIGGER_NOTIFICATION);
255 }
256
257 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriBoth) {
258 RunSingleClientMigrationTest(
259 MakeList(MakeSet(syncable::PREFERENCES, syncable::NIGORI)),
260 MODIFY_PREF);
261 }
262
263 // The whole shebang -- all data types.
264
265 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesIndividually) {
266 ASSERT_TRUE(SetupClients());
267 RunSingleClientMigrationTest(GetPreferredDataTypesList(), MODIFY_BOOKMARK);
268 }
269
270 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
271 AllTypesIndividuallyTriggerNotification) {
272 ASSERT_TRUE(SetupClients());
273 RunSingleClientMigrationTest(GetPreferredDataTypesList(),
274 TRIGGER_NOTIFICATION);
275 }
276
277 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesAtOnce) {
278 ASSERT_TRUE(SetupClients());
279 RunSingleClientMigrationTest(MakeList(GetPreferredDataTypes()),
280 MODIFY_PREF);
281 }
282
283 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
284 AllTypesAtOnceTriggerNotification) {
285 ASSERT_TRUE(SetupClients());
286 RunSingleClientMigrationTest(MakeList(GetPreferredDataTypes()),
287 TRIGGER_NOTIFICATION);
288 }
289
290 // All data types plus nigori.
291
292 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
293 AllTypesWithNigoriIndividually) {
294 ASSERT_TRUE(SetupClients());
295 MigrationList migration_list = GetPreferredDataTypesList();
296 migration_list.push_front(MakeSet(syncable::NIGORI));
297 RunSingleClientMigrationTest(migration_list, MODIFY_BOOKMARK);
298 }
299
300 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesWithNigoriAtOnce) {
301 ASSERT_TRUE(SetupClients());
302 syncable::ModelTypeSet all_types = GetPreferredDataTypes();
303 all_types.insert(syncable::NIGORI);
304 RunSingleClientMigrationTest(MakeList(all_types), MODIFY_PREF);
305 }
306
307 class MigrationTwoClientTest : public MigrationTest {
308 public:
309 MigrationTwoClientTest() : MigrationTest(TWO_CLIENT) {}
310 virtual ~MigrationTwoClientTest() {}
311
312 // Helper function that verifies that preferences sync still works.
313 void VerifyPrefSync() {
314 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
315 ChangeBooleanPref(0, prefs::kShowHomeButton);
316 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
317 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
318 }
319
320 void RunTwoClientMigrationTest(const MigrationList& migration_list,
321 TriggerMethod trigger_method) {
322 if (!ShouldRunMigrationTest()) {
323 return;
324 }
325 ASSERT_TRUE(SetupSync());
326
327 // Make sure pref sync works before running the migration test.
328 VerifyPrefSync();
329
330 RunMigrationTest(migration_list, trigger_method);
331
332 // Make sure pref sync still works after running the migration
333 // test.
334 VerifyPrefSync();
335 }
336
337 private:
338 DISALLOW_COPY_AND_ASSIGN(MigrationTwoClientTest);
339 };
340
341 // Easiest possible test of migration errors: triggers a server
342 // migration on one datatype, then modifies some other datatype.
343 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest,
344 MigratePrefsThenModifyBookmark) {
345 RunTwoClientMigrationTest(MakeList(syncable::PREFERENCES),
346 MODIFY_BOOKMARK);
192 } 347 }
193 348
194 // Triggers a server migration on two datatypes, then makes a local 349 // Triggers a server migration on two datatypes, then makes a local
195 // modification to one of them. 350 // modification to one of them.
196 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 351 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest,
197 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 352 MigratePrefsAndBookmarksThenModifyBookmark) {
198 DISABLED_MigratePrefsAndBookmarksThenModifyBookmark) { 353 RunTwoClientMigrationTest(
199 if (!ServerSupportsErrorTriggering()) { 354 MakeList(syncable::PREFERENCES, syncable::BOOKMARKS),
200 LOG(WARNING) << "Test skipped in this server environment."; 355 MODIFY_BOOKMARK);
201 return;
202 }
203
204 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
205
206 // Phase 1: Before migrating anything, create & sync a preference.
207 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
208 ChangeBooleanPref(0, prefs::kShowHomeButton);
209 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
210 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
211
212 // Phase 2: Trigger a migration on the server.
213 syncable::ModelTypeSet migrate_types;
214 migrate_types.insert(syncable::PREFERENCES);
215 migrate_types.insert(syncable::BOOKMARKS);
216 TriggerMigrationDoneError(migrate_types);
217
218 // Phase 3: Modify a bookmark and wait for it to sync.
219 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
220 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
221
222 // Phase 4: Verify that preferences can still be synchronized.
223 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
224 ChangeBooleanPref(0, prefs::kShowHomeButton);
225 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
226 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
227 } 356 }
228 357
229 // Migrate every datatype in sequence; the catch being that the server 358 // Migrate every datatype in sequence; the catch being that the server
230 // will only tell the client about the migrations one at a time. 359 // will only tell the client about the migrations one at a time.
231 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 360 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithoutNigori) {
232 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 361 ASSERT_TRUE(SetupClients());
233 DISABLED_MigrationHellWithoutNigori) { 362 MigrationList migration_list = GetPreferredDataTypesList();
234 if (!ServerSupportsErrorTriggering()) { 363 // Let the first nudge be a datatype that's neither prefs nor
235 LOG(WARNING) << "Test skipped in this server environment."; 364 // bookmarks.
236 return; 365 migration_list.push_front(MakeSet(syncable::THEMES));
237 } 366 RunTwoClientMigrationTest(migration_list, MODIFY_BOOKMARK);
238 367 }
239 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 368
240 369 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithNigori) {
241 // Phase 1: Before migrating anything, create & sync a preference. 370 ASSERT_TRUE(SetupClients());
242 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 371 MigrationList migration_list = GetPreferredDataTypesList();
243 ChangeBooleanPref(0, prefs::kShowHomeButton); 372 // Let the first nudge be a datatype that's neither prefs nor
244 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 373 // bookmarks.
245 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 374 migration_list.push_front(MakeSet(syncable::THEMES));
246 375 // Pop off one so that we don't migrate all data types; the syncer
247 // Phase 2: Queue up a horrendous number of migrations on the server. 376 // freaks out if we do that (see http://crbug.com/94882).
248 // Let the first nudge be a datatype that's neither prefs nor bookmarks. 377 ASSERT_GE(migration_list.size(), 2u);
249 syncable::ModelTypeSet migrate_themes; 378 ASSERT_NE(migration_list.back(), MakeSet(syncable::NIGORI));
250 migrate_themes.insert(syncable::THEMES); 379 migration_list.back() = MakeSet(syncable::NIGORI);
251 TriggerMigrationDoneError(migrate_themes); 380 RunTwoClientMigrationTest(migration_list, MODIFY_BOOKMARK);
252 for (int i = syncable::FIRST_REAL_MODEL_TYPE; i < syncable::MODEL_TYPE_COUNT; 381 }
253 ++i) { 382
254 if (i == syncable::NIGORI) { 383 class MigrationReconfigureTest : public MigrationTwoClientTest {
255 continue;
256 }
257 syncable::ModelTypeSet migrate_types;
258 migrate_types.insert(syncable::ModelTypeFromInt(i));
259 TriggerMigrationDoneError(migrate_types);
260 }
261
262 // Phase 3: Modify a bookmark and wait for it to sync.
263 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
264 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
265
266 // Phase 4: Verify that preferences can still be synchronized.
267 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
268 ChangeBooleanPref(0, prefs::kShowHomeButton);
269 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
270 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
271 }
272
273 // TODO(akalin): Fails (times out) due to http://crbug.com/92928.
274 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest,
275 DISABLED_MigrationHellWithNigori) {
276 if (!ServerSupportsErrorTriggering()) {
277 LOG(WARNING) << "Test skipped in this server environment.";
278 return;
279 }
280
281 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
282
283 // Phase 1: Before migrating anything, create & sync a preference.
284 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
285 ChangeBooleanPref(0, prefs::kShowHomeButton);
286 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
287 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
288
289 // Phase 2: Queue up a horrendous number of migrations on the server.
290 // Let the first nudge be a datatype that's neither prefs nor bookmarks.
291 syncable::ModelTypeSet migrate_themes;
292 migrate_themes.insert(syncable::THEMES);
293 TriggerMigrationDoneError(migrate_themes);
294 for (int i = syncable::FIRST_REAL_MODEL_TYPE; i < syncable::MODEL_TYPE_COUNT;
295 ++i) {
296 // TODO(lipalani): If all types are disabled syncer freaks out. Fix it.
297 if (i == syncable::BOOKMARKS) {
298 continue;
299 }
300 syncable::ModelTypeSet migrate_types;
301 migrate_types.insert(syncable::ModelTypeFromInt(i));
302 TriggerMigrationDoneError(migrate_types);
303 }
304
305 // Phase 3: Modify a bookmark and wait for it to sync.
306 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
307 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
308
309 // Phase 4: Verify that preferences can still be synchronized.
310 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
311 ChangeBooleanPref(0, prefs::kShowHomeButton);
312 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
313 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
314 }
315
316 class MigrationReconfigureTest : public LiveSyncTest {
317 public: 384 public:
318 MigrationReconfigureTest() : LiveSyncTest(TWO_CLIENT) {} 385 MigrationReconfigureTest() {}
319 386
320 virtual void SetUpCommandLine(CommandLine* cl) OVERRIDE { 387 virtual void SetUpCommandLine(CommandLine* cl) OVERRIDE {
321 AddTestSwitches(cl); 388 AddTestSwitches(cl);
322 // Do not add optional datatypes. 389 // Do not add optional datatypes.
323 } 390 }
324 391
325 virtual ~MigrationReconfigureTest() {} 392 virtual ~MigrationReconfigureTest() {}
326 393
327 private: 394 private:
328 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); 395 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest);
329 }; 396 };
330 397
331 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabs) { 398 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabs) {
332 if (!ServerSupportsErrorTriggering()) { 399 if (!ServerSupportsErrorTriggering()) {
333 LOG(WARNING) << "Test skipped in this server environment."; 400 LOG(WARNING) << "Test skipped in this server environment.";
334 return; 401 return;
335 } 402 }
336 403
337 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 404 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
338 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 405 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
339 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 406 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
340 407
341 // Phase 1: Before migrating anything, create & sync a preference. 408 // Phase 1: Before migrating anything, create & sync a preference.
342 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 409 VerifyPrefSync();
343 ChangeBooleanPref(0, prefs::kShowHomeButton);
344 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
345 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
346 410
347 // Phase 2: Trigger setting the sync_tabs field. 411 // Phase 2: Trigger setting the sync_tabs field.
348 TriggerSetSyncTabs(); 412 TriggerSetSyncTabs();
349 413
350 // Phase 3: Modify a bookmark and wait for it to sync. 414 // Phase 3: Modify a bookmark and wait for it to sync.
351 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); 415 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
352 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 416 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
353 417
354 // Phase 4: Verify that preferences can still be synchronized. 418 // Phase 4: Verify that preferences can still be synchronized.
355 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 419 VerifyPrefSync();
356 ChangeBooleanPref(0, prefs::kShowHomeButton);
357 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
358 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
359 420
360 // Phase 5: Verify that sessions are registered and enabled. 421 // Phase 5: Verify that sessions are registered and enabled.
361 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 422 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
362 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 423 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
363 } 424 }
364 425
365 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 426 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabsAndMigrate) {
366 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest,
367 DISABLED_SetSyncTabsAndMigrate) {
368 if (!ServerSupportsErrorTriggering()) { 427 if (!ServerSupportsErrorTriggering()) {
369 LOG(WARNING) << "Test skipped in this server environment."; 428 LOG(WARNING) << "Test skipped in this server environment.";
370 return; 429 return;
371 } 430 }
372 431
373 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 432 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
374 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 433 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
375 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 434 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
376 435
377 // Phase 1: Before migrating anything, create & sync a preference. 436 // Phase 1: Before migrating anything, create & sync a preference.
378 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 437 VerifyPrefSync();
379 ChangeBooleanPref(0, prefs::kShowHomeButton);
380 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
381 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
382 438
383 // Phase 2: Trigger setting the sync_tabs field. 439 // Phase 2: Trigger setting the sync_tabs field.
384 TriggerSetSyncTabs(); 440 TriggerSetSyncTabs();
385 441
386 // Phase 3: Trigger a preference migration on the server. 442 // Phase 3: Trigger a preference migration on the server.
387 syncable::ModelTypeSet migrate_types; 443 RunMigrationTest(MakeList(syncable::PREFERENCES), MODIFY_BOOKMARK);
388 migrate_types.insert(syncable::PREFERENCES);
389 TriggerMigrationDoneError(migrate_types);
390
391 // Phase 4: Modify a bookmark and wait for it to sync.
392 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
393 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
394 444
395 // Phase 5: Verify that preferences can still be synchronized. 445 // Phase 5: Verify that preferences can still be synchronized.
396 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 446 VerifyPrefSync();
397 ChangeBooleanPref(0, prefs::kShowHomeButton);
398 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
399 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
400 447
401 // Phase 6: Verify that sessions are registered and enabled. 448 // Phase 6: Verify that sessions are registered and enabled.
402 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 449 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
403 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 450 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
404 } 451 }
452
453 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_test.cc ('k') | chrome/test/sync/engine/test_user_share.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698