Skip to content
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

Increase timeouts for datacollector to connect to Testhost #1406

Merged
merged 6 commits into from
Feb 2, 2018
Merged

Increase timeouts for datacollector to connect to Testhost #1406

merged 6 commits into from
Feb 2, 2018

Conversation

mayankbansal018
Copy link
Contributor

@mayankbansal018 mayankbansal018 commented Feb 1, 2018

Description

On Slower Machines(hosted agents) with Profiling enabled 15secs is not enough for testhost to get started,
hence with data collection enabled, the connection b/w testhost, & dc.exe fails.

TestHost process currently waits infinitely to connect to dc.exe, if the above connection does not happen, it causes a hang in th.exe

Fixes #1410

@@ -109,7 +111,9 @@ public void GetFrameWorkForDotNetAssembly(string framework)
}

Console.WriteLine("Framework:{0}, {1}", framework, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));

Copy link

Choose a reason for hiding this comment

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

if we remove asserts what are we testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What these tests are testing, is that we are correctly determining the architecture of dll, see lines above. Putting Assert that they should pass in within certain time is highly in-deterministic. Whether or not a test will complete in 5ms depends upon a lot of factors, like machine state, CPU cycles the test gets, etc..

Putting Assert around timeout is not a way to test performance, for that we should have an appropriate test-bed, along with a standard physical machine to benchmark things on

Copy link
Contributor

Choose a reason for hiding this comment

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

Mayank please remove the commented out code.


In reply to: 165563074 [](ancestors = 165563074)

Copy link

@nigurr nigurr left a comment

Choose a reason for hiding this comment

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

Please do change tests as per new logic or remove old code. no comment out

@@ -32,6 +32,8 @@ internal class DefaultEngineInvoker :
/// </summary>
private const int ClientListenTimeOut = Timeout.Infinite;
Copy link
Contributor

Choose a reason for hiding this comment

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

where is ClientListenTimeout used ? And can it be removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ClientListenTimeout is used by testhost to connect to vstest.console. We are waiting infinitely here so as to allow testhost to keep on polling vstest for comm. However vstest.console only waits for 60secs as default(this is configurable) to connect to testhost. If this does not connect to testhost in this time, it will itself kill testhost process. So this timeout will not cause deadlock

Copy link
Contributor

Choose a reason for hiding this comment

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

Let us not have infinite timeouts anywhere in the code.. keep the timeout then the twice of the vstest.console.exe timeout.. but not infinite..


In reply to: 165572248 [](ancestors = 165572248)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like I said vstest.console will kill testhost process if cannot connect to it. So keeping an infinite timeout here is not harmful. Also the timeout at vstest.console is configurable, & not here. What I can do however is make this also configurable using same environment variable as we use for vstest.console, but then again allowing testhost to wait indefinitely to connect to vstest.console is not harfmful.

Let me know if I still need to make this change

@cltshivash
Copy link
Contributor

            if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut))

do we need infinite timeout here ..?


Refers to: src/testhost.x86/DefaultEngineInvoker.cs:163 in 1251029. [](commit_id = 1251029, deletion_comment = False)

private const int DATACOLLECTIONCONNTIMEOUT = 15 * 1000;
// 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 DATACOLLECTIONCONNTIMEOUT = 60 * 1000;
Copy link
Contributor

@cltshivash cltshivash Feb 2, 2018

Choose a reason for hiding this comment

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

DATACOLLECTIONCONNTIMEOUT [](start = 26, length = 25)

nitpick: can it be properly cased ? #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

// if somehow(on slower machines, with Profiler Enabled) testhost can take considerable time to launch,
// in such scenario dc.exe would have killed the server, but testhost will wait infinitely to connect to it,
// hence do not wait to connect to datacollector process infinitely, as it will cause process hang.
dataCollectionTestCaseEventSender.WaitForRequestSenderConnection(DataConnectionClientListenTimeOut);
Copy link
Contributor

@cltshivash cltshivash Feb 2, 2018

Choose a reason for hiding this comment

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

WaitForRequestSenderConnection [](start = 54, length = 30)

if we fail to connect we aren't logging anything .. minimal we should do that.. also what will happen when timeout kicks in,,,?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logging done. If timeout kicks in vstest will only run test, & data collection will fail

Assert.AreEqual(Enum.Parse(typeof(Architecture), platform, ignoreCase: true), arch);

// We should not assert on time elapsed, it will vary depending on machine, & their state, commenting below assert
// Assert.IsTrue(stopWatch.ElapsedMilliseconds < expectedElapsedTime, string.Format(PerfAssertMessageFormat, expectedElapsedTime, stopWatch.ElapsedMilliseconds));
Copy link
Contributor

@cltshivash cltshivash Feb 2, 2018

Choose a reason for hiding this comment

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

can we remove it then ? #WontFix

Copy link
Contributor Author

@mayankbansal018 mayankbansal018 Feb 2, 2018

Choose a reason for hiding this comment

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

I don't want to remove this commented out as:

  1. It is in test code so I can live with it.
  2. If I had removed it to being with, I would not have been able to explain why I did so in first place.
  3. It's kind of a reminder that do not add perf test in Unit Tests #WontFix

Copy link
Contributor

@cltshivash cltshivash left a comment

Choose a reason for hiding this comment

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

🕐

@mayankbansal018
Copy link
Contributor Author

@dotnet-bot Windows_NT / Debug Build

@mayankbansal018
Copy link
Contributor Author

@dotnet-bot test Windows_NT / Debug Build

Copy link
Contributor

@acesiddhu acesiddhu left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@cltshivash cltshivash left a comment

Choose a reason for hiding this comment

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

:shipit:

@mayankbansal018 mayankbansal018 merged commit 0ceb019 into microsoft:master Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants