Skip to content

Commit

Permalink
Start a local XMPP-only python server for sync server integration tests
Browse files Browse the repository at this point in the history
The sync integration tests can also be run against a local instance of
a live sync server. However, when mock gaia credentials are used by the
client and server, we cannot rely on server initiated notifications due
to the mock credentials in use.

This patch causes the integration test framework to start an XMPP-only
version of the python sync server for use when integration tests are run
against a local live sync server using mock gaia credentials.

It also adds more meaningful variable names for the URL fetchers in
use by the integration test framework.

BUG=none
TEST=sync_integration_tests

Review URL: http://codereview.chromium.org/7821012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99078 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsimha@chromium.org committed Aug 31, 2011
1 parent 0fbe67b commit 466028d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
27 changes: 17 additions & 10 deletions chrome/test/live_sync/live_sync_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,24 @@ void LiveSyncTest::ReadPasswordFile() {
void LiveSyncTest::SetupMockGaiaResponses() {
username_ = "user@gmail.com";
password_ = "password";
integration_factory_.reset(new URLFetcherFactory());
factory_.reset(new FakeURLFetcherFactory(integration_factory_.get()));
factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true);
factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true);
factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true);
factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true);
factory_.reset(new URLFetcherFactory());
fake_factory_.reset(new FakeURLFetcherFactory(factory_.get()));
fake_factory_->SetFakeResponse(kClientLoginUrl, "SID=sid\nLSID=lsid", true);
fake_factory_->SetFakeResponse(kGetUserInfoUrl, "email=user@gmail.com", true);
fake_factory_->SetFakeResponse(kIssueAuthTokenUrl, "auth", true);
fake_factory_->SetFakeResponse(kSearchDomainCheckUrl, ".google.com", true);
}

// Start up a local sync server based on the value of server_type_, which
// was determined from the command line parameters.
void LiveSyncTest::SetUpTestServerIfRequired() {
if (server_type_ == LOCAL_PYTHON_SERVER) {
if (!SetUpLocalPythonTestServer())
LOG(FATAL) << "Failed to set up local python test server";
LOG(FATAL) << "Failed to set up local python sync and XMPP servers";
} else if (server_type_ == LOCAL_LIVE_SERVER) {
// Using mock gaia credentials requires the use of a mock XMPP server.
if (username_ == "user@gmail.com" && !SetUpLocalPythonTestServer())
LOG(FATAL) << "Failed to set up local python XMPP server";
if (!SetUpLocalTestServer())
LOG(FATAL) << "Failed to set up local test server";
} else if (server_type_ == EXTERNAL_LIVE_SERVER) {
Expand All @@ -402,9 +405,11 @@ bool LiveSyncTest::SetUpLocalPythonTestServer() {
<< "Could not launch local python test server.";

CommandLine* cl = CommandLine::ForCurrentProcess();
std::string sync_service_url = sync_server_.GetURL("chromiumsync").spec();
cl->AppendSwitchASCII(switches::kSyncServiceURL, sync_service_url);
VLOG(1) << "Started local python test server at " << sync_service_url;
if (server_type_ == LOCAL_PYTHON_SERVER) {
std::string sync_service_url = sync_server_.GetURL("chromiumsync").spec();
cl->AppendSwitchASCII(switches::kSyncServiceURL, sync_service_url);
VLOG(1) << "Started local python sync server at " << sync_service_url;
}

int xmpp_port = 0;
if (!sync_server_.server_data().GetInteger("xmpp_port", &xmpp_port)) {
Expand All @@ -426,6 +431,8 @@ bool LiveSyncTest::SetUpLocalPythonTestServer() {
// The local XMPP server only supports insecure connections.
cl->AppendSwitch(switches::kSyncAllowInsecureXmppConnection);
}
VLOG(1) << "Started local python XMPP server at "
<< xmpp_host_port_pair.ToString();

return true;
}
Expand Down
11 changes: 6 additions & 5 deletions chrome/test/live_sync/live_sync_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ class LiveSyncTest : public InProcessBrowserTest {
// Helper method that starts up a sync test server if required.
void SetUpTestServerIfRequired();

// Helper method used to start up a local python sync test server. Returns
// true if successful.
// Helper method used to start up a local python test server. Note: We set up
// an XMPP-only python server if |server_type_| is LOCAL_LIVE_SERVER and mock
// gaia credentials are in use. Returns true if successful.
bool SetUpLocalPythonTestServer();

// Helper method used to start up a local sync test server. Returns true if
Expand Down Expand Up @@ -299,10 +300,10 @@ class LiveSyncTest : public InProcessBrowserTest {
base::ProcessHandle test_server_handle_;

// Fake URLFetcher factory used to mock out GAIA signin.
scoped_ptr<FakeURLFetcherFactory> factory_;
scoped_ptr<FakeURLFetcherFactory> fake_factory_;

// URLFetcher factory used to contact sync server.
scoped_ptr<URLFetcherFactory> integration_factory_;
// The URLFetcherFactory instance used to instantiate |fake_factory_|.
scoped_ptr<URLFetcherFactory> factory_;

DISALLOW_COPY_AND_ASSIGN(LiveSyncTest);
};
Expand Down

0 comments on commit 466028d

Please sign in to comment.