-
Notifications
You must be signed in to change notification settings - Fork 5.5k
config: Remove entries from initial resource versions map #6320
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f859135
remove removed resources from initial resource versions map
fredlas 61dcd2d
Merge remote-tracking branch 'upstream/master' into REM_fix_removed
fredlas ab1dfba
also update resource_names_, now using helper fns
fredlas 11fde72
add test checking removal from initial versions map
fredlas 9fcf00b
Merge remote-tracking branch 'upstream/master' into REM_fix_removed
fredlas 44904d7
unused using
fredlas f452fc0
snapshot
fredlas 2d9a1a5
Merge remote-tracking branch 'upstream/master' into REM_fix_removed
fredlas 2435536
fix not informing server of lost interest, use test harness
fredlas 9be733e
Merge remote-tracking branch 'upstream/master' into REM_fix_removed
fredlas 5054932
make a certain expectation more thorough
fredlas 35a6f49
fix format
fredlas 65dc1b7
replace EmptyVersion with new ResourceVersion helper class
fredlas 25da0c6
Merge remote-tracking branch 'upstream/master' into REM_fix_removed
fredlas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #include <memory> | ||
|
|
||
| #include "common/config/delta_subscription_impl.h" | ||
| #include "common/config/utility.h" | ||
| #include "common/stats/isolated_store_impl.h" | ||
|
|
||
| #include "test/mocks/common.h" | ||
| #include "test/mocks/config/mocks.h" | ||
| #include "test/mocks/event/mocks.h" | ||
| #include "test/mocks/grpc/mocks.h" | ||
| #include "test/mocks/local_info/mocks.h" | ||
| #include "test/mocks/runtime/mocks.h" | ||
| #include "test/test_common/logging.h" | ||
| #include "test/test_common/test_time.h" | ||
| #include "test/test_common/utility.h" | ||
|
|
||
| #include "gmock/gmock.h" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| using testing::NiceMock; | ||
|
|
||
| namespace Envoy { | ||
| namespace Config { | ||
| namespace { | ||
|
|
||
| TEST(DeltaSubscriptionImplTest, ResourceGoneLeadsToBlankInitialVersion) { | ||
|
fredlas marked this conversation as resolved.
Outdated
|
||
| NiceMock<Event::MockDispatcher> dispatcher; | ||
| NiceMock<Runtime::MockRandomGenerator> random; | ||
| Envoy::Config::RateLimitSettings rate_limit_settings; | ||
| Stats::IsolatedStoreImpl stats_store; | ||
| SubscriptionStats stats = Utility::generateStats(stats_store); | ||
| NiceMock<Config::MockSubscriptionCallbacks<envoy::api::v2::ClusterLoadAssignment>> callbacks; | ||
| envoy::api::v2::core::Node node; | ||
| node.set_id("fo0"); | ||
| NiceMock<LocalInfo::MockLocalInfo> local_info; | ||
| EXPECT_CALL(local_info, node()).WillRepeatedly(testing::ReturnRef(node)); | ||
|
|
||
| DeltaSubscriptionImpl<envoy::api::v2::ClusterLoadAssignment> subscription( | ||
| local_info, std::make_unique<NiceMock<Grpc::MockAsyncClient>>(), dispatcher, | ||
| *Protobuf::DescriptorPool::generated_pool()->FindMethodByName( | ||
| "envoy.api.v2.EndpointDiscoveryService.StreamEndpoints"), | ||
| random, stats_store, rate_limit_settings, stats, std::chrono::milliseconds(123)); | ||
|
|
||
| subscription.start({"name1", "name2"}, callbacks); | ||
|
|
||
| Protobuf::RepeatedPtrField<envoy::api::v2::Resource> added; | ||
| auto* resource = added.Add(); | ||
| resource->set_name("name1"); | ||
| resource->set_version("version1A"); | ||
| resource = added.Add(); | ||
| resource->set_name("name2"); | ||
| resource->set_version("version2A"); | ||
| subscription.onConfigUpdate(added, {}, "debugversion1"); | ||
| subscription.handleStreamEstablished(); | ||
| envoy::api::v2::DeltaDiscoveryRequest cur_request = subscription.stateOfRequest(); | ||
| EXPECT_EQ("version1A", cur_request.initial_resource_versions().at("name1")); | ||
| EXPECT_EQ("version2A", cur_request.initial_resource_versions().at("name2")); | ||
|
|
||
| Protobuf::RepeatedPtrField<std::string> removed1; | ||
| *removed1.Add() = "name1"; | ||
| subscription.onConfigUpdate({}, removed1, "debugversion2"); | ||
| subscription.handleStreamEstablished(); | ||
| cur_request = subscription.stateOfRequest(); | ||
| EXPECT_EQ(cur_request.initial_resource_versions().end(), | ||
| cur_request.initial_resource_versions().find("name1")); | ||
| EXPECT_EQ("version2A", cur_request.initial_resource_versions().at("name2")); | ||
|
|
||
| Protobuf::RepeatedPtrField<std::string> removed2; | ||
| *removed2.Add() = "name2"; | ||
| subscription.onConfigUpdate({}, removed2, "debugversion3"); | ||
| subscription.handleStreamEstablished(); | ||
| cur_request = subscription.stateOfRequest(); | ||
| EXPECT_EQ(cur_request.initial_resource_versions().end(), | ||
| cur_request.initial_resource_versions().find("name1")); | ||
| EXPECT_EQ(cur_request.initial_resource_versions().end(), | ||
| cur_request.initial_resource_versions().find("name2")); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace Config | ||
| } // namespace Envoy | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.