Commit 6e4e4a05 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Fix websocket throttling unittests

I moved some unittests in [1] but I did it wrongly.

The original tests added N pending connections and measured the delay for
the Nth connection. The new tests add N pending connections and measured
the delay which will be used for a new connection (i.e., the N+1th
connection).

This CL fixes the issue.

1: https://crrev.com/8e55d7a3718dba9fe5d451cf899bef669ba02473

Bug: 721400
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Iee4c31414a217496df104c5194452e874be63c5a
Reviewed-on: https://chromium-review.googlesource.com/981960
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546042}
parent 30eb52cc
......@@ -173,13 +173,13 @@ TEST(WebSocketPerProcessThrottlerTest, Roll) {
EXPECT_EQ(0, throttler.num_previous_failed_connections());
}
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_4Pending) {
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_3Pending) {
WebSocketPerProcessThrottler throttler;
std::vector<WebSocketPerProcessThrottler::PendingConnection> trackers;
for (int i = 0; i < 4; ++i)
for (int i = 0; i < 3; ++i)
trackers.push_back(throttler.IssuePendingConnectionTracker());
EXPECT_EQ(4, throttler.num_pending_connections());
EXPECT_EQ(3, throttler.num_pending_connections());
EXPECT_EQ(0, throttler.num_current_succeeded_connections());
EXPECT_EQ(0, throttler.num_previous_succeeded_connections());
EXPECT_EQ(0, throttler.num_current_failed_connections());
......@@ -187,13 +187,13 @@ TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_4Pending) {
EXPECT_EQ(base::TimeDelta(), throttler.CalculateDelay());
}
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_8Pending) {
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_7Pending) {
WebSocketPerProcessThrottler throttler;
std::vector<WebSocketPerProcessThrottler::PendingConnection> trackers;
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 7; ++i)
trackers.push_back(throttler.IssuePendingConnectionTracker());
EXPECT_EQ(8, throttler.num_pending_connections());
EXPECT_EQ(7, throttler.num_pending_connections());
EXPECT_EQ(0, throttler.num_current_succeeded_connections());
EXPECT_EQ(0, throttler.num_previous_succeeded_connections());
EXPECT_EQ(0, throttler.num_current_failed_connections());
......@@ -201,13 +201,13 @@ TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_8Pending) {
EXPECT_LT(base::TimeDelta(), throttler.CalculateDelay());
}
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_17Pending) {
TEST(WebSocketPerProcessThrottlerTest, CalculateDelay_16Pending) {
WebSocketPerProcessThrottler throttler;
std::vector<WebSocketPerProcessThrottler::PendingConnection> trackers;
for (int i = 0; i < 17; ++i)
for (int i = 0; i < 16; ++i)
trackers.push_back(throttler.IssuePendingConnectionTracker());
EXPECT_EQ(17, throttler.num_pending_connections());
EXPECT_EQ(16, throttler.num_pending_connections());
EXPECT_EQ(0, throttler.num_current_succeeded_connections());
EXPECT_EQ(0, throttler.num_previous_succeeded_connections());
EXPECT_EQ(0, throttler.num_current_failed_connections());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment