From 1559b7c38737c4e7063531f61a6c1ebcd20eae50 Mon Sep 17 00:00:00 2001 From: Hai Cao Date: Tue, 13 Dec 2022 15:01:01 -0800 Subject: [PATCH] Make ParallelMessageProcessingTest stable by loose the assertion (#1786) --- .../Messaging/MessageDispatcherTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Messaging/MessageDispatcherTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Messaging/MessageDispatcherTests.cs index e1d6e304..54633430 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Messaging/MessageDispatcherTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/Messaging/MessageDispatcherTests.cs @@ -93,11 +93,11 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Messaging int numOfRequests = 10; int msForEachRequest = 1000; // Without parallel processing, this should take around numOfRequests * msForEachRequest ms to finish. - // With parallel process, this should take around 1 * msForEachRequest ms to finish. - // The diff should be around (numOfRequests - 1) * msForEachRequest ms. - // In order to make this test stable, we loose the assertion by checking the diff against - // (numOfRequests / 2) * msForEachRequest ms, which should for sure pass. - Assert.IsTrue(GetTimeToHandleRequests(false, numOfRequests, msForEachRequest) - GetTimeToHandleRequests(true, numOfRequests, msForEachRequest) > msForEachRequest * (numOfRequests / 2)); + // With parallel process, this should take around 1 * msForEachRequest ms to finish in theory (with perfect parallelism). + // The diff should in theory be around (numOfRequests - 1) * msForEachRequest ms. + // In order to make this test stable on machines with poor hardware / few logical cores, + // we loose the assertion by only checking parallel process being faster than sequential processing. + Assert.IsTrue(GetTimeToHandleRequests(false, numOfRequests, msForEachRequest) > GetTimeToHandleRequests(true, numOfRequests, msForEachRequest)); }