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

Side by Side Diff: remoting/test/chromoting_test_driver.cc

Issue 1864433005: Fixing the Chromoting Test Driver host online retry logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaning up HostInfo creation in the unit tests. Created 4 years, 8 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
« no previous file with comments | « no previous file | remoting/test/chromoting_test_driver_environment.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // The host name determines which host to initiate a session with from the 201 // The host name determines which host to initiate a session with from the
202 // host list returned from the directory service. 202 // host list returned from the directory service.
203 options.host_name = 203 options.host_name =
204 command_line->GetSwitchValueASCII(switches::kHostNameSwitchName); 204 command_line->GetSwitchValueASCII(switches::kHostNameSwitchName);
205 205
206 if (options.host_name.empty()) { 206 if (options.host_name.empty()) {
207 LOG(ERROR) << "No hostname passed in, connect to host requires hostname!"; 207 LOG(ERROR) << "No hostname passed in, connect to host requires hostname!";
208 return -1; 208 return -1;
209 } 209 }
210 VLOG(1) << "host_name: '" << options.host_name << "'";
210 211
211 options.host_jid = 212 options.host_jid =
212 command_line->GetSwitchValueASCII(switches::kHostJidSwitchName); 213 command_line->GetSwitchValueASCII(switches::kHostJidSwitchName);
213 214 VLOG(1) << "host_jid: '" << options.host_jid << "'";
214 VLOG(1) << "Chromoting tests will connect to: " << options.host_name;
215 215
216 options.pin = command_line->GetSwitchValueASCII(switches::kPinSwitchName); 216 options.pin = command_line->GetSwitchValueASCII(switches::kPinSwitchName);
217 217
218 // Create and register our global test data object. It will handle 218 // Create and register our global test data object. It will handle
219 // retrieving an access token or host list for the user. The GTest framework 219 // retrieving an access token or host list for the user. The GTest framework
220 // will own the lifetime of this object once it is registered below. 220 // will own the lifetime of this object once it is registered below.
221 scoped_ptr<remoting::test::ChromotingTestDriverEnvironment> shared_data( 221 scoped_ptr<remoting::test::ChromotingTestDriverEnvironment> shared_data(
222 new remoting::test::ChromotingTestDriverEnvironment(options)); 222 new remoting::test::ChromotingTestDriverEnvironment(options));
223 223
224 if (!shared_data->Initialize(auth_code)) { 224 if (!shared_data->Initialize(auth_code)) {
225 VLOG(1) << "Failed to initialize ChromotingTestDriverEnvironment instance.";
225 // If we failed to initialize our shared data object, then bail. 226 // If we failed to initialize our shared data object, then bail.
226 return -1; 227 return -1;
227 } 228 }
228 229
229 if (!options.host_jid.empty() && 230 // This method is necessary as there are occasional propagation delays in the
230 !shared_data->WaitForHostOnline(options.host_jid, options.host_name)) { 231 // backend and we don't want the test to fail because of that.
231 // Host with expected JID is not online. No point running further tests. 232 if (!shared_data->WaitForHostOnline(options.host_jid, options.host_name)) {
233 VLOG(1) << "The expected host was not available for connections.";
234 // Host is not online. No point running further tests.
232 return -1; 235 return -1;
233 } 236 }
234 237
235 // Since we've successfully set up our shared_data object, we'll assign the 238 // Since we've successfully set up our shared_data object, we'll assign the
236 // value to our global* and transfer ownership to the framework. 239 // value to our global* and transfer ownership to the framework.
237 remoting::test::g_chromoting_shared_data = shared_data.release(); 240 remoting::test::g_chromoting_shared_data = shared_data.release();
238 testing::AddGlobalTestEnvironment(remoting::test::g_chromoting_shared_data); 241 testing::AddGlobalTestEnvironment(remoting::test::g_chromoting_shared_data);
239 242
240 // Running the tests serially will avoid clients from connecting to the same 243 // Running the tests serially will avoid clients from connecting to the same
241 // host. 244 // host.
242 return base::LaunchUnitTestsSerially( 245 return base::LaunchUnitTestsSerially(
243 argc, argv, 246 argc, argv,
244 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite))); 247 base::Bind(&base::TestSuite::Run, base::Unretained(&test_suite)));
245 } 248 }
OLDNEW
« no previous file with comments | « no previous file | remoting/test/chromoting_test_driver_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698