From 8c800fbd0fa54321952f0324f2084cdbdde3dd47 Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 2 Nov 2015 14:36:47 -0800 Subject: [PATCH] Rearranging test port allocations to avoid test race conditions #152 --- .../Utilities.cs | 3 +++ .../Microsoft.Net.Http.Server.FunctionalTests/Utilities.cs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/Utilities.cs b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/Utilities.cs index 31eb61ea07..d3440800bd 100644 --- a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/Utilities.cs +++ b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/Utilities.cs @@ -27,6 +27,9 @@ namespace Microsoft.AspNet.Server.WebListener { internal static class Utilities { + // When tests projects are run in parallel, overlapping port ranges can cause a race condition when looking for free + // ports during dynamic port allocation. To avoid this, make sure the port range here is different from the range in + // Microsoft.Net.Http.Server. private const int BasePort = 5001; private const int MaxPort = 8000; private static int NextPort = BasePort; diff --git a/test/Microsoft.Net.Http.Server.FunctionalTests/Utilities.cs b/test/Microsoft.Net.Http.Server.FunctionalTests/Utilities.cs index fd732e11a4..c8bad49ad6 100644 --- a/test/Microsoft.Net.Http.Server.FunctionalTests/Utilities.cs +++ b/test/Microsoft.Net.Http.Server.FunctionalTests/Utilities.cs @@ -6,8 +6,11 @@ namespace Microsoft.Net.Http.Server { internal static class Utilities { - private const int BasePort = 5001; - private const int MaxPort = 8000; + // When tests projects are run in parallel, overlapping port ranges can cause a race condition when looking for free + // ports during dynamic port allocation. To avoid this, make sure the port range here is different from the range in + // Microsoft.AspNet.Server.WebListener. + private const int BasePort = 8001; + private const int MaxPort = 11000; private static int NextPort = BasePort; private static object PortLock = new object();