diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs
new file mode 100644
index 0000000000..99b2621f38
--- /dev/null
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/CommunicationEndpointFactory.cs
@@ -0,0 +1,30 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities
+{
+ using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
+ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
+
+ ///
+ /// Implements ICommunicationEndpointFactory.
+ ///
+ public class CommunicationEndpointFactory : ICommunicationEndpointFactory
+ {
+ ///
+ public ICommunicationEndPoint Create(ConnectionRole role)
+ {
+ ICommunicationEndPoint endPoint;
+ if (role == ConnectionRole.Host)
+ {
+ endPoint = new SocketServer();
+ }
+ else
+ {
+ endPoint = new SocketClient();
+ }
+
+ return endPoint;
+ }
+ }
+}
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs
index ba4aa8c356..d9102a7665 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/DataCollectionRequestHandler.cs
@@ -5,11 +5,12 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollect
{
using System;
using System.Collections.Generic;
+ using System.Globalization;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
-
+ using CoreUtilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Common;
using Microsoft.VisualStudio.TestPlatform.Common.DataCollection;
using Microsoft.VisualStudio.TestPlatform.Common.DataCollector;
@@ -25,15 +26,14 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollect
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
+ using CommunicationUtilitiesResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources;
+ using CoreUtilitiesConstants = Microsoft.VisualStudio.TestPlatform.CoreUtilities.Constants;
+
///
/// Handles test session events received from vstest console process.
///
internal class DataCollectionRequestHandler : IDataCollectionRequestHandler, IDisposable
{
- // On Slower Machines(hosted agents) with Profiling enabled 15secs is not enough for testhost to get started(weird right!!),
- // hence increasing this timeout
- private const int DataCollectionCommTimeOut = 60 * 1000;
-
private static readonly object SyncObject = new object();
private readonly ICommunicationManager communicationManager;
@@ -294,21 +294,30 @@ private void HandleBeforeTestRunStart(Message message)
{
try
{
+ var timeout = EnvironmentHelper.GetConnectionTimeout();
if (this.dataCollectionTestCaseEventHandler.WaitForRequestHandlerConnection(
- DataCollectionCommTimeOut))
+ timeout * 1000))
{
this.dataCollectionTestCaseEventHandler.ProcessRequests();
}
else
{
- EqtTrace.Error("DataCollectionRequestHandler.ProcessRequests: TestCaseEventHandler timed out while connecting to the Sender.");
+ EqtTrace.Error(
+ "DataCollectionRequestHandler.HandleBeforeTestRunStart: TestCaseEventHandler timed out while connecting to the Sender.");
this.dataCollectionTestCaseEventHandler.Close();
- throw new TimeoutException();
+ throw new TestPlatformException(
+ string.Format(
+ CultureInfo.CurrentUICulture,
+ CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage,
+ CoreUtilitiesConstants.DatacollectorProcessName,
+ CoreUtilitiesConstants.TesthostProcessName,
+ timeout,
+ EnvironmentHelper.VstestConnectionTimeout));
}
}
catch (Exception e)
{
- EqtTrace.Error("DataCollectionRequestHandler.ProcessRequests : Error occured during initialization of TestHost : {0}", e);
+ EqtTrace.Error("DataCollectionRequestHandler.HandleBeforeTestRunStart : Error occured during initialization of TestHost : {0}", e);
}
},
this.cancellationTokenSource.Token);
@@ -337,7 +346,7 @@ private void HandleAfterTestRunEnd(Message message)
}
catch (Exception ex)
{
- EqtTrace.Error("DataCollectionRequestHandler.ProcessRequests : {0}", ex.ToString());
+ EqtTrace.Error("DataCollectionRequestHandler.HandleAfterTestRunEnd : Error while processing event from testhost: {0}", ex.ToString());
}
var attachmentsets = this.dataCollectionManager.SessionEnded(isCancelled);
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Friends.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Friends.cs
index 0e55268a01..bdd70c6c18 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Friends.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Friends.cs
@@ -11,4 +11,5 @@
[assembly: InternalsVisibleTo("datacollector, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("datacollector.PlatformTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
+[assembly: InternalsVisibleTo("datacollector.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
\ No newline at end of file
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs
new file mode 100644
index 0000000000..4fc2630b12
--- /dev/null
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ICommunicationEndpointFactory.cs
@@ -0,0 +1,17 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
+{
+ using TestPlatform.ObjectModel;
+
+ public interface ICommunicationEndpointFactory
+ {
+ ///
+ /// Create communication endpoint.
+ ///
+ /// Endpoint role.
+ /// Return communication endpoint object.
+ ICommunicationEndPoint Create(ConnectionRole role);
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs
index ba51d1b556..e73d69ef8e 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/IDataCollectionTestCaseEventSender.cs
@@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
///
/// Interface for sending test case events from test execution process to data collection process
///
- internal interface IDataCollectionTestCaseEventSender
+ public interface IDataCollectionTestCaseEventSender
{
///
/// Setups client based on port
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs
index f8a2f146ad..e15bb9a203 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Interfaces/ITestRequestHandler.cs
@@ -3,6 +3,7 @@
namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
{
+ using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
@@ -13,8 +14,13 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
///
/// Defines the contract for handling test platform requests
///
- public interface ITestRequestHandler
+ public interface ITestRequestHandler : IDisposable
{
+ ///
+ /// Gets or sets connection info for to start server/client.
+ ///
+ TestHostConnectionInfo ConnectionInfo { get; set; }
+
///
/// Setups client based on port
///
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj b/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj
index d628ab72d1..2e7ec2d4d4 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Microsoft.TestPlatform.CommunicationUtilities.csproj
@@ -39,10 +39,16 @@
- ResXFileCodeGenerator
+ PublicResXFileCodeGeneratorResources.Designer.cs
+
+
+ PublicResXFileCodeGenerator
+ Resources.Designer.cs
+
+ 1621415e-7723-4f46-a589-4c4620c0751a
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs
index 51df712ef3..a2f1fef914 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.Designer.cs
@@ -20,10 +20,10 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
+ public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
@@ -37,7 +37,7 @@ internal Resources() {
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
+ public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly);
@@ -52,7 +52,7 @@ internal Resources() {
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
+ public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -62,18 +62,18 @@ internal Resources() {
}
///
- /// Looks up a localized string similar to The active Test Discovery was aborted. Due to {0}.
+ /// Looks up a localized string similar to The active test discovery was aborted. Reason: {0}.
///
- internal static string AbortedTestDiscovery {
+ public static string AbortedTestDiscovery {
get {
return ResourceManager.GetString("AbortedTestDiscovery", resourceCulture);
}
}
///
- /// Looks up a localized string similar to The active Test Run was aborted. Due to {0}.
+ /// Looks up a localized string similar to The active test run was aborted. Reason: {0}.
///
- internal static string AbortedTestRun {
+ public static string AbortedTestRun {
get {
return ResourceManager.GetString("AbortedTestRun", resourceCulture);
}
@@ -82,16 +82,25 @@ internal static string AbortedTestRun {
///
/// Looks up a localized string similar to An existing connection was forcibly closed by the remote host..
///
- internal static string ConnectionClosed {
+ public static string ConnectionClosed {
get {
return ResourceManager.GetString("ConnectionClosed", resourceCulture);
}
}
///
- /// Looks up a localized string similar to Unable to communicate with test execution process..
+ /// Looks up a localized string similar to {0} process failed to connect to {1} process after {2} seconds. This may occur due to machine slowness, please set environment variable {3} to increase timeout..
///
- internal static string UnableToCommunicateToTestHost {
+ public static string ConnectionTimeoutErrorMessage {
+ get {
+ return ResourceManager.GetString("ConnectionTimeoutErrorMessage", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Unable to communicate with test host process..
+ ///
+ public static string UnableToCommunicateToTestHost {
get {
return ResourceManager.GetString("UnableToCommunicateToTestHost", resourceCulture);
}
@@ -100,32 +109,26 @@ internal static string UnableToCommunicateToTestHost {
///
/// Looks up a localized string similar to Unexpected message received. Expected MessageType : {0} Actual MessageType: {1}.
///
- internal static string UnexpectedMessage
- {
- get
- {
+ public static string UnexpectedMessage {
+ get {
return ResourceManager.GetString("UnexpectedMessage", resourceCulture);
}
}
-
+
///
/// Looks up a localized string similar to Protocol version check failed. Make sure test runner and host are compatible..
///
- internal static string VersionCheckFailed
- {
- get
- {
+ public static string VersionCheckFailed {
+ get {
return ResourceManager.GetString("VersionCheckFailed", resourceCulture);
}
}
-
+
///
- /// Looks up a localized string similar to Failed to negotiate protocol. Wait for response timed out.
+ /// Looks up a localized string similar to Failed to negotiate protocol, waiting for response timed out after {0} seconds. This may occur due to machine slowness, please set environment variable {1} to increase timeout..
///
- internal static string VersionCheckTimedout
- {
- get
- {
+ public static string VersionCheckTimedout {
+ get {
return ResourceManager.GetString("VersionCheckTimedout", resourceCulture);
}
}
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.resx b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.resx
index 1defecfd8c..48f90d1d97 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.resx
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/Resources.resx
@@ -136,6 +136,9 @@
Protocol version check failed. Make sure test runner and host are compatible.
- Failed to negotiate protocol. Wait for response timed out.
+ Failed to negotiate protocol, waiting for response timed out after {0} seconds. This may occur due to machine slowness, please set environment variable {1} to increase timeout.
+
+
+ {0} process failed to connect to {1} process after {2} seconds. This may occur due to machine slowness, please set environment variable {3} to increase timeout.
\ No newline at end of file
diff --git a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/xlf/Resources.cs.xlf b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/xlf/Resources.cs.xlf
index bed798d669..7baa1c0063 100644
--- a/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/xlf/Resources.cs.xlf
+++ b/src/Microsoft.TestPlatform.CommunicationUtilities/Resources/xlf/Resources.cs.xlf
@@ -67,9 +67,14 @@
- Failed to negotiate protocol. Wait for response timed out.
- Nepovedlo se vyjednat protokol. Při čekání na odpověď vypršel časový limit.
-
+ Failed to negotiate protocol, waiting for response timed out after {0} seconds. This may occur due to machine slowness, please set environment variable {1} to increase timeout.
+ Nepovedlo se vyjednat protokol. Při čekání na odpověď vypršel časový limit.
+
+
+
+ {0} process failed to connect to {1} process after {2} seconds. This may occur due to machine slowness, please set environment variable {3} to increase timeout.
+ {0} process failed to connect to {1} process after {2} seconds. This may occur due to machine slowness, please set environment variable {3} to increase timeout.
+