Skip to content
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

Remove select optimization #358

Merged
merged 5 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,6 @@ await CallWithRequestTracing(async () =>

foreach (var loadOption in _options.KeyValueSelectors)
{
if ((useDefaultQuery && LabelFilter.Null.Equals(loadOption.LabelFilter)) ||
_options.KeyValueSelectors.Any(s => s != loadOption &&
string.Equals(s.KeyFilter, KeyFilter.Any) &&
string.Equals(s.LabelFilter, loadOption.LabelFilter)))
{
// This selection was already encapsulated by a wildcard query
// Or would select kvs obtained by a different selector
// We skip it to prevent unnecessary requests
continue;
}

var selector = new SettingSelector
{
KeyFilter = loadOption.KeyFilter,
Expand Down
18 changes: 11 additions & 7 deletions tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,13 @@ public void SkipRefreshIfCacheNotExpired()
[Fact]
public void PreservesDefaultQuery()
{
var response = new MockResponse(200);
response.SetContent(SerializationHelpers.Serialize(new[] { _kv }, TestHelpers.SerializeBatch));
var mockTransport = new MockTransport(req =>
{
var response = new MockResponse(200);
response.SetContent(SerializationHelpers.Serialize(new[] { _kv }, TestHelpers.SerializeBatch));
return response;
});

var mockTransport = new MockTransport(response);
var clientOptions = new ConfigurationClientOptions
{
Transport = mockTransport
Expand All @@ -364,10 +367,11 @@ public void PreservesDefaultQuery()
options.UseFeatureFlags();
}).Build();

MockRequest request = mockTransport.SingleRequest;
bool performedDefaultQuery = mockTransport.Requests.Any(r => r.Uri.PathAndQuery.Contains("/kv/?key=%2A&label=%00"));
bool queriedFeatureFlags = mockTransport.Requests.Any(r => r.Uri.PathAndQuery.Contains(Uri.EscapeDataString(FeatureManagementConstants.FeatureFlagMarker)));

Assert.Contains("/kv/?key=%252A&label=%2500", Uri.EscapeUriString(request.Uri.PathAndQuery));
Assert.DoesNotContain(Uri.EscapeDataString(FeatureManagementConstants.FeatureFlagMarker), request.Uri.PathAndQuery);
Assert.True(performedDefaultQuery);
Assert.True(queriedFeatureFlags);
}

[Fact]
Expand Down Expand Up @@ -423,7 +427,7 @@ public void UsesEtagForFeatureFlagRefresh()
Thread.Sleep(cacheExpirationTimeSpan);

refresher.TryRefreshAsync().Wait();
mockClient.Verify(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()), Times.Exactly(2));
mockClient.Verify(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()), Times.Exactly(3));
}

[Fact]
Expand Down