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 6 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
Expand Up @@ -136,6 +136,6 @@
<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, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<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, Timeout: {0} milliseconds occured while waiting for response, Set enviroment 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>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<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, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Fehler beim Verhandeln des Protokolls. Timeout beim Warten auf Antwort.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<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, Timeout: {0} milliseconds occured while waiting for response, Set enviroment 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>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Échec de la négociation du protocole. Expiration du délai d'attente de la réponse.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Échec de la négociation du protocole. Expiration du délai d'attente de la réponse.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Non è stato possibile negoziare il protocollo. Si è verificato un timeout durante l'attesa della risposta.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Non è stato possibile negoziare il protocollo. Si è verificato un timeout durante l'attesa della risposta.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">プロトコルをネゴシエートできませんでした。応答がタイムアウトするまでしばらくお待ちください。</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">プロトコルをネゴシエートできませんでした。応答がタイムアウトするまでしばらくお待ちください。</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">프로토콜을 협상하지 못했습니다. 응답 시간이 초과될 때까지 기다려 주세요.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">프로토콜을 협상하지 못했습니다. 응답 시간이 초과될 때까지 기다려 주세요.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Nie można negocjować protokołu. Zaczekaj na przekroczenie limitu czasu odpowiedzi.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Nie można negocjować protokołu. Zaczekaj na przekroczenie limitu czasu odpowiedzi.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Falha ao negociar o protocolo. Aguarde a resposta atingir o tempo limite.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Falha ao negociar o protocolo. Aguarde a resposta atingir o tempo limite.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Не удалось согласовать протокол. Подождите, пока истечет время ожидания ответа.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Не удалось согласовать протокол. Подождите, пока истечет время ожидания ответа.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">Protokol üzerinde anlaşmaya varılamadı. Yanıt beklenirken zaman aşımı gerçekleşti.</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Protokol üzerinde anlaşmaya varılamadı. Yanıt beklenirken zaman aşımı gerçekleşti.</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<note></note>
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">Failed to negotiate protocol. Wait for response timed out.</target>
<note></note>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">未能协商协议。等待响应超时。</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">未能协商协议。等待响应超时。</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
<note />
</trans-unit>
<trans-unit id="VersionCheckTimedout">
<source>Failed to negotiate protocol. Wait for response timed out.</source>
<target state="translated">無法交涉通訊協定。請等候回應逾時。</target>
<note />
<source>Failed to negotiate protocol, Timeout: {0} milliseconds occured while waiting for response, Set enviroment variable {1} to increase timeout.</source>
<target state="new">無法交涉通訊協定。請等候回應逾時。</target>
<note></note>
</trans-unit>
</body>
</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace Microsoft.VisualStudio.TestPlatform.CommunicationUtilities
using System.Collections.Generic;
using System.Globalization;
using System.Threading;

using CoreUtilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions;
using CommonResources = Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Resources.Resources;

/// <summary>
Expand Down Expand Up @@ -96,11 +96,11 @@ internal TestRequestSender(
/// <param name="protocolConfig">Protocol configuration.</param>
/// <param name="clientExitedWaitTime">Time to wait for client process exit.</param>
internal TestRequestSender(
ICommunicationEndPoint communicationEndPoint,
TestHostConnectionInfo connectionInfo,
IDataSerializer serializer,
ProtocolConfig protocolConfig,
int clientExitedWaitTime)
ICommunicationEndPoint communicationEndPoint,
TestHostConnectionInfo connectionInfo,
IDataSerializer serializer,
ProtocolConfig protocolConfig,
int clientExitedWaitTime)
: this(connectionInfo, serializer, protocolConfig, clientExitedWaitTime)
{
this.communicationEndpoint = communicationEndPoint;
Expand Down Expand Up @@ -198,9 +198,10 @@ public void CheckVersionWithTestHost()
this.channel.Send(data);

// Wait for negotiation response
if (!protocolNegotiated.WaitOne(60 * 1000))
var timeout = EnvironmentHelper.GetConnectionTimeout();
if (!protocolNegotiated.WaitOne(timeout * 1000))
{
throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckTimedout));
throw new TestPlatformException(string.Format(CultureInfo.CurrentUICulture, CommonResources.VersionCheckTimedout, timeout, Constants.VstestTimeoutIncreaseByTimes));
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add more in CoreUtilities dll? can we move this to Testplatform.Utilities?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoreUtilities have basic utilities on BCL. TestPlatform.Utilities has OM + BCL Utilities.

// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers
{
using System;
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces;
using ObjectModel;

public class EnvironmentHelper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an IEnvironment Interface in platform abstractions, should it not move there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will go for PlatformAbstration if there is need to do #if defs. This function not required that.

{
public const string VstestConnectionTimeout = "VSTEST_CONNECTION_TIMEOUT";
public const int DefaultConnectionTimeout = 90; // seconds

/// <summary>
/// Get timeout based on environment variable VSTEST_CONNECTION_TIMEOUT.
/// </summary>
public static int GetConnectionTimeout()
{
var envVarValue = Environment.GetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout);
if (!string.IsNullOrEmpty(envVarValue) && int.TryParse(envVarValue, out int value))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if user sets a very small value say 10, should we honor it? I would say we keep 90 or 60 something as min, & users value will only be honored if it is > min val
More over here we are not even checking for -ve values

Copy link
Contributor Author

@smadala smadala Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handled -ve case. Keep min value 0, giving more choice to user.

{
EqtTrace.Info("EnvironmentHelper.GetConnectionTimeout: {0} value set to {1}.", EnvironmentHelper.VstestConnectionTimeout, value);
}
else
{
value = EnvironmentHelper.DefaultConnectionTimeout;
}

return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ProxyDiscoveryManager : ProxyOperationManager, IProxyDiscoveryManag
/// <param name="testRequestSender">Test request sender instance.</param>
/// <param name="testHostManager">Test host manager instance.</param>
public ProxyDiscoveryManager(IRequestData requestData, ITestRequestSender testRequestSender, ITestRuntimeProvider testHostManager)
: this(requestData, testRequestSender, testHostManager, JsonDataSerializer.Instance, CrossPlatEngine.Constants.ClientConnectionTimeout)
: this(requestData, testRequestSender, testHostManager, JsonDataSerializer.Instance)
{
this.testHostManager = testHostManager;
}
Expand All @@ -51,23 +51,19 @@ public ProxyDiscoveryManager(IRequestData requestData, ITestRequestSender testRe
/// Initializes a new instance of the <see cref="ProxyDiscoveryManager"/> class.
/// Constructor with Dependency injection. Used for unit testing.
/// </summary>
/// <param name="requestData"></param>
/// <param name="requestSender">
/// The request Sender.
/// The request Sender.
/// </param>
/// <param name="testHostManager">
/// Test host Manager instance
/// Test host Manager instance
/// </param>
/// <param name="dataSerializer"></param>
/// <param name="clientConnectionTimeout">
/// The client Connection Timeout
/// </param>
internal ProxyDiscoveryManager(
IRequestData requestData,
internal ProxyDiscoveryManager(IRequestData requestData,
ITestRequestSender requestSender,
ITestRuntimeProvider testHostManager,
IDataSerializer dataSerializer,
int clientConnectionTimeout)
: base(requestData, requestSender, testHostManager, clientConnectionTimeout)
IDataSerializer dataSerializer)
: base(requestData, requestSender, testHostManager)
{
this.dataSerializer = dataSerializer;
this.testHostManager = testHostManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

using Constants = Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Constants;

/// <summary>
/// Orchestrates test execution operations for the engine communicating with the client.
/// </summary>
Expand All @@ -49,7 +47,7 @@ internal class ProxyExecutionManager : ProxyOperationManager, IProxyExecutionMan
/// <param name="requestSender">Test request sender instance.</param>
/// <param name="testHostManager">Test host manager for this proxy.</param>
public ProxyExecutionManager(IRequestData requestData, ITestRequestSender requestSender, ITestRuntimeProvider testHostManager) :
this(requestData, requestSender, testHostManager, JsonDataSerializer.Instance, Constants.ClientConnectionTimeout)
this(requestData, requestSender, testHostManager, JsonDataSerializer.Instance)
{
}

Expand All @@ -61,9 +59,9 @@ public ProxyExecutionManager(IRequestData requestData, ITestRequestSender reques
/// <param name="requestSender">Request Sender instance</param>
/// <param name="testHostManager">Test host manager instance</param>
/// <param name="dataSerializer"></param>
/// <param name="clientConnectionTimeout">The client Connection Timeout</param>
internal ProxyExecutionManager(IRequestData requestData, ITestRequestSender requestSender, ITestRuntimeProvider testHostManager, IDataSerializer dataSerializer, int clientConnectionTimeout)
: base(requestData, requestSender, testHostManager, clientConnectionTimeout)
internal ProxyExecutionManager(IRequestData requestData, ITestRequestSender requestSender,
ITestRuntimeProvider testHostManager, IDataSerializer dataSerializer)
: base(requestData, requestSender, testHostManager)
{
this.testHostManager = testHostManager;
this.dataSerializer = dataSerializer;
Expand Down
Loading