Skip to content

Commit

Permalink
Merge pull request #631 from Azure/main
Browse files Browse the repository at this point in the history
Merge main to release/stable/v8 for 8.1.1 stable release
  • Loading branch information
amerjusupovic authored Feb 26, 2025
2 parents 4ac0aad + 961cdeb commit 17843ce
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>8.1.0</OfficialVersion>
<OfficialVersion>8.1.1</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>8.1.0</OfficialVersion>
<OfficialVersion>8.1.1</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class AzureAppConfigurationOptions
{
private const int MaxRetries = 2;
private static readonly TimeSpan MaxRetryDelay = TimeSpan.FromMinutes(1);
private static readonly KeyValueSelector DefaultQuery = new KeyValueSelector { KeyFilter = KeyFilter.Any, LabelFilter = LabelFilter.Null };

private List<KeyValueWatcher> _individualKvWatchers = new List<KeyValueWatcher>();
private List<KeyValueWatcher> _ffWatchers = new List<KeyValueWatcher>();
Expand Down Expand Up @@ -159,7 +160,7 @@ public AzureAppConfigurationOptions()
};

// Adds the default query to App Configuration if <see cref="Select"/> and <see cref="SelectSnapshot"/> are never called.
_selectors = new List<KeyValueSelector> { new KeyValueSelector { KeyFilter = KeyFilter.Any, LabelFilter = LabelFilter.Null } };
_selectors = new List<KeyValueSelector> { DefaultQuery };
}

/// <summary>
Expand Down Expand Up @@ -201,7 +202,7 @@ public AzureAppConfigurationOptions Select(string keyFilter, string labelFilter

if (!_selectCalled)
{
_selectors.Clear();
_selectors.Remove(DefaultQuery);

_selectCalled = true;
}
Expand Down Expand Up @@ -229,7 +230,7 @@ public AzureAppConfigurationOptions SelectSnapshot(string name)

if (!_selectCalled)
{
_selectors.Clear();
_selectors.Remove(DefaultQuery);

_selectCalled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ public void ProcessPushNotification(PushNotification pushNotification, TimeSpan?

if (_configClientManager.UpdateSyncToken(pushNotification.ResourceUri, pushNotification.SyncToken))
{
if (_requestTracingEnabled && _requestTracingOptions != null)
{
_requestTracingOptions.IsPushRefreshUsed = true;
}

SetDirty(maxDelay);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal class RequestTracingConstants
public const string LoadBalancingEnabledTag = "LB";
public const string SignalRUsedTag = "SignalR";
public const string FailoverRequestTag = "Failover";
public const string PushRefreshTag = "PushRefresh";

public const string FeatureFlagFilterTypeKey = "Filter";
public const string CustomFilter = "CSTM";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<!-- Nuget Package Version Settings -->

<PropertyGroup>
<OfficialVersion>8.1.0</OfficialVersion>
<OfficialVersion>8.1.1</OfficialVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(CDP_PATCH_NUMBER)'!='' AND '$(CDP_BUILD_TYPE)'=='Official'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ internal class RequestTracingOptions
/// </summary>
public bool IsFailoverRequest { get; set; } = false;

/// <summary>
/// Flag to indicate whether push refresh is used.
/// </summary>
public bool IsPushRefreshUsed { get; set; } = false;

/// <summary>
/// Checks whether any tracing feature is used.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ private static string CreateCorrelationContextHeader(RequestType requestType, Re
correlationContextTags.Add(RequestTracingConstants.FailoverRequestTag);
}

if (requestTracingOptions.IsPushRefreshUsed)
{
correlationContextTags.Add(RequestTracingConstants.PushRefreshTag);
}

var sb = new StringBuilder();

foreach (KeyValuePair<string, string> kvp in correlationContextKeyValues)
Expand Down
57 changes: 57 additions & 0 deletions tests/Tests.AzureAppConfiguration/FeatureManagementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,63 @@ public void SelectFeatureFlags()
Assert.Null(config["FeatureManagement:App2_Feature2"]);
}

[Fact]
public void SelectOrderDoesNotAffectLoad()
{
var mockResponse = new Mock<Response>();
var mockClient = new Mock<ConfigurationClient>(MockBehavior.Strict);

List<ConfigurationSetting> kvCollection = new List<ConfigurationSetting>
{
ConfigurationModelFactory.ConfigurationSetting("TestKey1", "TestValue1", "label",
eTag: new ETag("0a76e3d7-7ec1-4e37-883c-9ea6d0d89e63")),
ConfigurationModelFactory.ConfigurationSetting("TestKey2", "TestValue2", "label",
eTag: new ETag("31c38369-831f-4bf1-b9ad-79db56c8b989"))
};

MockAsyncPageable GetTestKeys(SettingSelector selector, CancellationToken ct)
{
List<ConfigurationSetting> settingCollection;

if (selector.KeyFilter.StartsWith(FeatureManagementConstants.FeatureFlagMarker))
{
settingCollection = _featureFlagCollection;
}
else
{
settingCollection = kvCollection;
}

var copy = new List<ConfigurationSetting>();
var newSetting = settingCollection.FirstOrDefault(s => (s.Key == selector.KeyFilter && s.Label == selector.LabelFilter));
if (newSetting != null)
copy.Add(TestHelpers.CloneSetting(newSetting));
return new MockAsyncPageable(copy);
}

mockClient.Setup(c => c.GetConfigurationSettingsAsync(It.IsAny<SettingSelector>(), It.IsAny<CancellationToken>()))
.Returns((Func<SettingSelector, CancellationToken, MockAsyncPageable>)GetTestKeys);

var config = new ConfigurationBuilder()
.AddAzureAppConfiguration(options =>
{
options.ClientManager = TestHelpers.CreateMockedConfigurationClientManager(mockClient.Object);
options.UseFeatureFlags(ff =>
{
ff.Select("App1_Feature1", "App1_Label");
ff.Select("App2_Feature1", "App2_Label");
});
options.Select("TestKey1", "label");
options.Select("TestKey2", "label");
})
.Build();

Assert.Equal("True", config["FeatureManagement:App1_Feature1"]);
Assert.Equal("False", config["FeatureManagement:App2_Feature1"]);
Assert.Equal("TestValue1", config["TestKey1"]);
Assert.Equal("TestValue2", config["TestKey2"]);
}

[Fact]
public void TestNullAndMissingValuesForConditions()
{
Expand Down

0 comments on commit 17843ce

Please sign in to comment.