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

Attempt fix GetMetrics_ReturnsExpectedResult failing in live tests #34356

Merged
merged 7 commits into from
Feb 21, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void SetUp()
_loggerProvider = new TestLoggerProvider();
_loggerFactory.AddProvider(_loggerProvider);
_mockQueue = new Mock<QueueClient>(new Uri("https://test.queue.core.windows.net/testqueue"), new QueueClientOptions());
_mockQueue.Setup(x => x.Name).Returns("testqueue");
_metricsProvider = new QueueMetricsProvider(_mockQueue.Object, _loggerFactory);
}

Expand All @@ -53,7 +54,8 @@ public void OneTimeTearDown()
[Test]
public async Task GetMetrics_ReturnsExpectedResult()
{
var metrics = await _metricsProvider.GetMetricsAsync();
QueueMetricsProvider _provider = new QueueMetricsProvider(Fixture.Queue, _loggerFactory);
var metrics = await _provider.GetMetricsAsync();

Assert.AreEqual(0, metrics.QueueLength);
Assert.AreEqual(TimeSpan.Zero, metrics.QueueTime);
Expand All @@ -67,14 +69,14 @@ public async Task GetMetrics_ReturnsExpectedResult()

await Task.Delay(TimeSpan.FromSeconds(5));

metrics = await _metricsProvider.GetMetricsAsync();
metrics = await _provider.GetMetricsAsync();

Assert.AreEqual(5, metrics.QueueLength);
Assert.True(metrics.QueueTime.Ticks > 0);
Assert.AreNotEqual(default(DateTime), metrics.Timestamp);

// verify non-generic interface works as expected
metrics = (QueueTriggerMetrics)(await _metricsProvider.GetMetricsAsync());
metrics = (QueueTriggerMetrics)(await _provider.GetMetricsAsync());
Assert.AreEqual(5, metrics.QueueLength);
}

Expand All @@ -101,7 +103,7 @@ public async Task GetMetrics_HandlesStorageExceptions()

public class TestFixture : IDisposable
{
private const string TestQueuePrefix = "queuelistenertests";
private const string TestQueuePrefix = "metrictests";

public TestFixture()
{
Expand Down