-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathTargetBasedScalingTests.cs
56 lines (46 loc) · 1.91 KB
/
TargetBasedScalingTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
namespace DurableTask.SqlServer.AzureFunctions.Tests
{
using DurableTask.Core;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Host.Scale;
using Moq;
using Xunit;
public class TargetBasedScalingTests
{
readonly Mock<SqlMetricsProvider> metricsProviderMock;
readonly Mock<IOrchestrationService> orchestrationServiceMock;
public TargetBasedScalingTests()
{
this.orchestrationServiceMock = new Mock<IOrchestrationService>(MockBehavior.Strict);
SqlOrchestrationService? nullServiceArg = null; // not needed for this test
this.metricsProviderMock = new Mock<SqlMetricsProvider>(
behavior: MockBehavior.Strict,
nullServiceArg);
}
[Theory]
[InlineData(0)]
[InlineData(10)]
[InlineData(20)]
public async void TargetBasedScalingTest(int expectedTargetWorkerCount)
{
var durabilityProviderMock = new Mock<DurabilityProvider>(
MockBehavior.Strict,
"storageProviderName",
this.orchestrationServiceMock.Object,
new Mock<IOrchestrationServiceClient>().Object,
"connectionName");
var sqlScaleMetric = new SqlScaleMetric()
{
RecommendedReplicaCount = expectedTargetWorkerCount,
};
this.metricsProviderMock.Setup(m => m.GetMetricsAsync(null)).ReturnsAsync(sqlScaleMetric);
var targetScaler = new SqlTargetScaler(
"functionId",
this.metricsProviderMock.Object);
TargetScalerResult result = await targetScaler.GetScaleResultAsync(new TargetScalerContext());
Assert.Equal(expectedTargetWorkerCount, result.TargetWorkerCount);
}
}
}