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

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: Addressed rsimha's 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
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 a poll-based trigger method.
77 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION };
78
79 syncable::ModelTypeSet GetPreferredDataTypes() {
80 syncable::ModelTypeSet preferred_data_types;
81 GetClient(0)->service()->GetPreferredDataTypes(&preferred_data_types);
82 // Make sure all clients have the same preferred data types.
83 for (int i = 1; i < num_clients(); ++i) {
84 syncable::ModelTypeSet other_preferred_data_types;
85 GetClient(i)->service()->GetPreferredDataTypes(
86 &other_preferred_data_types);
87 EXPECT_EQ(preferred_data_types, other_preferred_data_types);
88 }
89 return preferred_data_types;
90 }
91
92 // Returns a MigrationList with every enabled data type in its own
93 // set.
94 MigrationList GetPreferredDataTypesList() {
95 MigrationList migration_list;
96 const syncable::ModelTypeSet& preferred_data_types =
97 GetPreferredDataTypes();
98 for (syncable::ModelTypeSet::const_iterator it =
99 preferred_data_types.begin();
100 it != preferred_data_types.end(); ++it) {
101 migration_list.push_back(MakeSet(*it));
102 }
103 return migration_list;
104 }
105
106 // Trigger a migration for the given types with the given method.
107 void TriggerMigration(const syncable::ModelTypeSet& model_types,
108 TriggerMethod trigger_method) {
109 switch (trigger_method) {
110 case MODIFY_PREF:
111 // Unlike MODIFY_BOOKMARK, MODIFY_PREF doesn't cause a
112 // notification to happen (since model association on a
113 // boolean pref clobbers the local value), so it doesn't work
114 // for anything but single-client tests.
115 ASSERT_EQ(1, num_clients());
116 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
117 ChangeBooleanPref(0, prefs::kShowHomeButton);
118 break;
119 case MODIFY_BOOKMARK:
120 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))));
121 break;
122 case TRIGGER_NOTIFICATION:
123 TriggerNotification(model_types);
124 break;
125 default:
126 ADD_FAILURE();
127 }
128 }
129
130 // Block until all clients have completed migration for the given
131 // types.
132 void AwaitMigration(const syncable::ModelTypeSet& migrate_types) {
133 for (int i = 0; i < num_clients(); ++i) {
134 ASSERT_TRUE(GetClient(i)->AwaitMigration(migrate_types));
135 }
136 }
137
138 bool ShouldRunMigrationTest() const {
139 if (!ServerSupportsNotificationControl() ||
140 !ServerSupportsErrorTriggering()) {
141 LOG(WARNING) << "Test skipped in this server environment.";
142 return false;
143 }
144 return true;
145 }
146
147 // Makes sure migration works with the given migration list and
148 // trigger method.
149 void RunMigrationTest(const MigrationList& migration_list,
150 TriggerMethod trigger_method) {
151 ASSERT_TRUE(ShouldRunMigrationTest());
152
153 // If we have only one client, turn off notifications to avoid the
154 // possibility of spurious sync cycles.
155 bool do_test_without_notifications =
156 (trigger_method != TRIGGER_NOTIFICATION && num_clients() == 1);
157
158 if (do_test_without_notifications) {
159 DisableNotifications();
160 }
161
162 // Phase 1: Trigger the migrations on the server.
163 for (MigrationList::const_iterator it = migration_list.begin();
164 it != migration_list.end(); ++it) {
165 TriggerMigrationDoneError(*it);
166 }
167
168 // Phase 2: Trigger each migration individually and wait for it to
169 // complete. (Multiple migrations may be handled by each
170 // migration cycle, but there's no guarantee of that, so we have
171 // to trigger each migration individually.)
172 for (MigrationList::const_iterator it = migration_list.begin();
173 it != migration_list.end(); ++it) {
174 TriggerMigration(*it, trigger_method);
175 AwaitMigration(*it);
176 }
177
178 // Phase 3: Wait for all clients to catch up.
179 AwaitQuiescence();
180
181 // Re-enable notifications if we disabled it.
182 if (do_test_without_notifications) {
183 EnableNotifications();
184 }
185 }
29 186
30 private: 187 private:
31 DISALLOW_COPY_AND_ASSIGN(MigrationCycleTest); 188 DISALLOW_COPY_AND_ASSIGN(MigrationTest);
32 }; 189 };
33 190
34 IN_PROC_BROWSER_TEST_F(MigrationCycleTest, PrefsOnly) { 191 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.
Raghu Simha 2011/09/01 04:23:59 Looks like you've fixed 93167 with this patch? (if
akalin 2011/09/01 04:39:05 Not quite, it's just that I don't have to work aro
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: 192 public:
153 MigrationErrorsTest() : LiveSyncTest(TWO_CLIENT) {} 193 MigrationSingleClientTest() : MigrationTest(SINGLE_CLIENT) {}
154 virtual ~MigrationErrorsTest() {} 194 virtual ~MigrationSingleClientTest() {}
195
196 void RunSingleClientMigrationTest(const MigrationList& migration_list,
197 TriggerMethod trigger_method) {
198 if (!ShouldRunMigrationTest()) {
199 return;
200 }
201 ASSERT_TRUE(SetupSync());
202 RunMigrationTest(migration_list, trigger_method);
203 }
155 204
156 private: 205 private:
157 DISALLOW_COPY_AND_ASSIGN(MigrationErrorsTest); 206 DISALLOW_COPY_AND_ASSIGN(MigrationSingleClientTest);
158 }; 207 };
159 208
160 // Easiest possible test of migration errors: triggers a server migration on 209 // The simplest possible migration tests -- a single data type.
161 // one datatype, then modifies some other datatype. 210
162 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 211 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsOnlyModifyPref) {
163 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 212 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES), MODIFY_PREF);
164 DISABLED_MigratePrefsThenModifyBookmark) { 213 }
165 if (!ServerSupportsErrorTriggering()) { 214
166 LOG(WARNING) << "Test skipped in this server environment."; 215 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsOnlyModifyBookmark) {
167 return; 216 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
168 } 217 MODIFY_BOOKMARK);
169 218 }
170 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 219
171 220 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
172 // Phase 1: Before migrating anything, create & sync a preference. 221 PrefsOnlyTriggerNotification) {
173 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 222 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
174 ChangeBooleanPref(0, prefs::kShowHomeButton); 223 TRIGGER_NOTIFICATION);
175 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 224 }
176 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 225
177 226 // Nigori is handled specially, so we test that separately.
178 // Phase 2: Trigger a preference migration on the server. 227
179 syncable::ModelTypeSet migrate_types; 228 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, NigoriOnly) {
180 migrate_types.insert(syncable::PREFERENCES); 229 RunSingleClientMigrationTest(MakeList(syncable::PREFERENCES),
181 TriggerMigrationDoneError(migrate_types); 230 TRIGGER_NOTIFICATION);
182 231 }
183 // Phase 3: Modify a bookmark and wait for it to sync. 232
184 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); 233 // A little more complicated -- two data types.
185 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 234
186 235 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
187 // Phase 4: Verify that preferences can still be synchronized. 236 BookmarksPrefsIndividually) {
188 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 237 RunSingleClientMigrationTest(
189 ChangeBooleanPref(0, prefs::kShowHomeButton); 238 MakeList(syncable::BOOKMARKS, syncable::PREFERENCES),
190 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 239 MODIFY_PREF);
191 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 240 }
241
242 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, BookmarksPrefsBoth) {
243 RunSingleClientMigrationTest(
244 MakeList(MakeSet(syncable::BOOKMARKS, syncable::PREFERENCES)),
245 MODIFY_BOOKMARK);
246 }
247
248 // Two data types with one being nigori.
249
250 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriIndividiaully) {
251 RunSingleClientMigrationTest(
252 MakeList(syncable::PREFERENCES, syncable::NIGORI),
253 TRIGGER_NOTIFICATION);
254 }
255
256 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, PrefsNigoriBoth) {
257 RunSingleClientMigrationTest(
258 MakeList(MakeSet(syncable::PREFERENCES, syncable::NIGORI)),
259 MODIFY_PREF);
260 }
261
262 // The whole shebang -- all data types.
263
264 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesIndividually) {
265 ASSERT_TRUE(SetupClients());
266 RunSingleClientMigrationTest(GetPreferredDataTypesList(), MODIFY_BOOKMARK);
267 }
268
269 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
270 AllTypesIndividuallyTriggerNotification) {
271 ASSERT_TRUE(SetupClients());
272 RunSingleClientMigrationTest(GetPreferredDataTypesList(),
273 TRIGGER_NOTIFICATION);
274 }
275
276 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesAtOnce) {
277 ASSERT_TRUE(SetupClients());
278 RunSingleClientMigrationTest(MakeList(GetPreferredDataTypes()),
279 MODIFY_PREF);
280 }
281
282 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
283 AllTypesAtOnceTriggerNotification) {
284 ASSERT_TRUE(SetupClients());
285 RunSingleClientMigrationTest(MakeList(GetPreferredDataTypes()),
286 TRIGGER_NOTIFICATION);
287 }
288
289 // All data types plus nigori.
290
291 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest,
292 AllTypesWithNigoriIndividually) {
293 ASSERT_TRUE(SetupClients());
294 MigrationList migration_list = GetPreferredDataTypesList();
295 migration_list.push_front(MakeSet(syncable::NIGORI));
296 RunSingleClientMigrationTest(migration_list, MODIFY_BOOKMARK);
297 }
298
299 IN_PROC_BROWSER_TEST_F(MigrationSingleClientTest, AllTypesWithNigoriAtOnce) {
300 ASSERT_TRUE(SetupClients());
301 syncable::ModelTypeSet all_types = GetPreferredDataTypes();
302 all_types.insert(syncable::NIGORI);
303 RunSingleClientMigrationTest(MakeList(all_types), MODIFY_PREF);
304 }
305
306 class MigrationTwoClientTest : public MigrationTest {
307 public:
308 MigrationTwoClientTest() : MigrationTest(TWO_CLIENT) {}
309 virtual ~MigrationTwoClientTest() {}
310
311 // Helper function that verifies that preferences sync still works.
312 void VerifyPrefSync() {
313 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
314 ChangeBooleanPref(0, prefs::kShowHomeButton);
315 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
316 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
317 }
318
319 void RunTwoClientMigrationTest(const MigrationList& migration_list,
320 TriggerMethod trigger_method) {
321 if (!ShouldRunMigrationTest()) {
322 return;
323 }
324 ASSERT_TRUE(SetupSync());
325
326 // Make sure pref sync works before running the migration test.
327 VerifyPrefSync();
328
329 RunMigrationTest(migration_list, trigger_method);
330
331 // Make sure pref sync still works after running the migration
332 // test.
333 VerifyPrefSync();
334 }
335
336 private:
337 DISALLOW_COPY_AND_ASSIGN(MigrationTwoClientTest);
338 };
339
340 // Easiest possible test of migration errors: triggers a server
341 // migration on one datatype, then modifies some other datatype.
342 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest,
343 MigratePrefsThenModifyBookmark) {
344 RunTwoClientMigrationTest(MakeList(syncable::PREFERENCES),
345 MODIFY_BOOKMARK);
192 } 346 }
193 347
194 // Triggers a server migration on two datatypes, then makes a local 348 // Triggers a server migration on two datatypes, then makes a local
195 // modification to one of them. 349 // modification to one of them.
196 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 350 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest,
197 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 351 MigratePrefsAndBookmarksThenModifyBookmark) {
198 DISABLED_MigratePrefsAndBookmarksThenModifyBookmark) { 352 RunTwoClientMigrationTest(
199 if (!ServerSupportsErrorTriggering()) { 353 MakeList(syncable::PREFERENCES, syncable::BOOKMARKS),
200 LOG(WARNING) << "Test skipped in this server environment."; 354 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 } 355 }
228 356
229 // Migrate every datatype in sequence; the catch being that the server 357 // Migrate every datatype in sequence; the catch being that the server
230 // will only tell the client about the migrations one at a time. 358 // will only tell the client about the migrations one at a time.
231 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 359 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithoutNigori) {
232 IN_PROC_BROWSER_TEST_F(MigrationErrorsTest, 360 ASSERT_TRUE(SetupClients());
233 DISABLED_MigrationHellWithoutNigori) { 361 MigrationList migration_list = GetPreferredDataTypesList();
234 if (!ServerSupportsErrorTriggering()) { 362 // Let the first nudge be a datatype that's neither prefs nor
235 LOG(WARNING) << "Test skipped in this server environment."; 363 // bookmarks.
236 return; 364 migration_list.push_front(MakeSet(syncable::THEMES));
237 } 365 RunTwoClientMigrationTest(migration_list, MODIFY_BOOKMARK);
238 366 }
239 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 367
240 368 IN_PROC_BROWSER_TEST_F(MigrationTwoClientTest, MigrationHellWithNigori) {
241 // Phase 1: Before migrating anything, create & sync a preference. 369 ASSERT_TRUE(SetupClients());
242 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 370 MigrationList migration_list = GetPreferredDataTypesList();
243 ChangeBooleanPref(0, prefs::kShowHomeButton); 371 // Let the first nudge be a datatype that's neither prefs nor
244 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 372 // bookmarks.
245 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 373 migration_list.push_front(MakeSet(syncable::THEMES));
246 374 // 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. 375 // 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. 376 ASSERT_GE(migration_list.size(), 2u);
249 syncable::ModelTypeSet migrate_themes; 377 ASSERT_NE(migration_list.back(), MakeSet(syncable::NIGORI));
250 migrate_themes.insert(syncable::THEMES); 378 migration_list.back() = MakeSet(syncable::NIGORI);
251 TriggerMigrationDoneError(migrate_themes); 379 RunTwoClientMigrationTest(migration_list, MODIFY_BOOKMARK);
252 for (int i = syncable::FIRST_REAL_MODEL_TYPE; i < syncable::MODEL_TYPE_COUNT; 380 }
253 ++i) { 381
254 if (i == syncable::NIGORI) { 382 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: 383 public:
318 MigrationReconfigureTest() : LiveSyncTest(TWO_CLIENT) {} 384 MigrationReconfigureTest() {}
319 385
320 virtual void SetUpCommandLine(CommandLine* cl) OVERRIDE { 386 virtual void SetUpCommandLine(CommandLine* cl) OVERRIDE {
321 AddTestSwitches(cl); 387 AddTestSwitches(cl);
322 // Do not add optional datatypes. 388 // Do not add optional datatypes.
323 } 389 }
324 390
325 virtual ~MigrationReconfigureTest() {} 391 virtual ~MigrationReconfigureTest() {}
326 392
327 private: 393 private:
328 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); 394 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest);
329 }; 395 };
330 396
331 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabs) { 397 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabs) {
332 if (!ServerSupportsErrorTriggering()) { 398 if (!ServerSupportsErrorTriggering()) {
333 LOG(WARNING) << "Test skipped in this server environment."; 399 LOG(WARNING) << "Test skipped in this server environment.";
334 return; 400 return;
335 } 401 }
336 402
337 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 403 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
338 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 404 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
339 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 405 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
340 406
341 // Phase 1: Before migrating anything, create & sync a preference. 407 // Phase 1: Before migrating anything, create & sync a preference.
342 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 408 VerifyPrefSync();
343 ChangeBooleanPref(0, prefs::kShowHomeButton);
344 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
345 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
346 409
347 // Phase 2: Trigger setting the sync_tabs field. 410 // Phase 2: Trigger setting the sync_tabs field.
348 TriggerSetSyncTabs(); 411 TriggerSetSyncTabs();
349 412
350 // Phase 3: Modify a bookmark and wait for it to sync. 413 // Phase 3: Modify a bookmark and wait for it to sync.
351 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); 414 ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL);
352 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 415 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
353 416
354 // Phase 4: Verify that preferences can still be synchronized. 417 // Phase 4: Verify that preferences can still be synchronized.
355 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 418 VerifyPrefSync();
356 ChangeBooleanPref(0, prefs::kShowHomeButton);
357 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
358 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
359 419
360 // Phase 5: Verify that sessions are registered and enabled. 420 // Phase 5: Verify that sessions are registered and enabled.
361 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 421 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
362 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 422 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
363 } 423 }
364 424
365 // TODO(akalin): Fails (times out) due to http://crbug.com/92928. 425 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest, SetSyncTabsAndMigrate) {
366 IN_PROC_BROWSER_TEST_F(MigrationReconfigureTest,
367 DISABLED_SetSyncTabsAndMigrate) {
368 if (!ServerSupportsErrorTriggering()) { 426 if (!ServerSupportsErrorTriggering()) {
369 LOG(WARNING) << "Test skipped in this server environment."; 427 LOG(WARNING) << "Test skipped in this server environment.";
370 return; 428 return;
371 } 429 }
372 430
373 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 431 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
374 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 432 ASSERT_FALSE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
375 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 433 ASSERT_FALSE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
376 434
377 // Phase 1: Before migrating anything, create & sync a preference. 435 // Phase 1: Before migrating anything, create & sync a preference.
378 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 436 VerifyPrefSync();
379 ChangeBooleanPref(0, prefs::kShowHomeButton);
380 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
381 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
382 437
383 // Phase 2: Trigger setting the sync_tabs field. 438 // Phase 2: Trigger setting the sync_tabs field.
384 TriggerSetSyncTabs(); 439 TriggerSetSyncTabs();
385 440
386 // Phase 3: Trigger a preference migration on the server. 441 // Phase 3: Trigger a preference migration on the server.
387 syncable::ModelTypeSet migrate_types; 442 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 443
395 // Phase 5: Verify that preferences can still be synchronized. 444 // Phase 5: Verify that preferences can still be synchronized.
396 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); 445 VerifyPrefSync();
397 ChangeBooleanPref(0, prefs::kShowHomeButton);
398 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
399 ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton));
400 446
401 // Phase 6: Verify that sessions are registered and enabled. 447 // Phase 6: Verify that sessions are registered and enabled.
402 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS)); 448 ASSERT_TRUE(GetClient(0)->IsTypeRegistered(syncable::SESSIONS));
403 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS)); 449 ASSERT_TRUE(GetClient(0)->IsTypePreferred(syncable::SESSIONS));
404 } 450 }
451
452 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698