Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cgillum committed Nov 15, 2024
1 parent 8359496 commit 14a6a20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,15 @@ public DurableTaskScaleMonitor(
this.performanceMonitor = performanceMonitor;
this.durableTaskMetricsProvider = durableTaskMetricsProvider;

string id = $"DurableTaskTrigger-{this.hubName}".ToLower();
#if FUNCTIONS_V3_OR_GREATER
// Scalers in Durable Functions are shared for all functions in the same task hub.
// So instead of using a function ID, we use the task hub name as the basis for the descriptor ID.
string id = $"DurableTask-AzureStorage:{hubName ?? "default"}";
this.scaleMonitorDescriptor = new ScaleMonitorDescriptor(id: id, functionId: id);
#else
#pragma warning disable CS0618 // Type or member is obsolete.

// We need this because the new ScaleMonitorDescriptor constructor is not compatible with the WebJobs version of Functions V1 and V2.
// Technically, it is also not available in Functions V3, but we don't have a TFM allowing us to differentiate between Functions V3 and V4.
this.scaleMonitorDescriptor = new ScaleMonitorDescriptor($"DurableTaskTrigger-{this.hubName}".ToLower());
#pragma warning restore CS0618 // Type or member is obsolete. However, the new interface is not compatible with Functions V2 and V1
this.scaleMonitorDescriptor = new ScaleMonitorDescriptor(id);
#endif
}

Expand Down
7 changes: 1 addition & 6 deletions test/FunctionsV2/DurableTaskScaleMonitorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask.Tests
{
public class DurableTaskScaleMonitorTests
{
private readonly string functionId = "DurableTaskTriggerFunctionId";
private readonly FunctionName functionName = new FunctionName("DurableTaskTriggerFunctionName");
private readonly string hubName = "DurableTaskTriggerHubName";
private readonly CloudStorageAccount storageAccount = CloudStorageAccount.Parse(TestHelpers.GetStorageConnectionString());
private readonly ITestOutputHelper output;
Expand All @@ -41,15 +39,12 @@ public DurableTaskScaleMonitorTests(ITestOutputHelper output)
this.traceHelper = new EndToEndTraceHelper(logger, false);
this.performanceMonitor = new Mock<DisconnectedPerformanceMonitor>(MockBehavior.Strict, this.storageAccount, this.hubName, (int?)null);
var metricsProvider = new DurableTaskMetricsProvider(
this.functionName.Name,
this.hubName,
logger,
this.performanceMonitor.Object,
this.storageAccount);

this.scaleMonitor = new DurableTaskScaleMonitor(
this.functionId,
this.functionName.Name,
this.hubName,
this.storageAccount,
logger,
Expand All @@ -61,7 +56,7 @@ public DurableTaskScaleMonitorTests(ITestOutputHelper output)
[Trait("Category", PlatformSpecificHelpers.TestCategory)]
public void ScaleMonitorDescriptor_ReturnsExpectedValue()
{
Assert.Equal($"{this.functionId}-DurableTaskTrigger-{this.hubName}".ToLower(), this.scaleMonitor.Descriptor.Id);
Assert.Equal($"DurableTaskTrigger-{this.hubName}".ToLower(), this.scaleMonitor.Descriptor.Id);
}

[Fact]
Expand Down

0 comments on commit 14a6a20

Please sign in to comment.