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

Run NetFramework tests inside vstest.console.exe process #1009

Merged
merged 12 commits into from
Aug 28, 2017

Conversation

Faizan2304
Copy link
Contributor

@Faizan2304 Faizan2304 commented Aug 18, 2017

Run test within vstest.console.exe process for project targeting NetFramework if running from commandline.
This will be the default behavior. To opt out default behavior user has to explicitly pass '/InIsolation' argument.

@Faizan2304
Copy link
Contributor Author

Faizan2304 commented Aug 18, 2017

Please see the matrix below to see the benefit of using InProcess argument.

Performance matrix

Number of tests Normal Flow (in seconds) InProcess (in seconds) Percentage benefit
10 tests in one project 1.20 seconds 0.42 seconds 65%
100 tests in one project 1.23 seconds 0.45 seconds 63.4 %
1000 tests in one project 1.73 seconds 0.76 seconds 56%
10000 tests in one project 9.15 seconds 4.76 seconds 47.9%
10000 tests in 10 projects 9.91 seconds 6.42 seconds 35.2%
1 lakh test in 10 projects 75.60 seconds 46.60 seconds 38.3%

@pvlakshm @sbaid @codito

{
EqtTrace.Error("InProcessProxyexecutionManager.StartTestRun: Failed to start test run: {0}", exception);

// Send a discovery complete to caller.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: change comment to test execution complete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit.

@@ -59,14 +63,19 @@ public IProxyDiscoveryManager GetDiscoveryManager(ITestRuntimeProvider testHostM
{
var parallelLevel = this.VerifyParallelSettingAndCalculateParallelLevel(discoveryCriteria.Sources.Count(), discoveryCriteria.RunSettings);
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be moved below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit.

}

var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings);

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment specifying when will we enable InProc run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

class InProcessProxyDiscoveryManager : IProxyDiscoveryManager
Copy link
Contributor

Choose a reason for hiding this comment

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

public or internal class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

internal

EqtTrace.Error("InProcessProxyDiscoveryManager.DiscoverTests: Failed to discover tests: {0}", exception);

// Send a discovery complete to caller.
eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.Message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Log exception stacktrace also on failure scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
}

public int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if (runConfiguration.InProcess &&
!runConfiguration.DisableAppDomain &&
!runConfiguration.DesignMode &&
!(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Name.StartsWith()?
What scenario the netstandard is being used as TargetFramework?
If we target netstandard2.0, can enable this scenarion for .net core?

!(runConfiguration.TargetFrameworkVersion.Name.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0
|| runConfiguration.TargetFrameworkVersion.Name.IndexOf("netcoreapp", StringComparison.OrdinalIgnoreCase) >= 0))
{
return true ;
Copy link
Contributor

Choose a reason for hiding this comment

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

Log eqttrace message on successful/unsuccessful using of inproc. Give warning on using inproc option for not supported target frameworks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@@ -376,6 +399,15 @@ public bool DisableAppDomainSet
}

/// <summary>
/// Gets a value indicating whether InProcess is set.
/// </summary>
public bool InProcessSet
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 this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

/// <param name="eventHandler">EventHandler for handling discovery events from Engine</param>
public void DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler eventHandler)
{
var discoveryManager = this.testHostManagerFactory.GetDiscoveryManager();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why calling GetDiscoveryManager() in every method, Can be a member variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

and we can call Initilize() instead of doing check below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

public void InitializeShouldCallDiscoveryManagerInitializeWithEmptyIEnumerable()
{
this.inProcessProxyDiscoveryManager.Initialize();
this.mockDiscoveryManager.Verify(o => o.Initialize(Enumerable.Empty<string>()), Times.Once);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add assert failure message for all asserts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix in next commit.

// Start using these additional extensions
TestPluginCache.Instance.DefaultExtensionPaths = pathToAdditionalExtensions;
if (pathToAdditionalExtensions != null && pathToAdditionalExtensions.Count() > 0)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use pathToAdditionalExtensions.Any() instead of pathToAdditionalExtensions.Count() > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we can use

/// </summary>
public void Abort()
{
Task.Run(() => this.testHostManagerFactory.GetDiscoveryManager().Abort());
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 require any null check for this.testHostManagerFactory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't require. If its null, process should catch exception

faahmad added 3 commits August 25, 2017 20:43
2) Enable InIsolation argument to disable default in process.
3) Address PR comment
internal class InProcessProxyDiscoveryManager : IProxyDiscoveryManager
{
private ITestHostManagerFactory testHostManagerFactory;
IDiscoveryManager discoveryManager;
Copy link
Contributor

Choose a reason for hiding this comment

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

Explicit annotation for types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit.


// Send a discovery complete to caller.
eventHandler.HandleLogMessage(TestMessageLevel.Error, exception.ToString());
eventHandler.HandleDiscoveryComplete(-1, new List<TestCase>(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Enumerable.Empty<TestCase>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

var executionContext = new TestExecutionContext(
testRunCriteria.FrequencyOfRunStatsChangeEvent,
testRunCriteria.RunStatsChangeEventTimeout,
inIsolation: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this used in TPv1? Are we missing scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This info get passed to adapter through RunContext


if (testRunCriteria.HasSpecificSources)
{
// [TODO]: we need to revisit to second-last argument if we will enable datacollector.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove todo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

hasTestRun: true,
isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug),
testCaseFilter: testRunCriteria.TestCaseFilter);

Copy link
Contributor

Choose a reason for hiding this comment

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

We should ask TestRuntimeProvider for extensions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we should.

@Faizan2304 Faizan2304 merged commit f205078 into microsoft:master Aug 28, 2017
@Faizan2304 Faizan2304 deleted the noIsolation branch August 28, 2017 20:43
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.

6 participants