-
Notifications
You must be signed in to change notification settings - Fork 5.5k
config: fix update empty stat for eds #4276
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 5 commits
4a29d7a
ecc6188
981914f
e2c49d9
d8c8196
f51d592
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 |
|---|---|---|
|
|
@@ -231,7 +231,6 @@ TEST_F(GrpcMuxImplTest, WildcardWatch) { | |
| // Validate behavior when watches specify resources (potentially overlapping). | ||
| TEST_F(GrpcMuxImplTest, WatchDemux) { | ||
| setup(); | ||
|
|
||
| InSequence s; | ||
| const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment; | ||
| NiceMock<MockGrpcMuxCallbacks> foo_callbacks; | ||
|
|
@@ -251,9 +250,7 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { | |
| envoy::api::v2::ClusterLoadAssignment load_assignment; | ||
| load_assignment.set_cluster_name("x"); | ||
| response->add_resources()->PackFrom(load_assignment); | ||
| EXPECT_CALL(bar_callbacks, onConfigUpdate(_, "1")) | ||
|
Member
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. Could make this a |
||
| .WillOnce(Invoke([](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
| const std::string&) { EXPECT_TRUE(resources.empty()); })); | ||
| EXPECT_CALL(bar_callbacks, onConfigUpdate(_, "1")).Times(0); | ||
| EXPECT_CALL(foo_callbacks, onConfigUpdate(_, "1")) | ||
| .WillOnce( | ||
| Invoke([&load_assignment](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
|
|
@@ -311,6 +308,57 @@ TEST_F(GrpcMuxImplTest, WatchDemux) { | |
| expectSendMessage(type_url, {}, "2"); | ||
| } | ||
|
|
||
| // Validate behavior when we have multiple watchers that send empty updates. | ||
| TEST_F(GrpcMuxImplTest, MultipleWatcherWithEmptyUpdates) { | ||
| setup(); | ||
| InSequence s; | ||
| const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment; | ||
| NiceMock<MockGrpcMuxCallbacks> foo_callbacks; | ||
| auto foo_sub = grpc_mux_->subscribe(type_url, {"x", "y"}, foo_callbacks); | ||
|
|
||
| EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_)); | ||
| expectSendMessage(type_url, {"x", "y"}, ""); | ||
| grpc_mux_->start(); | ||
|
|
||
| { | ||
|
Member
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. What's the reason for these block constructs? They are used elsewhere in the file for forcing subscription objects to be destroyed, do we need them in these new tests?
Contributor
Author
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. There is no specific reason other than follow the same pattern of having subscription in a block construct. Will remove them |
||
| std::unique_ptr<envoy::api::v2::DiscoveryResponse> response( | ||
| new envoy::api::v2::DiscoveryResponse()); | ||
| response->set_type_url(type_url); | ||
| response->set_version_info("1"); | ||
|
|
||
| EXPECT_CALL(foo_callbacks, onConfigUpdate(_, "1")).Times(0); | ||
| expectSendMessage(type_url, {"x", "y"}, "1"); | ||
| grpc_mux_->onReceiveMessage(std::move(response)); | ||
| } | ||
|
|
||
| expectSendMessage(type_url, {}, "1"); | ||
| } | ||
|
|
||
| // Validate behavior when we have Single Watcher that sends Empty updates. | ||
| TEST_F(GrpcMuxImplTest, SingleWatcherWithEmptyUpdates) { | ||
| setup(); | ||
| const std::string& type_url = Config::TypeUrl::get().Cluster; | ||
| NiceMock<MockGrpcMuxCallbacks> foo_callbacks; | ||
| auto foo_sub = grpc_mux_->subscribe(type_url, {}, foo_callbacks); | ||
|
|
||
| EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_)); | ||
| expectSendMessage(type_url, {}, ""); | ||
| grpc_mux_->start(); | ||
|
|
||
| { | ||
| std::unique_ptr<envoy::api::v2::DiscoveryResponse> response( | ||
| new envoy::api::v2::DiscoveryResponse()); | ||
| response->set_type_url(type_url); | ||
| response->set_version_info("1"); | ||
| // Validate that onConfigUpdate is called with empty resources. | ||
| EXPECT_CALL(foo_callbacks, onConfigUpdate(_, "1")) | ||
| .WillOnce(Invoke([](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources, | ||
| const std::string&) { EXPECT_TRUE(resources.empty()); })); | ||
| expectSendMessage(type_url, {}, "1"); | ||
| grpc_mux_->onReceiveMessage(std::move(response)); | ||
| } | ||
| } | ||
|
|
||
| // Verifies that warning messages get logged when Envoy detects too many requests. | ||
| TEST_F(GrpcMuxImplTest, TooManyRequests) { | ||
| setup(); | ||
|
|
||
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.
@htuch single watch xDS case is already handled here. So just added a comment to be clear. Also added a test which validates that.