Skip to content

Commit

Permalink
Attempt fix GetMetrics_ReturnsExpectedResult failing in live tests (#…
Browse files Browse the repository at this point in the history
…34356)

* Attempt to fix live tests for GetMetrics tests from Target Based Scaling for Queues

* Remove unncessary packages

* Change test queue from mock queue to fixture queue

* Change metric provider constructor to only change for the success metrics test

* Correcting test to use fixture queue

* Removing duplicate queues for same tests

* shorter queue name
  • Loading branch information
amnguye authored Feb 21, 2023
1 parent 5393103 commit e95e59b
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit e95e59b

Please sign in to comment.