-
Notifications
You must be signed in to change notification settings - Fork 323
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
Make all communication timeouts configurable. #1538
Conversation
} | ||
|
||
return isValueSet; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required in Abstraction.
For testing, either have EnvironmentHelper or directly use it in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// <summary> | ||
/// Environment variable name to increase communication timeouts between processes. | ||
/// </summary> | ||
public const string VstestTimeoutIncreaseByTimes = "VSTEST_TIMEOUT_INCREASE_BY_TIMES"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VSTEST_TIMEOUT_INCREASE_BY_TIMES [](start = 60, length = 32)
How about VSTEST_CONNECTION_TIMEOUT?
We should have a simple settings, also make it consistent across
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, Done.
<body> | ||
<trans-unit id="DataCollectorFailedToConnetToVSTestConsole"> | ||
<source>Datacollector process failed to connect to vstest.console in {0} milliseconds, Set enviroment variable {1} to increase timeout.</source> | ||
<target state="new">Datacollector process failed to connect to vstest.console in {0} milliseconds, Set enviroment variable {1} to increase timeout.</target> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Datacollector process failed to connect to vstest.console in {0} milliseconds [](start = 28, length = 77)
Datacollector process failed to connect to vstest.console in {0} milliseconds. Please set environment variable {1} to increase the connection timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify time in Seconds, & take input in seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@singhsarab @mayankbansal018 Agreed. Done.
@@ -0,0 +1,155 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we create a new class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing refactored it.
@@ -0,0 +1,32 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
using System; | ||
using ObjectModel; | ||
|
||
public class EnvironmentHelper |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -207,20 +206,22 @@ public void Initialize() | |||
this.dataCollectionProcessId = this.dataCollectionLauncher.LaunchDataCollector(null, this.GetCommandLineArguments(this.dataCollectionPort)); | |||
EqtTrace.Info("ProxyDataCollectionManager.Initialize: Launched datacollector processId: {0} port: {1}", this.dataCollectionProcessId, this.dataCollectionPort); | |||
|
|||
ChangeConnectionTimeoutIfRequired(dataCollectionProcessId); | |||
var connectionTimeout = GetConnectionTimeout(dataCollectionProcessId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please use this, just to follow current coding convention
/// <param name="clientConnectionTimeout">Client Connection Timeout.</param> | ||
protected ProxyOperationManager(IRequestData requestData, ITestRequestSender requestSender, ITestRuntimeProvider testHostManager, int clientConnectionTimeout) | ||
/// <param name="processHelper">IProcessHelper implementation. </param> | ||
internal ProxyOperationManager(IRequestData requestData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this.
|
||
this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(100000)).Returns(true); | ||
this.testOperationManager.SetupChannel(Enumerable.Empty<string>(), CancellationToken.None); | ||
|
||
this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(100000), Times.Exactly(1)); | ||
|
||
this.connectionTimeout = 400; | ||
this.connectionTimeout = EnvironmentHelper.DefaultConnectionTimeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
|
||
this.testOperationManager.SetupChannel(Enumerable.Empty<string>(), CancellationToken.None); | ||
|
||
this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout), Times.Exactly(1)); | ||
this.mockRequestSender.Verify(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this exactly change
this.mockDataCollectionRequestSender.Setup(x => x.WaitForRequestHandlerConnection(timeout * 1000)).Returns(true); | ||
|
||
this.proxyDataCollectionManager.Initialize(); | ||
Environment.SetEnvironmentVariable(ProxyDataCollectionManager.TimeoutEnvironmentVaribleName, string.Empty); | ||
Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup?
} | ||
|
||
[TestMethod] | ||
public void RunShouldTimeoutBasedOneEnvVariable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On*
var message = Assert.ThrowsException<TestPlatformException>(() => this.dataCollectorMain.Run(args)).Message; | ||
Assert.AreEqual(message, | ||
string.Format( | ||
TestPlatform.DataCollector.Resources .Resources.DataCollectorFailedToConnetToVSTestConsole, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Connect*
private Mock<IEnvironment> mockEnvironment; | ||
private Mock<IDataCollectionRequestHandler> mockDataCollectionRequestHandler; | ||
private DataCollectorMain dataCollectorMain; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line*
@singhsarab @mayankbansal018 Addressed all the comments. Please have a look once more. |
this.SetParentProcessExitCallback(argsDictionary); | ||
|
||
this.requestHandler.ConnectionInfo = | ||
DefaultEngineInvoker.GetConnectionInfo(out var endpoint, argsDictionary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endpoint [](start = 63, length = 8)
remove endpoint, move logging in GetConnectionInfo()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
if (!this.testHostLaunched || !this.RequestSender.WaitForRequestHandlerConnection(connTimeout)) | ||
{ | ||
var errorMsg = CrossPlatEngineResources.InitializationFailed; | ||
var connected = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could repurpose this.testHostLaunched to check for connectivity error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
{ | ||
EqtTrace.Info("TestHostManagerCallbacks.ExitCallBack: Testhost processId: {0} exited with exitcode: 0 error: '{1}'", procId, testHostProcessStdErrorStr); | ||
} | ||
|
||
onHostExited(new HostProviderEventArgs(testHostProcessStdErrorStr, exitCode, procId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testHostProcessStdErrorStr [](start = 51, length = 26)
remove if check simply log exitcode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If exit code is non-zero we are writing to error level.
public static int GetConnectionTimeout() | ||
{ | ||
var envVarValue = Environment.GetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout); | ||
if (!string.IsNullOrEmpty(envVarValue) && int.TryParse(envVarValue, out int value)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
…om/Microsoft/vstest into increase-timeout-for-version-check
CoreUtilitiesConstants.TesthostProcessName, | ||
CoreUtilitiesConstants.DatacollectorProcessName, | ||
EnvironmentHelper.DefaultConnectionTimeout, | ||
EnvironmentHelper.VstestConnectionTimeout)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have exact string match in tests.
If someone changes string in resources, these tests should catch that.
Description
configurable.
Related issue
#1544 #1361
Exxample output