Skip to content

Commit

Permalink
addressed PR feedback, added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bachuv committed Nov 14, 2024
1 parent b194d21 commit 18f03dd
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

### New Features

- Update MaxQueuePollingInterval default for Flex Consumption apps #2953

### Bug Fixes

### Breaking Changes
Expand Down
19 changes: 13 additions & 6 deletions src/WebJobs.Extensions.DurableTask/Options/AzureStorageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,26 @@ public string TrackingStoreConnectionStringName

/// <summary>
/// Gets or sets the maximum queue polling interval.
/// We update the default value to 1 second for the Flex Consumption SKU
/// because of a known cold start latency with Flex Consumption
/// and Durable Functions.
/// The default value is 30 seconds for all other SKUs.
/// </summary>
/// <value>Maximum interval for polling control and work-item queues.</value>
public TimeSpan MaxQueuePollingInterval
{
get
{
if (string.Equals(Environment.GetEnvironmentVariable("WEBSITE_SKU"), "FlexConsumption", StringComparison.OrdinalIgnoreCase))
if (this.maxQueuePollingInterval == TimeSpan.Zero)
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(1);
}
else
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(30);
if (string.Equals(Environment.GetEnvironmentVariable("WEBSITE_SKU"), "FlexConsumption", StringComparison.OrdinalIgnoreCase))
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(1);
}
else
{
this.maxQueuePollingInterval = TimeSpan.FromSeconds(30);
}
}

return this.maxQueuePollingInterval;
Expand Down
56 changes: 56 additions & 0 deletions test/FunctionsV2/AzureStorageOptionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;

Check warning on line 1 in test/FunctionsV2/AzureStorageOptionsTests.cs

View workflow job for this annotation

GitHub Actions / build

The file header is missing or not located at the top of the file. (/~https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md)

Check warning on line 1 in test/FunctionsV2/AzureStorageOptionsTests.cs

View workflow job for this annotation

GitHub Actions / build

The file header is missing or not located at the top of the file. (/~https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md)

Check warning on line 1 in test/FunctionsV2/AzureStorageOptionsTests.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The file header is missing or not located at the top of the file. (/~https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md)

Check warning on line 1 in test/FunctionsV2/AzureStorageOptionsTests.cs

View workflow job for this annotation

GitHub Actions / build

The file header is missing or not located at the top of the file. (/~https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md)

Check warning on line 1 in test/FunctionsV2/AzureStorageOptionsTests.cs

View workflow job for this annotation

GitHub Actions / build

The file header is missing or not located at the top of the file. (/~https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md)
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests
{
public class AzureStorageOptionsTests
{
#if !FUNCTIONS_V1
[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_NonFlexConsumption_DefaultValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "Free");

var options = new AzureStorageOptions();
Assert.Equal(TimeSpan.FromSeconds(30), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_NonFlexConsumption_SetCustomValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "Free");

var options = new AzureStorageOptions();
options.MaxQueuePollingInterval = TimeSpan.FromSeconds(4);
Assert.Equal(TimeSpan.FromSeconds(4), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_FlexConsumption_DefaultValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "FlexConsumption");

var options = new AzureStorageOptions();
Assert.Equal(TimeSpan.FromSeconds(1), options.MaxQueuePollingInterval);
}

[Fact]
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void MaxQueuePollingInterval_FlexConsumption_SetCustomValue()
{
Environment.SetEnvironmentVariable("WEBSITE_SKU", "FlexConsumption");

var options = new AzureStorageOptions();
options.MaxQueuePollingInterval = TimeSpan.FromSeconds(6);
Assert.Equal(TimeSpan.FromSeconds(6), options.MaxQueuePollingInterval);
}
#endif
}
}

0 comments on commit 18f03dd

Please sign in to comment.