8000 In parallel create new testhost if datacollection is enabled. by mayankbansal018 · Pull Request #769 · microsoft/vstest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

In parallel create new testhost if datacollection is enabled. #769

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 3 commits into from
Apr 27, 2017
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
Expand Up @@ -143,17 +143,20 @@ public bool HandlePartialRunComplete(
{
var allRunsCompleted = false;

if(!this.SharedHosts)
// In case of DataCollection we only start dc.exe on initialize, & close once the TestRun is complete,
// So instead of resuing ProxyExecutionManager, we will close it here, & create new PEMWDC
if (!this.SharedHosts || (proxyExecutionManager is ProxyExecutionManagerWithDataCollection))
{
this.concurrentManagerHandlerMap.Remove(proxyExecutionManager);
proxyExecutionManager.Close();

proxyExecutionManager = CreateNewConcurrentManager();

var parallelEventsHandler = proxyExecutionManager is ProxyExecutionManagerWithDataCollection ?
new ParallelDataCollectionEventsHandler(proxyExecutionManager,
this.currentRunEventsHandler,
this,
var parallelEventsHandler = proxyExecutionManager is ProxyExecutionManagerWithDataCollection
? new ParallelDataCollectionEventsHandler(
proxyExecutionManager,
this.currentRunEventsHandler,
this,
this.currentRunDataAggregator) :
new ParallelRunEventsHandler(
proxyExecutionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client
using System.Threading;
using System.Threading.Tasks;

using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.Interfaces;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Moq;
Expand All @@ -27,14 +31,22 @@ public class ParallelProxyExecutionManagerTests
private List<Mock<IProxyExecutionManager>> createdMockManagers;
private Func<IProxyExecutionManager> proxyManagerFunc;
private Mock<ITestRunEventsHandler> mockHandler;
private Mock<ITestRuntimeProvider> mockTestHostManager;

private Mock<ITestRequestSender> mockRequestSender;

private Mock<IProxyDataCollectionManager> mockDataCollectionManager;
private List<string> sources;
private TestRunCriteria testRunCriteria;

private bool proxyManagerFuncCalled;

public ParallelProxyExecutionManagerTests()
{
this.createdMockManagers = new List<Mock<IProxyExecutionManager>>();
this.proxyManagerFunc = () =>
{
{
this.proxyManagerFuncCalled = true;
var manager = new Mock<IProxyExecutionManager>();
createdMockManagers.Add(manager);
return manager.Object;
Expand Down Expand Up @@ -143,6 +155,35 @@ public void StartTestRunWithSourcesShouldNotSendCompleteUntilAllSourcesAreProces
AssertMissingAndDuplicateSources(processedSources);
}

[TestMethod]
public void HandlePartialRunCompleteShouldCreateNewProxyExecutionManagerIfDataCollectionEnabled()
{
var completeArgs = new TestRunCompleteEventArgs(null, true, true, null, null, TimeSpan.Zero);
this.mockTestHostManager = new Mock<ITestRuntimeProvider>();
this.mockRequestSender = new Mock<ITestRequestSender>();
this.mockDataCollectionManager = new Mock<IProxyDataCollectionManager>();

var proxyDataCollectionManager = new ProxyExecutionManagerWithDataCollection(this.mockRequestSender.Object, this.mockTestHostManager.Object, this.mockDataCollectionManager.Object);
this.proxyParallelExecutionManager = new ParallelProxyExecutionManager(this.proxyManagerFunc, 2);

var tests = CreateTestCases();
var testRunCriteria = new TestRunCriteria(tests, 100);
var processedTestCases = new List<TestCase>();
SetupMockManagersForTestCase(processedTestCases, testRunCriteria);

AutoResetEvent completeEvent = new AutoResetEvent(false);

SetupHandleTestRunComplete(completeEvent);

this.proxyParallelExecutionManager.StartTestRun(testRunCriteria, this.mockHandler.Object);
Assert.IsTrue(completeEvent.WaitOne(taskTimeout), "Test run not completed.");
this.proxyManagerFuncCalled = false;

this.proxyParallelExecutionManager.HandlePartialRunComplete(proxyDataCollectionManager, completeArgs, null, null, null);

Assert.IsTrue(this.proxyManagerFuncCalled);
}

[TestMethod]
public void StartTestRunWithTestsShouldNotSendCompleteUntilAllTestsAreProcessed()
{
Expand Down
0