Skip to content

Commit

Permalink
Adding first performance measurement test to Chromoting Waterfall.
Browse files Browse the repository at this point in the history
After running about 500 simulations on a swarming bot, I found that the time to authenticate and time between authenticated and connected on the Chromoting Waterfall does not exceed more than 1000 ms each (max for each is 671 ms and 646 ms, respectively). Having a 2000 ms threshold for both measurements is more than enough time to authenticate and connect.

Both Sergey and Anand have checked off on these thresholds to determine whether or not we have a bug.
BUG=

Review URL: https://codereview.chromium.org/1291533002

Cr-Commit-Position: refs/heads/master@{#343154}
  • Loading branch information
tonychun authored and Commit bot committed Aug 13, 2015
1 parent 2fb1f44 commit 43fcaac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
22 changes: 10 additions & 12 deletions remoting/test/chromoting_test_driver_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/test/chromoting_test_driver_environment.h"
#include "remoting/test/chromoting_test_fixture.h"
#include "remoting/test/connection_time_observer.h"

namespace {
const base::TimeDelta kPinBasedMaxConnectionTimeInSeconds =
base::TimeDelta::FromSeconds(5);
const int kPinBasedMaxAuthenticationTimeMs = 4000;
const int kMaxTimeToConnectMs = 1000;
base::TimeDelta::FromSeconds(4);
const int kPinBasedMaxAuthenticationTimeMs = 2000;
const int kMaxTimeToConnectMs = 2000;
}

namespace remoting {
namespace test {

TEST_F(ChromotingTestFixture, DISABLED_TestMeasurePinBasedAuthentication) {
TEST_F(ChromotingTestFixture, TestMeasurePinBasedAuthentication) {
bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
EXPECT_TRUE(connected);

Expand All @@ -35,9 +34,11 @@ TEST_F(ChromotingTestFixture, DISABLED_TestMeasurePinBasedAuthentication) {
protocol::ConnectionToHost::State::AUTHENTICATED,
protocol::ConnectionToHost::State::CONNECTED).InMilliseconds();
EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs);

connection_time_observer_->DisplayConnectionStats();
}

TEST_F(ChromotingTestFixture, DISABLED_TestMeasureReconnectPerformance) {
TEST_F(ChromotingTestFixture, TestMeasureReconnectPerformance) {
bool connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
EXPECT_TRUE(connected);

Expand All @@ -57,6 +58,8 @@ TEST_F(ChromotingTestFixture, DISABLED_TestMeasureReconnectPerformance) {
protocol::ConnectionToHost::State::CONNECTED).InMilliseconds();
EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs);

connection_time_observer_->DisplayConnectionStats();

// Begin reconnection to same host.
connected = ConnectToHost(kPinBasedMaxConnectionTimeInSeconds);
EXPECT_TRUE(connected);
Expand All @@ -76,13 +79,8 @@ TEST_F(ChromotingTestFixture, DISABLED_TestMeasureReconnectPerformance) {
protocol::ConnectionToHost::State::AUTHENTICATED,
protocol::ConnectionToHost::State::CONNECTED).InMilliseconds();
EXPECT_LE(authenticated_to_connected_time, kMaxTimeToConnectMs);
}

// TODO(TonyChun): Remove #include "chromoting_test_driver_environment.h" and
// this test once connecting to the lab's Linux host is working.
TEST(HostListTest, VerifyRequestedHostIsInHostList) {
EXPECT_TRUE(g_chromoting_shared_data);
EXPECT_TRUE(g_chromoting_shared_data->host_info().IsReadyForConnection());
connection_time_observer_->DisplayConnectionStats();
}

} // namespace test
Expand Down
31 changes: 23 additions & 8 deletions remoting/test/chromoting_test_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ void ChromotingTestFixture::Disconnect() {
test_chromoting_client_->EndConnection();
}

void ChromotingTestFixture::CreateObserver() {
if (connection_time_observer_) {
DestroyObserver();
}

connection_time_observer_.reset(new ConnectionTimeObserver());
test_chromoting_client_->AddRemoteConnectionObserver(
connection_time_observer_.get());
}

void ChromotingTestFixture::DestroyObserver() {
if (!connection_time_observer_) {
return;
}

test_chromoting_client_->RemoveRemoteConnectionObserver(
connection_time_observer_.get());
connection_time_observer_.reset();
}

bool ChromotingTestFixture::ConnectToHost(
const base::TimeDelta& max_time_to_connect) {
DCHECK(thread_checker_.CalledOnValidThread());
Expand All @@ -39,6 +59,8 @@ bool ChromotingTestFixture::ConnectToHost(
// Host is online and ready, initiate a remote session.
base::RunLoop run_loop;

CreateObserver();

base::Timer timer(true, false);
timer.Start(FROM_HERE, max_time_to_connect, run_loop.QuitClosure());

Expand All @@ -65,18 +87,11 @@ bool ChromotingTestFixture::ConnectToHost(
return true;
}

void ChromotingTestFixture::SetUp() {
connection_time_observer_.reset(new ConnectionTimeObserver());
test_chromoting_client_->AddRemoteConnectionObserver(
connection_time_observer_.get());
}

void ChromotingTestFixture::TearDown() {
// If a chromoting connection is still connected, we want to end the
// connection before starting the next test.
Disconnect();
test_chromoting_client_->RemoveRemoteConnectionObserver(
connection_time_observer_.get());
DestroyObserver();
}

} // namespace test
Expand Down
7 changes: 6 additions & 1 deletion remoting/test/chromoting_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ class ChromotingTestFixture

private:
// testing::Test overrides.
void SetUp() override;
void TearDown() override;

// Creates |connection_time_observer_| to attach to |test_chromoting_client_|.
void CreateObserver();

// Detaches |connection_time_observer_| and destroys it.
void DestroyObserver();

// Creates and manages the connection to the remote host.
scoped_ptr<TestChromotingClient> test_chromoting_client_;

Expand Down

0 comments on commit 43fcaac

Please sign in to comment.