-
Notifications
You must be signed in to change notification settings - Fork 5.5k
http2: transist READY client to busy when SETTING decreases the capacity #18999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1436,30 +1436,46 @@ TEST_F(Http2ConnPoolImplTest, PreconnectWithoutMultiplexing) { | |
|
|
||
| TEST_F(Http2ConnPoolImplTest, DisconnectWithNegativeCapacity) { | ||
| TestScopedRuntime scoped_runtime; | ||
| cluster_->http2_options_.mutable_max_concurrent_streams()->set_value(2); | ||
| cluster_->http2_options_.mutable_max_concurrent_streams()->set_value(4); | ||
| ON_CALL(*cluster_, perUpstreamPreconnectRatio).WillByDefault(Return(1)); | ||
|
|
||
| // One stream results in one connection. Two streams result in two connections. | ||
| expectClientsCreate(1); | ||
| ActiveTestRequest r1(*this, 0, false); | ||
| CHECK_STATE(0 /*active*/, 1 /*pending*/, 2 /*capacity*/); | ||
| CHECK_STATE(0 /*active*/, 1 /*pending*/, 4 /*capacity*/); | ||
| ActiveTestRequest r2(*this, 0, false); | ||
| CHECK_STATE(0 /*active*/, 2 /*pending*/, 2 /*capacity*/); | ||
| CHECK_STATE(0 /*active*/, 2 /*pending*/, 4 /*capacity*/); | ||
| ActiveTestRequest r3(*this, 0, false); | ||
| CHECK_STATE(0 /*active*/, 3 /*pending*/, 4 /*capacity*/); | ||
|
|
||
| // When the connection connects, there is zero spare capacity in this pool. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to update comments? |
||
| EXPECT_CALL(*test_clients_[0].codec_, newStream(_)) | ||
| .WillOnce(DoAll(SaveArgAddress(&r1.inner_decoder_), ReturnRef(r1.inner_encoder_))) | ||
| .WillOnce(DoAll(SaveArgAddress(&r2.inner_decoder_), ReturnRef(r2.inner_encoder_))); | ||
| .WillOnce(DoAll(SaveArgAddress(&r2.inner_decoder_), ReturnRef(r2.inner_encoder_))) | ||
| .WillOnce(DoAll(SaveArgAddress(&r3.inner_decoder_), ReturnRef(r3.inner_encoder_))); | ||
| EXPECT_CALL(r1.callbacks_.pool_ready_, ready()); | ||
| EXPECT_CALL(r2.callbacks_.pool_ready_, ready()); | ||
| EXPECT_CALL(r3.callbacks_.pool_ready_, ready()); | ||
| expectClientConnect(0); | ||
| CHECK_STATE(2 /*active*/, 0 /*pending*/, 0 /*capacity*/); | ||
| CHECK_STATE(3 /*active*/, 0 /*pending*/, 1 /*capacity*/); | ||
| EXPECT_EQ(pool_->owningList(Envoy::ConnectionPool::ActiveClient::State::READY).size(), 1); | ||
|
|
||
| // Settings frame reducing capacity to one stream per connection results in -1 capacity. | ||
| // Settings frame reducing capacity to one stream per connection results in -2 capacity. | ||
| NiceMock<MockReceivedSettings> settings; | ||
| settings.max_concurrent_streams_ = 1; | ||
| test_clients_[0].codec_client_->onSettings(settings); | ||
| CHECK_STATE(2 /*active*/, 0 /*pending*/, -1 /*capacity*/); | ||
| CHECK_STATE(3 /*active*/, 0 /*pending*/, -2 /*capacity*/); | ||
| EXPECT_EQ(pool_->owningList(Envoy::ConnectionPool::ActiveClient::State::READY).size(), 0); | ||
|
|
||
| // If one stream closes, concurrency capacity goes to -1, still no ready client available. | ||
| completeRequest(r1); | ||
| EXPECT_EQ(pool_->owningList(Envoy::ConnectionPool::ActiveClient::State::READY).size(), 0); | ||
|
|
||
| // Close all streams, concurrency capacity goes to -1, there should be one ready client. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. concurrency capacity goes to 1, not -1 right? |
||
| completeRequest(r2); | ||
| completeRequest(r3); | ||
| EXPECT_EQ(pool_->owningList(Envoy::ConnectionPool::ActiveClient::State::READY).size(), 1); | ||
| CHECK_STATE(0 /*active*/, 0 /*pending*/, 1 /*capacity*/); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mind creating more streams before doing the close? I think there's value in regression testing that close works when capacity is negative. |
||
|
|
||
| closeAllClients(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not yours, but I think this comment is from another test and should be removed here (as long as I'm looking at it)b