Add QueryParameters option to AWS CloudMap-based peer discovery#1560
Conversation
…er discovery Signed-off-by: Chase Engelbrecht <engechas@amazon.com>
…E wording to be a bit more specific Signed-off-by: Chase Engelbrecht <engechas@amazon.com>
Signed-off-by: Chase Engelbrecht <engechas@amazon.com>
Codecov Report
@@ Coverage Diff @@
## main #1560 +/- ##
=========================================
Coverage 94.18% 94.18%
Complexity 1181 1181
=========================================
Files 165 165
Lines 3386 3386
Branches 277 277
=========================================
Hits 3189 3189
Misses 141 141
Partials 56 56 Continue to review full report at Codecov.
|
| private static Map<String, String> getOptionalSettingMap(final PluginSetting pluginSetting, final String propertyName) { | ||
| final Map<String, String> propertyValue = pluginSetting.getTypedMap(propertyName, String.class, String.class); | ||
|
|
||
| if (propertyValue == null) { |
There was a problem hiding this comment.
Out of scope for PR: We should eliminate null checks by enforcing a default value in the PluginSettings or allow calling classes to specify the default. Raising: #1563
…case for QueryParameters missing from PluginSetting in AwsCloudMapPeerListProvider_CreateTest Signed-off-by: Chase Engelbrecht <engechas@amazon.com>
| void createPeerListProvider_with_missing_optional_map_property(final String propertyToRemove) { | ||
| pluginSetting.getSettings().remove(propertyToRemove); | ||
|
|
||
| final PeerListProvider result = AwsCloudMapPeerListProvider.createPeerListProvider(pluginSetting, pluginMetrics); |
There was a problem hiding this comment.
Thanks! This is the bit of code that I was hoping to test.
The only missing part is to verify that a subsequent call to the AWS SDK has an empty map.
There was a problem hiding this comment.
The ServiceDiscoveryAsyncClient is created as a local variable in the createPeerListProvider so there's not a good way to mock it in this flow without introducing PowerMock as a new dependency or a decent chunk of refactoring.
I will drop the private scope from the getOptionalSettingMap to test the various scenarios while keeping this PR minimal.
There was a problem hiding this comment.
OK. I'm fine with keeping this as it is for now.
…search-project#1560) * Implement QueryParameters filter option for AWS CloudMap peer forwarder discovery Signed-off-by: Chase Engelbrecht <engechas@amazon.com> * Small fixes related to import statements and unit tests. Update README wording to be a bit more specific Signed-off-by: Chase Engelbrecht <engechas@amazon.com> * Adding some asserts to unit tests Signed-off-by: Chase Engelbrecht <engechas@amazon.com> * Randomize map generation in AwsCloudMapPeerListProvider and add test case for QueryParameters missing from PluginSetting in AwsCloudMapPeerListProvider_CreateTest Signed-off-by: Chase Engelbrecht <engechas@amazon.com> Signed-off-by: Finn Roblin <finnrobl@amazon.com>
Description
This PR adds
awsCloudMapQueryParametersas an optional setting when using AWS CloudMap for peer discovery. The implementation accepts aMap<String, String>which is passed directly to thequeryParametersfield of theDiscoverInstancesRequest.Documentation on this field: https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/servicediscovery/model/DiscoverInstancesRequest.Builder.html#queryParameters-java.util.Map-
Testing
AWS CloudMap service contents:
Testing no filters
pipelines.yaml:
Logs:
Testing filter has match:
pipelines.yaml:
Logs:
Testing filter has no matches
pipelines.yaml:
Logs:
Testing blank entry
pipelines.yaml:
Logs:
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.