Skip to content

Make all communication timeouts configurable. #1538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Implements ICommunicationEndpointFactory.
/// </summary>
public class CommunicationEndpointFactory : ICommunicationEndpointFactory
{
/// <inheritdoc />
public ICommunicationEndPoint Create(ConnectionRole role)
{
ICommunicationEndPoint endPoint;
if (role == ConnectionRole.Host)
{
endPoint = new SocketServer();
}
else
{
endPoint = new SocketClient();
}

return endPoint;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/// <summary>
/// Handles test session events received from vstest console process.
/// </summary>
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Create communication endpoint.
/// </summary>
/// <param name="role" cref="ConnectionRole">Endpoint role.</param>
/// <returns cref="ICommunicationEndPoint">Return communication endpoint object.</returns>
ICommunicationEndPoint Create(ConnectionRole role);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
/// <summary>
/// Interface for sending test case events from test execution process to data collection process
/// </summary>
internal interface IDataCollectionTestCaseEventSender
public interface IDataCollectionTestCaseEventSender
{
/// <summary>
/// Setups client based on port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
{
using System;
using System.Collections.Generic;

using Microsoft.VisualStudio.TestPlatform.ObjectModel;
Expand All @@ -13,8 +14,13 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces
/// <summary>
/// Defines the contract for handling test platform requests
/// </summary>
public interface ITestRequestHandler
public interface ITestRequestHandler : IDisposable
{
/// <summary>
/// Gets or sets connection info for to start server/client.
/// </summary>
TestHostConnectionInfo ConnectionInfo { get; set; }

/// <summary>
/// Setups client based on port
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Resources\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>1621415e-7723-4f46-a589-4c4620c0751a</ProjectGuid>
</PropertyGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<value>Protocol version check failed. Make sure test runner and host are compatible.</value>
</data>
<data name="VersionCheckTimedout" xml:space="preserve">
<value>Failed to negotiate protocol. Wait for response timed out.</value>
<value>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.</value>
</data>
<data name="ConnectionTimeoutErrorMessage" xml:space="preserve">
<value>{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.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Nepovedlo se vyjednat protokol. Při čekání na odpověď vypršel časový limit.</target>
<note />
<source>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.</source>
<target state="new">Nepovedlo se vyjednat protokol. Při čekání na odpověď vypršel časový limit.</target>
<note></note>
</trans-unit>
<trans-unit id="ConnectionTimeoutErrorMessage">
<source>{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.</source>
<target state="new">{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.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Fehler beim Verhandeln des Protokolls. Timeout beim Warten auf Antwort.</target>
<note />
<source>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.</source>
<target state="new">Fehler beim Verhandeln des Protokolls. Timeout beim Warten auf Antwort.</target>
<note></note>
</trans-unit>
<trans-unit id="ConnectionTimeoutErrorMessage">
<source>{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.</source>
<target state="new">{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.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">No se pudo negociar el protocolo. Se agotó el tiempo de espera para la respuesta.</target>
<note />
<source>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.</source>
<target state="new">No se pudo negociar el protocolo. Se agotó el tiempo de espera para la respuesta.</target>
<note></note>
</trans-unit>
<trans-unit id="ConnectionTimeoutErrorMessage">
<source>{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.</source>
<target state="new">{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.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Loading