Stabilize sync integration tests
This patch contains more updates to the ProfileSyncServiceTestHarness class, in light of recent changes to the sync startup sequence, and new tests that require support for offline scenarios.
BUG=53858,54743,52007
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/3399002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59463 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/test/live_sync/live_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc
index fcf1e47b..14ecf8d 100644
--- a/chrome/test/live_sync/live_sync_test.cc
+++ b/chrome/test/live_sync/live_sync_test.cc
@@ -229,14 +229,11 @@
net::RuleBasedHostResolverProc* resolver =
new net::RuleBasedHostResolverProc(host_resolver());
resolver->AllowDirectLookup("*.google.com");
- // Allow direct lookup of thawte.com. On Linux, we use Chromium's nss
- // implementation which uses ocsp.thawte.com for certificate verification.
- // Without this, running the test case on Linux causes an error as we make an
- // external DNS lookup of "ocsp.thawte.com".
+ // On Linux, we use Chromium's NSS implementation which uses the following
+ // hosts for certificate verification. Without these overrides, running the
+ // integration tests on Linux causes error as we make external DNS lookups.
resolver->AllowDirectLookup("*.thawte.com");
- // The new XMPP cert seems to use crl.geotrust.com on Linux.
resolver->AllowDirectLookup("*.geotrust.com");
- // SSL chain.
resolver->AllowDirectLookup("*.gstatic.com");
mock_host_resolver_override_.reset(
new net::ScopedDefaultHostResolverProc(resolver));
@@ -268,28 +265,20 @@
void LiveSyncTest::EnableNetwork(Profile* profile) {
SetProxyConfig(profile->GetRequestContext(),
net::ProxyConfig::CreateDirect());
- // Bugs: http://crbug.com/53857
- // http://crbug.com/53858
+ // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
}
void LiveSyncTest::DisableNetwork(Profile* profile) {
- // Set the current proxy configuration to a nonexistent proxy to
- // effectively disable networking.
+ // Set the current proxy configuration to a nonexistent proxy to effectively
+ // disable networking.
net::ProxyConfig config;
config.proxy_rules().ParseFromString("http=127.0.0.1:0");
SetProxyConfig(profile->GetRequestContext(), config);
+ // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
}
-bool LiveSyncTest::EnsureSyncServerConfiguration() {
- const CommandLine* cl = CommandLine::ForCurrentProcess();
- if (!cl->HasSwitch(switches::kSyncServiceURL))
- return true;
-
- return ConfigureSyncServer("user_email", username_);
-}
-
void LiveSyncTest::SetProxyConfig(URLRequestContextGetter* context_getter,
const net::ProxyConfig& proxy_config) {
base::WaitableEvent done(false, false);
@@ -301,19 +290,3 @@
proxy_config));
done.Wait();
}
-
-bool LiveSyncTest::ConfigureSyncServer(const std::string& name,
- const std::string& value) {
- std::string url = StringPrintf("http://%s:%d/chromiumsync/configure",
- test_server_.host_port_pair().host().c_str(),
- test_server_.host_port_pair().port());
- std::string data = EscapePath(name) + "=" + EscapePath(value);
- ConfigureURLFectcherDelegate delegate;
- scoped_ptr<URLFetcher> fetcher(
- URLFetcher::Create(0, GURL(url), URLFetcher::POST, &delegate));
- fetcher->set_request_context(Profile::GetDefaultRequestContext());
- fetcher->set_upload_data("application/x-www-form-urlencoded", data);
- fetcher->Start();
- MessageLoop::current()->Run();
- return delegate.success();
-}
diff --git a/chrome/test/live_sync/live_sync_test.h b/chrome/test/live_sync/live_sync_test.h
index 134b200..ee5ab08 100644
--- a/chrome/test/live_sync/live_sync_test.h
+++ b/chrome/test/live_sync/live_sync_test.h
@@ -129,9 +129,6 @@
// Enable outgoing network connections for the given profile.
virtual void EnableNetwork(Profile* profile);
- // Configure mock server with test's options.
- virtual bool EnsureSyncServerConfiguration();
-
protected:
// InProcessBrowserTest override. Destroys all the sync clients and sync
// profiles created by a test.
@@ -170,9 +167,6 @@
void SetProxyConfig(URLRequestContextGetter* context,
const net::ProxyConfig& proxy_config);
- // Sends configuration options to the mock sync server.
- bool ConfigureSyncServer(const std::string& name, const std::string& value);
-
// Used to differentiate between single-client, two-client, multi-client and
// many-client tests.
TestType test_type_;
diff --git a/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc
index 174fd12..2736537 100644
--- a/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/many_client_live_bookmarks_sync_test.cc
@@ -5,8 +5,7 @@
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
-// TODO(rsimha): Marking this as flaky until crbug.com/53931 is fixed.
-IN_PROC_BROWSER_TEST_F(ManyClientLiveBookmarksSyncTest, FLAKY_Sanity) {
+IN_PROC_BROWSER_TEST_F(ManyClientLiveBookmarksSyncTest, Sanity) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
BookmarkModelVerifier* v = verifier_helper();
v->AddURL(GetBookmarkModel(0), GetBookmarkBarNode(0), 0, L"Google URL",
diff --git a/chrome/test/live_sync/many_client_live_preferences_sync_test.cc b/chrome/test/live_sync/many_client_live_preferences_sync_test.cc
index 3c0ab77..1b28f39 100644
--- a/chrome/test/live_sync/many_client_live_preferences_sync_test.cc
+++ b/chrome/test/live_sync/many_client_live_preferences_sync_test.cc
@@ -4,8 +4,7 @@
#include "chrome/test/live_sync/live_preferences_sync_test.h"
-// TODO(rsimha): Marking this as flaky until crbug.com/53931 is fixed.
-IN_PROC_BROWSER_TEST_F(ManyClientLivePreferencesSyncTest, FLAKY_Sanity) {
+IN_PROC_BROWSER_TEST_F(ManyClientLivePreferencesSyncTest, Sanity) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
bool new_value = !GetVerifierPrefs()->GetBoolean(
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.cc b/chrome/test/live_sync/profile_sync_service_test_harness.cc
index b49bf56..541403b 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.cc
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.cc
@@ -15,6 +15,7 @@
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
+#include "chrome/test/test_timeouts.h"
#include "chrome/test/ui_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,8 +23,6 @@
// WAITING_FOR_UPDATES state.
static const int kMinTimestampNeededNone = -1;
-static const ProfileSyncService::Status kInvalidStatus = {};
-
// Simple class to implement a timeout using PostDelayedTask. If it is not
// aborted before picked up by a message queue, then it asserts with the message
// provided. This class is not thread safe.
@@ -88,7 +87,6 @@
const std::string& username, const std::string& password, int id)
: wait_state_(WAITING_FOR_ON_BACKEND_INITIALIZED),
profile_(p), service_(NULL),
- last_status_(kInvalidStatus),
last_timestamp_(0),
min_timestamp_needed_(kMinTimestampNeededNone),
username_(username), password_(password), id_(id) {
@@ -99,15 +97,14 @@
bool ProfileSyncServiceTestHarness::SetupSync() {
service_ = profile_->GetProfileSyncService("");
+ EXPECT_FALSE(service_ == NULL) << "SetupSync(): service_ is null.";
service_->AddObserver(this);
service_->signin_.StartSignIn(username_, password_, "", "");
-
return WaitForServiceInit();
}
void ProfileSyncServiceTestHarness::SignalStateCompleteWithNextState(
WaitState next_state) {
-
wait_state_ = next_state;
SignalStateComplete();
}
@@ -117,78 +114,62 @@
}
bool ProfileSyncServiceTestHarness::RunStateChangeMachine() {
- WaitState state = wait_state_;
- ProfileSyncService::Status status(service_->QueryDetailedSyncStatus());
+ WaitState original_wait_state = wait_state_;
switch (wait_state_) {
case WAITING_FOR_ON_BACKEND_INITIALIZED: {
LogClientInfo("WAITING_FOR_ON_BACKEND_INITIALIZED");
- if (service_->GetAuthError().state() != GoogleServiceAuthError::NONE) {
- SignalStateCompleteWithNextState(AUTH_ERROR);
- }
- if (service_->sync_initialized()) {
- SignalStateCompleteWithNextState(WAITING_FOR_NOTIFICATIONS_ENABLED);
+ if (service()->sync_initialized()) {
+ // The sync backend is initialized. Start waiting for the first sync
+ // cycle to complete.
+ SignalStateCompleteWithNextState(WAITING_FOR_INITIAL_SYNC);
}
break;
}
- case WAITING_FOR_NOTIFICATIONS_ENABLED: {
- LogClientInfo("WAITING_FOR_NOTIFICATIONS_ENABLED");
- if (status.notifications_enabled) {
+ case WAITING_FOR_INITIAL_SYNC: {
+ LogClientInfo("WAITING_FOR_INITIAL_SYNC");
+ if (IsSynced()) {
+ // The first sync cycle is now complete. We can start running tests.
SignalStateCompleteWithNextState(FULLY_SYNCED);
}
break;
}
- case WAITING_FOR_SERVER_REACHABLE: {
- LogClientInfo("WAITING_FOR_SERVER_REACHABLE");
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- if (!status.server_reachable) {
- break;
- }
- if (service()->backend()->HasUnsyncedItems() ||
- snap->has_more_to_sync || snap->unsynced_count != 0) {
- SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH);
- break;
- }
- last_timestamp_ = snap->max_local_timestamp;
- SignalStateCompleteWithNextState(FULLY_SYNCED);
- break;
- }
case WAITING_FOR_SYNC_TO_FINISH: {
LogClientInfo("WAITING_FOR_SYNC_TO_FINISH");
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- DCHECK(snap) << "Should have been at least one sync session by now";
- // TODO(rsimha): In an ideal world, snap->has_more_to_sync == false should
- // be a sufficient condition for sync to have completed. However, the
- // additional check of snap->unsynced_count is required due to
- // http://crbug.com/48989.
- if (service()->backend()->HasUnsyncedItems() ||
- snap->has_more_to_sync || snap->unsynced_count != 0) {
- if (!status.server_reachable)
- SignalStateCompleteWithNextState(WAITING_FOR_SERVER_REACHABLE);
+ if (!IsSynced()) {
+ // The client is not yet fully synced. Continue waiting.
+ if (!GetStatus().server_reachable) {
+ // The client cannot reach the sync server because the network is
+ // disabled. There is no need to wait anymore.
+ SignalStateCompleteWithNextState(SERVER_UNREACHABLE);
+ }
break;
}
- EXPECT_LE(last_timestamp_, snap->max_local_timestamp);
- last_timestamp_ = snap->max_local_timestamp;
+ GetUpdatedTimestamp();
SignalStateCompleteWithNextState(FULLY_SYNCED);
break;
}
case WAITING_FOR_UPDATES: {
LogClientInfo("WAITING_FOR_UPDATES");
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- DCHECK(snap) << "Should have been at least one sync session by now";
- if (snap->max_local_timestamp < min_timestamp_needed_) {
+ if (!IsSynced() || GetUpdatedTimestamp() < min_timestamp_needed_) {
+ // The client is not yet fully synced. Continue waiting until the client
+ // is at the required minimum timestamp.
break;
}
- EXPECT_LE(last_timestamp_, snap->max_local_timestamp);
- last_timestamp_ = snap->max_local_timestamp;
SignalStateCompleteWithNextState(FULLY_SYNCED);
break;
}
- case FULLY_SYNCED: {
- LogClientInfo("FULLY_SYNCED");
+ case SERVER_UNREACHABLE: {
+ LogClientInfo("SERVER_UNREACHABLE");
+ if (GetStatus().server_reachable) {
+ // The client was offline due to the network being disabled, but is now
+ // back online. Wait for the pending sync cycle to complete.
+ SignalStateCompleteWithNextState(WAITING_FOR_SYNC_TO_FINISH);
+ }
break;
}
- case AUTH_ERROR: {
- LogClientInfo("AUTH_ERROR");
+ case FULLY_SYNCED: {
+ // The client is online and fully synced. There is nothing to do.
+ LogClientInfo("FULLY_SYNCED");
break;
}
default:
@@ -196,8 +177,7 @@
// classes using the the UI message loop. Defer to their handling.
break;
}
- last_status_ = status;
- return state != wait_state_;
+ return original_wait_state != wait_state_;
}
void ProfileSyncServiceTestHarness::OnStateChanged() {
@@ -207,18 +187,33 @@
bool ProfileSyncServiceTestHarness::AwaitSyncCycleCompletion(
const std::string& reason) {
LogClientInfo("AwaitSyncCycleCompletion");
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- DCHECK(snap) << "Should have been at least one sync session by now";
- // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and
- // snap->unsynced_count once http://crbug.com/48989 is fixed.
- if (service()->backend()->HasUnsyncedItems() ||
- snap->has_more_to_sync ||
- snap->unsynced_count != 0) {
- wait_state_ = WAITING_FOR_SYNC_TO_FINISH;
- return AwaitStatusChangeWithTimeout(60, reason);
+ if (!IsSynced()) {
+ if (wait_state_ == SERVER_UNREACHABLE) {
+ // Client was offline; wait for it to go online, and then wait for sync.
+ AwaitStatusChangeWithTimeout(
+ TestTimeouts::live_operation_timeout_ms(), reason);
+ EXPECT_EQ(wait_state_, WAITING_FOR_SYNC_TO_FINISH);
+ return AwaitStatusChangeWithTimeout(
+ TestTimeouts::live_operation_timeout_ms(), reason);
+ } else {
+ EXPECT_TRUE(service()->sync_initialized());
+ wait_state_ = WAITING_FOR_SYNC_TO_FINISH;
+ AwaitStatusChangeWithTimeout(
+ TestTimeouts::live_operation_timeout_ms(), reason);
+ if (wait_state_ == FULLY_SYNCED) {
+ // Client is online; sync was successful.
+ return true;
+ } else if (wait_state_ == SERVER_UNREACHABLE){
+ // Client is offline; sync was unsuccessful.
+ return false;
+ } else {
+ LOG(FATAL) << "Invalid wait state:" << wait_state_;
+ return false;
+ }
+ }
} else {
- EXPECT_LE(last_timestamp_, snap->max_local_timestamp);
- last_timestamp_ = snap->max_local_timestamp;
+ // Client is already synced; don't wait.
+ GetUpdatedTimestamp();
return true;
}
}
@@ -270,18 +265,17 @@
int64 timestamp, const std::string& reason) {
LogClientInfo("WaitUntilTimestampIsAtLeast");
min_timestamp_needed_ = timestamp;
- const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
- DCHECK(snap) << "Should have been at least one sync session by now";
- if (snap->max_local_timestamp < min_timestamp_needed_) {
+ if (GetUpdatedTimestamp() < min_timestamp_needed_) {
wait_state_ = WAITING_FOR_UPDATES;
- return AwaitStatusChangeWithTimeout(60, reason);
+ return AwaitStatusChangeWithTimeout(
+ TestTimeouts::live_operation_timeout_ms(), reason);
} else {
return true;
}
}
bool ProfileSyncServiceTestHarness::AwaitStatusChangeWithTimeout(
- int timeout_seconds,
+ int timeout_milliseconds,
const std::string& reason) {
LogClientInfo("AwaitStatusChangeWithTimeout");
scoped_refptr<StateChangeTimeoutEvent> timeout_signal(
@@ -291,7 +285,7 @@
FROM_HERE,
NewRunnableMethod(timeout_signal.get(),
&StateChangeTimeoutEvent::Callback),
- 1000 * timeout_seconds);
+ timeout_milliseconds);
LogClientInfo("Before RunMessageLoop");
ui_test_utils::RunMessageLoop();
LogClientInfo("After RunMessageLoop");
@@ -303,12 +297,11 @@
// Wait for the OnBackendInitialized() callback.
EXPECT_EQ(wait_state_, WAITING_FOR_ON_BACKEND_INITIALIZED);
- EXPECT_TRUE(AwaitStatusChangeWithTimeout(30,
- "Waiting for OnBackendInitialized().")) <<
- "OnBackendInitialized() not seen after 30 seconds.";
-
- if (wait_state_ == AUTH_ERROR) {
- return false;
+ if (!AwaitStatusChangeWithTimeout(TestTimeouts::live_operation_timeout_ms(),
+ "Waiting for OnBackendInitialized().")) {
+ LOG(FATAL) << "OnBackendInitialized() not seen after "
+ << TestTimeouts::live_operation_timeout_ms() / 1000
+ << " seconds.";
}
// Choose datatypes to be synced.
@@ -317,17 +310,38 @@
i < syncable::MODEL_TYPE_COUNT; ++i) {
set.insert(syncable::ModelTypeFromInt(i));
}
- service_->OnUserChoseDatatypes(true, set);
+ service()->OnUserChoseDatatypes(true, set);
- // Wait for notifications_enabled to be set to true.
- EXPECT_EQ(wait_state_, WAITING_FOR_NOTIFICATIONS_ENABLED);
- EXPECT_TRUE(AwaitStatusChangeWithTimeout(30,
- "Waiting for notifications_enabled to be set to true.")) <<
- "notifications_enabled not set to true after 30 seconds.";
+ // Wait for initial sync cycle to complete.
+ EXPECT_EQ(wait_state_, WAITING_FOR_INITIAL_SYNC);
+ if (!AwaitStatusChangeWithTimeout(TestTimeouts::live_operation_timeout_ms(),
+ "Waiting for initial sync cycle to complete.")) {
+ LOG(FATAL) << "Initial sync cycle did not complete after "
+ << TestTimeouts::live_operation_timeout_ms() / 1000
+ << " seconds.";
+ }
return true;
}
+ProfileSyncService::Status ProfileSyncServiceTestHarness::GetStatus() {
+ EXPECT_FALSE(service() == NULL) << "GetStatus(): service() is NULL.";
+ return service()->QueryDetailedSyncStatus();
+}
+
+bool ProfileSyncServiceTestHarness::IsSynced() {
+ const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
+ // TODO(rsimha): Remove additional checks of snap->has_more_to_sync and
+ // snap->unsynced_count once http://crbug.com/48989 is fixed.
+ return (service() &&
+ snap &&
+ ServiceIsPushingChanges() &&
+ GetStatus().notifications_enabled &&
+ !service()->backend()->HasUnsyncedItems() &&
+ !snap->has_more_to_sync &&
+ snap->unsynced_count == 0);
+}
+
const SyncSessionSnapshot*
ProfileSyncServiceTestHarness::GetLastSessionSnapshot() const {
EXPECT_FALSE(service_ == NULL) << "Sync service has not yet been set up.";
@@ -337,14 +351,24 @@
return NULL;
}
+int64 ProfileSyncServiceTestHarness::GetUpdatedTimestamp() {
+ const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
+ EXPECT_FALSE(snap == NULL) << "GetUpdatedTimestamp(): Sync snapshot is NULL.";
+ EXPECT_LE(last_timestamp_, snap->max_local_timestamp);
+ last_timestamp_ = snap->max_local_timestamp;
+ return last_timestamp_;
+}
+
void ProfileSyncServiceTestHarness::LogClientInfo(std::string message) {
const SyncSessionSnapshot* snap = GetLastSessionSnapshot();
if (snap) {
LOG(INFO) << "Client " << id_ << ": " << message << ": "
- << "has_more_to_sync: " << snap->has_more_to_sync
- << ", max_local_timestamp: " << snap->max_local_timestamp
+ << "max_local_timestamp: " << snap->max_local_timestamp
+ << ", has_more_to_sync: " << snap->has_more_to_sync
<< ", unsynced_count: " << snap->unsynced_count
<< ", has_unsynced_items: " << service()->backend()->HasUnsyncedItems()
+ << ", notifications_enabled: " << GetStatus().notifications_enabled
+ << ", ServiceIsPushingChanges(): " << ServiceIsPushingChanges()
<< ".";
} else {
LOG(INFO) << "Client " << id_ << ": " << message << ": "
diff --git a/chrome/test/live_sync/profile_sync_service_test_harness.h b/chrome/test/live_sync/profile_sync_service_test_harness.h
index 34cfde3..e9c50ea8 100644
--- a/chrome/test/live_sync/profile_sync_service_test_harness.h
+++ b/chrome/test/live_sync/profile_sync_service_test_harness.h
@@ -66,8 +66,12 @@
static bool AwaitQuiescence(
std::vector<ProfileSyncServiceTestHarness*>& clients);
+ // Returns the ProfileSyncService member of the the sync client.
ProfileSyncService* service() { return service_; }
+ // Returns the status of the ProfileSyncService member of the the sync client.
+ ProfileSyncService::Status GetStatus();
+
// See ProfileSyncService::ShouldPushChanges().
bool ServiceIsPushingChanges() { return service_->ShouldPushChanges(); }
@@ -77,18 +81,21 @@
enum WaitState {
// The sync client awaits the OnBackendInitialized() callback.
WAITING_FOR_ON_BACKEND_INITIALIZED = 0,
- // The sync client is waiting for notifications_enabled to become true.
- WAITING_FOR_NOTIFICATIONS_ENABLED,
+
+ // The sync client is waiting for the first sync cycle to complete.
+ WAITING_FOR_INITIAL_SYNC,
+
// The sync client is waiting for an ongoing sync cycle to complete.
WAITING_FOR_SYNC_TO_FINISH,
+
// The sync client anticipates incoming updates leading to a new sync cycle.
WAITING_FOR_UPDATES,
- // The sync client is waiting for server_reachable to become true.
- WAITING_FOR_SERVER_REACHABLE,
+
+ // The sync client cannot reach the server.
+ SERVER_UNREACHABLE,
+
// The sync client is fully synced and there are no pending updates.
FULLY_SYNCED,
- // An authentication error has occurred.
- AUTH_ERROR,
NUMBER_OF_STATES,
};
@@ -101,13 +108,15 @@
bool RunStateChangeMachine();
// Returns true if a status change took place, false on timeout.
- virtual bool AwaitStatusChangeWithTimeout(int timeout_seconds,
+ virtual bool AwaitStatusChangeWithTimeout(int timeout_milliseconds,
const std::string& reason);
- // Returns true if the service initialized correctly. Set is_auth_retry to
- // true when calling this method second time after an authentication failure.
+ // Returns true if the service initialized correctly.
bool WaitForServiceInit();
+ // Returns true if the sync client has no unsynced items.
+ bool IsSynced();
+
// Logs message with relevant info about client's sync state (if available).
void LogClientInfo(std::string message);
@@ -119,8 +128,9 @@
// Returns a snapshot of the current sync session.
const SyncSessionSnapshot* GetLastSessionSnapshot() const;
- // State tracking. Used for debugging and tracking of state.
- ProfileSyncService::Status last_status_;
+ // Updates |last_timestamp_| with the timestamp of the current sync session.
+ // Returns the new value of |last_timestamp_|.
+ int64 GetUpdatedTimestamp();
// This value tracks the max sync timestamp (e.g. synced-to revision) inside
// the sync engine. It gets updated when a sync cycle ends and the session
diff --git a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
index bc66917..702d56b 100644
--- a/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/single_client_live_bookmarks_sync_test.cc
@@ -4,35 +4,25 @@
#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
-// TODO(rsimha): Debug the flakiness of this with fred. http://crbug.com/53858
-IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest,
- FAILS_OfflineToOnline) {
+IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, OfflineToOnline) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
DisableNetwork(GetProfile(0));
BookmarkModel* bm = GetBookmarkModel(0);
BookmarkModelVerifier* v = verifier_helper();
-
const BookmarkNode* top = v->AddGroup(bm, bm->other_node(), 0, L"top");
v->SetTitle(bm, top, L"title");
-
- EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change."));
- {
- ProfileSyncService::Status status(
- GetClient(0)->service()->QueryDetailedSyncStatus());
- EXPECT_EQ(status.summary, ProfileSyncService::Status::OFFLINE_UNSYNCED);
- }
+ EXPECT_FALSE(GetClient(0)->AwaitSyncCycleCompletion("Offline state change."));
+ EXPECT_EQ(ProfileSyncService::Status::OFFLINE_UNSYNCED,
+ GetClient(0)->GetStatus().summary);
EnableNetwork(GetProfile(0));
- {
- EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes."));
- ProfileSyncService::Status status(
- GetClient(0)->service()->QueryDetailedSyncStatus());
- EXPECT_EQ(status.summary, ProfileSyncService::Status::READY);
- v->ExpectMatch(bm);
- }
+ EXPECT_TRUE(GetClient(0)->AwaitSyncCycleCompletion("Commit changes."));
+ EXPECT_EQ(ProfileSyncService::Status::READY,
+ GetClient(0)->GetStatus().summary);
+
+ v->ExpectMatch(bm);
}
IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, Sanity) {
@@ -142,16 +132,3 @@
"Move after addition of bookmarks."));
v->ExpectMatch(bm);
}
-
-// Connects a client with no bookmarks to a cloud account. As a natural
-// consequence of shutdown, this will encode the BookmarkModel as JSON to the
-// 'Bookmarks' file. This is mostly useful to verify server state.
-// DISABLED because it should be; we use this as a utility more than a test.
-IN_PROC_BROWSER_TEST_F(SingleClientLiveBookmarksSyncTest, DISABLED_GetUpdates) {
- ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
-
- EXPECT_TRUE(GetClient(0)->ServiceIsPushingChanges());
- ProfileSyncService::Status status(GetService(0)->QueryDetailedSyncStatus());
- EXPECT_EQ(status.summary, ProfileSyncService::Status::READY);
- EXPECT_EQ(status.unsynced_count, 0);
-}
diff --git a/chrome/test/test_switches.cc b/chrome/test/test_switches.cc
index 9fbf153..3eb1dd24 100644
--- a/chrome/test/test_switches.cc
+++ b/chrome/test/test_switches.cc
@@ -10,6 +10,9 @@
// Enable displaying error dialogs (for debugging).
const char switches::kEnableErrorDialogs[] = "enable-errdialogs";
+// Time (in milliseconds) for which we wait for live operations to complete.
+const char switches::kLiveOperationTimeout[] = "live-operation-timeout";
+
// Number of iterations that page cycler tests will run.
const char switches::kPageCyclerIterations[] = "page-cycler-iterations";
diff --git a/chrome/test/test_switches.h b/chrome/test/test_switches.h
index 4497d1ac..f8a101f9 100644
--- a/chrome/test/test_switches.h
+++ b/chrome/test/test_switches.h
@@ -11,6 +11,7 @@
// alongside the definition of their values in the .cc file.
extern const char kExtraChromeFlags[];
extern const char kEnableErrorDialogs[];
+extern const char kLiveOperationTimeout[];
extern const char kPageCyclerIterations[];
extern const char kUiTestActionTimeout[];
extern const char kUiTestActionMaxTimeout[];
diff --git a/chrome/test/test_timeouts.cc b/chrome/test/test_timeouts.cc
index 245f148..8e38da0 100644
--- a/chrome/test/test_timeouts.cc
+++ b/chrome/test/test_timeouts.cc
@@ -43,6 +43,9 @@
int TestTimeouts::wait_for_terminate_timeout_ms_ = 15000;
// static
+int TestTimeouts::live_operation_timeout_ms_ = 30000;
+
+// static
void TestTimeouts::Initialize() {
if (initialized_) {
NOTREACHED();
@@ -64,4 +67,7 @@
&command_execution_timeout_ms_);
InitializeTimeout(switches::kUiTestTerminateTimeout,
&wait_for_terminate_timeout_ms_);
+
+ InitializeTimeout(switches::kLiveOperationTimeout,
+ &live_operation_timeout_ms_);
}
diff --git a/chrome/test/test_timeouts.h b/chrome/test/test_timeouts.h
index 8405a51..45034c4 100644
--- a/chrome/test/test_timeouts.h
+++ b/chrome/test/test_timeouts.h
@@ -45,6 +45,12 @@
return wait_for_terminate_timeout_ms_;
}
+ // Timeout to wait for a live operation to complete. Used by tests that access
+ // external services.
+ static int live_operation_timeout_ms() {
+ return live_operation_timeout_ms_;
+ }
+
private:
static bool initialized_;
@@ -54,6 +60,7 @@
static int sleep_timeout_ms_;
static int command_execution_timeout_ms_;
static int wait_for_terminate_timeout_ms_;
+ static int live_operation_timeout_ms_;
DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts);
};
diff --git a/net/tools/testserver/chromiumsync.py b/net/tools/testserver/chromiumsync.py
index a9041f01..c36054c3 100755
--- a/net/tools/testserver/chromiumsync.py
+++ b/net/tools/testserver/chromiumsync.py
@@ -619,19 +619,6 @@
# The implementation supports exactly one account; its state is here.
self.account = SyncDataModel()
self.account_lock = threading.Lock()
- self.account_user_email = '[email protected]'
-
- def HandleConfigure(self, config):
- """Handles various test configuration parameters sent from the client.
-
- Args:
- config: Dictionary of configuration parameters.
- Returns:
- True if configuration was successful.
- """
- if config.has_key('user_email'):
- self.account_user_email = config['user_email'][0]
- return True
def HandleCommand(self, raw_request):
"""Decode and handle a sync command from a raw input of bytes.
@@ -661,7 +648,7 @@
print 'Authenticate'
# We accept any authentication token, and support only one account.
# TODO(nick): Mock out the GAIA authentication as well; hook up here.
- response.authenticate.user.email = self.account_user_email
+ response.authenticate.user.email = 'syncjuser@chromium'
response.authenticate.user.display_name = 'Sync J User'
elif contents == sync_pb2.ClientToServerMessage.COMMIT:
print 'Commit'
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 4f30b2c..6ab36df7 100644
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -141,7 +141,6 @@
self.WriteFile,
self.EchoTitleHandler,
self.EchoAllHandler,
- self.ChromiumSyncConfigureHandler,
self.ChromiumSyncCommandHandler,
self.EchoHandler] + self._get_handlers
self._put_handlers = [
@@ -1027,29 +1026,6 @@
self.end_headers()
return True
- def ChromiumSyncConfigureHandler(self):
- """Handle updating the configuration of the sync server.
-
- The name and value pairs of the post payload will update the
- configuration of the sync server. Supported tuples are:
- user_email,<email address> - Sets the email for the fake user account
- """
- test_name = "/chromiumsync/configure"
- if not self._ShouldHandleRequest(test_name):
- return False
-
- length = int(self.headers.getheader('content-length'))
- raw_request = self.rfile.read(length)
- config = cgi.parse_qs(raw_request, keep_blank_values=1)
-
- success = self._sync_handler.HandleConfigure(config)
- if success:
- self.send_response(200)
- else:
- self.send_response(500)
- self.end_headers()
- return True
-
def ChromiumSyncCommandHandler(self):
"""Handle a chromiumsync command arriving via http.