Skip to content

Commit

Permalink
Longer timeout for tests (#5102)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Jun 17, 2024
1 parent 8456930 commit 4046b99
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client;
[TestClass]
public class ParallelProxyDiscoveryManagerTests
{
private const int Timeout3Seconds = 3 * 1000;
private const int Timeout10Seconds = 10 * 1000;
private readonly Queue<Mock<IProxyDiscoveryManager>> _preCreatedMockManagers;
private readonly List<Mock<IProxyDiscoveryManager>> _usedMockManagers;
private readonly Func<TestRuntimeProviderInfo, DiscoveryCriteria, IProxyDiscoveryManager> _createMockManager;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void DiscoverTestsShouldProcessAllSources()
var parallelDiscoveryManager = SetupDiscoveryManager(_createMockManager, 2, false);

var task = Task.Run(() => parallelDiscoveryManager.DiscoverTests(_discoveryCriteriaWith2Sources, _mockEventHandler.Object));
var discoveryCompleted = _discoveryCompleted.Wait(Timeout3Seconds);
var discoveryCompleted = _discoveryCompleted.Wait(Timeout10Seconds);

if (task.IsCompleted)
{
Expand Down Expand Up @@ -214,7 +214,7 @@ public void DiscoveryTestsShouldStopDiscoveryIfAbortionWasRequested()
parallelDiscoveryManager.Abort();
});

Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
Assert.AreEqual(1, _processedSources.Count, "One source should be processed.");
}

Expand All @@ -232,7 +232,7 @@ public void DiscoveryTestsShouldStopDiscoveryIfAbortionWithEventHandlerWasReques
parallelDiscoveryManager.Abort(_mockEventHandler.Object);
});

Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
Assert.AreEqual(1, _processedSources.Count, "One source should be processed.");
}

Expand All @@ -252,7 +252,7 @@ public void DiscoveryTestsShouldProcessAllSourceIfOneDiscoveryManagerIsStarved()
Task.Run(() => parallelDiscoveryManager.DiscoverTests(_discoveryCriteriaWith2Sources, _mockEventHandler.Object));

// Processed sources should be 1 since the 2nd source is never discovered
Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
Assert.AreEqual(1, _processedSources.Count, "All Sources must be processed.");
}

Expand All @@ -272,7 +272,7 @@ public void DiscoveryTestsShouldCatchExceptionAndHandleLogMessageOfError()
Task.Run(() => parallelDiscoveryManager.DiscoverTests(_discoveryCriteriaWith2Sources, _mockEventHandler.Object));

// Processed sources should be 1 since the 2nd source is never discovered
Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
_mockEventHandler.Verify(s => s.HandleLogMessage(TestMessageLevel.Error, It.IsAny<string>()), Times.Once);
}

Expand All @@ -292,7 +292,7 @@ public void DiscoveryTestsShouldCatchExceptionAndHandleRawMessageOfTestMessage()
Task.Run(() => parallelDiscoveryManager.DiscoverTests(_discoveryCriteriaWith2Sources, _mockEventHandler.Object));

// Processed sources should be 1 since the 2nd source is never discovered
Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
_mockEventHandler.Verify(s => s.HandleRawMessage(It.Is<string>(str => str.Contains(MessageType.TestMessage))));
}

Expand Down Expand Up @@ -324,7 +324,7 @@ public void DiscoveryTestsWithCompletionMarksAllSourcesAsFullyDiscovered()

Task.Run(() => parallelDiscoveryManager.DiscoverTests(_discoveryCriteriaWith2Sources, _mockEventHandler.Object));

Assert.IsTrue(_discoveryCompleted.Wait(Timeout3Seconds), "Test discovery not completed.");
Assert.IsTrue(_discoveryCompleted.Wait(Timeout10Seconds), "Test discovery not completed.");
Assert.AreEqual(_sources.Count, _processedSources.Count, "All Sources must be processed.");
CollectionAssert.AreEquivalent(_sources, _dataAggregator.GetSourcesWithStatus(DiscoveryStatus.FullyDiscovered));
Assert.AreEqual(0, _dataAggregator.GetSourcesWithStatus(DiscoveryStatus.PartiallyDiscovered).Count);
Expand Down

0 comments on commit 4046b99

Please sign in to comment.