/// <inheritdoc/> public bool HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, long totalTests, IEnumerable <TestCase> lastChunk, bool isAborted) { var allDiscoverersCompleted = false; if (!this.SharedHosts) { this.concurrentManagerHandlerMap.Remove(proxyDiscoveryManager); proxyDiscoveryManager.Close(); proxyDiscoveryManager = this.CreateNewConcurrentManager(); var parallelEventsHandler = new ParallelDiscoveryEventsHandler( proxyDiscoveryManager, this.currentDiscoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.concurrentManagerHandlerMap.Add(proxyDiscoveryManager, parallelEventsHandler); } // In Case of Cancel or Abort, no need to trigger discovery for rest of the data // If there are no more sources/testcases, a parallel executor is truly done with discovery if (isAborted || !this.DiscoverTestsOnConcurrentManager(proxyDiscoveryManager)) { lock (this.discoveryStatusLockObject) { // Each concurrent Executor calls this method // So, we need to keep track of total discoverycomplete calls this.discoveryCompletedClients++; allDiscoverersCompleted = this.discoveryCompletedClients == this.concurrentManagerInstances.Length; } // verify that all executors are done with the discovery and there are no more sources/testcases to execute if (allDiscoverersCompleted) { // Reset enumerators this.sourceEnumerator = null; this.currentDiscoveryDataAggregator = null; this.currentDiscoveryEventsHandler = null; // Dispose concurrent executors // Do not do the cleanuptask in the current thread as we will unncessarily add to discovery time this.lastParallelDiscoveryCleanUpTask = Task.Run(() => { this.UpdateParallelLevel(0); }); } } return(allDiscoverersCompleted); }
private void DiscoverTestsPrivate(ITestDiscoveryEventsHandler2 discoveryEventsHandler) { this.currentDiscoveryEventsHandler = discoveryEventsHandler; // Cleanup Task for cleaning up the parallel executors except for the default one // We do not do this in Sync so that this task does not add up to discovery time if (this.lastParallelDiscoveryCleanUpTask != null) { try { if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("ProxyParallelDiscoveryManager: Wait for last cleanup to complete."); } this.lastParallelDiscoveryCleanUpTask.Wait(); } catch (Exception ex) { // if there is an exception disposing off concurrent hosts ignore it if (EqtTrace.IsWarningEnabled) { EqtTrace.Warning("ParallelProxyDiscoveryManager: Exception while invoking an action on DiscoveryManager: {0}", ex); } } this.lastParallelDiscoveryCleanUpTask = null; } // Reset the discoverycomplete data this.discoveryCompletedClients = 0; // One data aggregator per parallel discovery this.currentDiscoveryDataAggregator = new ParallelDiscoveryDataAggregator(); foreach (var concurrentManager in this.GetConcurrentManagerInstances()) { var parallelEventsHandler = new ParallelDiscoveryEventsHandler( this.requestData, concurrentManager, discoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler); this.DiscoverTestsOnConcurrentManager(concurrentManager); } }
private void DiscoverTestsPrivate(ITestDiscoveryEventsHandler discoveryEventsHandler) { this.currentDiscoveryEventsHandler = discoveryEventsHandler; // Cleanup Task for cleaning up the parallel executors except for the default one // We do not do this in Sync so that this task does not add up to discovery time if (this.lastParallelDiscoveryCleanUpTask != null) { try { this.lastParallelDiscoveryCleanUpTask.Wait(); } catch (Exception ex) { // if there is an exception disposing off concurrent hosts ignore it if (EqtTrace.IsWarningEnabled) { EqtTrace.Warning("ParallelProxyDiscoveryManager: Exception while invoking an action on DiscoveryManager: {0}", ex); } } this.lastParallelDiscoveryCleanUpTask = null; } // Reset the discoverycomplete data this.discoveryCompletedClients = 0; // One data aggregator per parallel discovery this.currentDiscoveryDataAggregator = new ParallelDiscoveryDataAggregator(); this.concurrentManagerHandlerMap = new Dictionary <IProxyDiscoveryManager, ITestDiscoveryEventsHandler>(); for (int i = 0; i < this.concurrentManagerInstances.Length; i++) { var concurrentManager = this.concurrentManagerInstances[i]; var parallelEventsHandler = new ParallelDiscoveryEventsHandler( concurrentManager, discoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.concurrentManagerHandlerMap.Add(concurrentManager, parallelEventsHandler); Task.Run(() => this.DiscoverTestsOnConcurrentManager(concurrentManager)); } }
private void DiscoverTestsPrivate(ITestDiscoveryEventsHandler2 discoveryEventsHandler) { this.currentDiscoveryEventsHandler = discoveryEventsHandler; // Reset the discoverycomplete data this.discoveryCompletedClients = 0; // One data aggregator per parallel discovery this.currentDiscoveryDataAggregator = new ParallelDiscoveryDataAggregator(); foreach (var concurrentManager in this.GetConcurrentManagerInstances()) { var parallelEventsHandler = new ParallelDiscoveryEventsHandler( this.requestData, concurrentManager, discoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler); this.DiscoverTestsOnConcurrentManager(concurrentManager); } }
/// <inheritdoc/> public bool HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, long totalTests, IEnumerable <TestCase> lastChunk, bool isAborted) { var allDiscoverersCompleted = false; lock (this.discoveryStatusLockObject) { // Each concurrent Executor calls this method // So, we need to keep track of total discoverycomplete calls this.discoveryCompletedClients++; // If there are no more sources/testcases, a parallel executor is truly done with discovery allDiscoverersCompleted = this.discoveryCompletedClients == this.availableTestSources; if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Total completed clients = {0}, Discovery complete = {1}.", this.discoveryCompletedClients, allDiscoverersCompleted); } } // Discovery is completed. Schedule the clean up for managers and handlers. if (allDiscoverersCompleted) { // Reset enumerators this.sourceEnumerator = null; this.currentDiscoveryDataAggregator = null; this.currentDiscoveryEventsHandler = null; // Dispose concurrent executors // Do not do the cleanuptask in the current thread as we will unncessarily add to discovery time this.lastParallelDiscoveryCleanUpTask = Task.Run(() => this.UpdateParallelLevel(0)); return(true); } // Discovery is not complete. // First, clean up the used proxy discovery manager if the last run was aborted // or this run doesn't support shared hosts (netcore tests) if (!this.SharedHosts || isAborted) { if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Replace discovery manager. Shared: {0}, Aborted: {1}.", this.SharedHosts, isAborted); } this.RemoveManager(proxyDiscoveryManager); proxyDiscoveryManager = this.CreateNewConcurrentManager(); var parallelEventsHandler = new ParallelDiscoveryEventsHandler( this.requestData, proxyDiscoveryManager, this.currentDiscoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.AddManager(proxyDiscoveryManager, parallelEventsHandler); } // Second, let's attempt to trigger discovery for the next source. this.DiscoverTestsOnConcurrentManager(proxyDiscoveryManager); return(false); }
/// <inheritdoc/> public bool HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, long totalTests, IEnumerable <TestCase> lastChunk, bool isAborted) { var allDiscoverersCompleted = false; lock (this.discoveryStatusLockObject) { // Each concurrent Executor calls this method // So, we need to keep track of total discovery complete calls this.discoveryCompletedClients++; // If there are no more sources/testcases, a parallel executor is truly done with discovery allDiscoverersCompleted = this.discoveryCompletedClients == this.availableTestSources; if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Total completed clients = {0}, Discovery complete = {1}.", this.discoveryCompletedClients, allDiscoverersCompleted); } } /* * If discovery is complete or discovery aborting was requsted by testPlatfrom(user) * we need to stop all ongoing discoveries, because we want to separate aborting request * when testhost crashed by itself and when user requested it (f.e. through TW) * Schedule the clean up for managers and handlers. */ if (allDiscoverersCompleted || discoveryAbortRequested) { // Reset enumerators this.sourceEnumerator = null; this.currentDiscoveryDataAggregator = null; this.currentDiscoveryEventsHandler = null; // Dispose concurrent executors this.UpdateParallelLevel(0); return(true); } // Discovery is not complete. // First, clean up the used proxy discovery manager if the last run was aborted // or this run doesn't support shared hosts (netcore tests) if (!this.SharedHosts || isAborted) { if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("ParallelProxyDiscoveryManager: HandlePartialDiscoveryComplete: Replace discovery manager. Shared: {0}, Aborted: {1}.", this.SharedHosts, isAborted); } this.RemoveManager(proxyDiscoveryManager); proxyDiscoveryManager = this.CreateNewConcurrentManager(); var parallelEventsHandler = new ParallelDiscoveryEventsHandler( this.requestData, proxyDiscoveryManager, this.currentDiscoveryEventsHandler, this, this.currentDiscoveryDataAggregator); this.AddManager(proxyDiscoveryManager, parallelEventsHandler); } // Second, let's attempt to trigger discovery for the next source. this.DiscoverTestsOnConcurrentManager(proxyDiscoveryManager); return(false); }