Пример #1
0
 public ParallelRunEventsHandler(IProxyExecutionManager proxyExecutionManager,
                                 ITestRunEventsHandler actualRunEventsHandler,
                                 IParallelProxyExecutionManager parallelProxyExecutionManager,
                                 ParallelRunDataAggregator runDataAggregator) :
     this(proxyExecutionManager, actualRunEventsHandler, parallelProxyExecutionManager, runDataAggregator, JsonDataSerializer.Instance)
 {
 }
        /// <summary>
        /// Handles Partial Run Complete event coming from a specific concurrent proxy exceution manager
        /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete
        /// </summary>
        /// <param name="proxyExecutionManager">Concurrent Execution manager that completed the run</param>
        /// <param name="testRunCompleteArgs">RunCompleteArgs for the concurrent run</param>
        /// <param name="lastChunkArgs">LastChunk testresults for the concurrent run</param>
        /// <param name="runContextAttachments">RunAttachments for the concurrent run</param>
        /// <param name="executorUris">ExecutorURIs of the adapters involved in executing the tests</param>
        /// <returns>True if parallel run is complete</returns>
        public bool HandlePartialRunComplete(
            IProxyExecutionManager proxyExecutionManager,
            TestRunCompleteEventArgs testRunCompleteArgs,
            TestRunChangedEventArgs lastChunkArgs,
            ICollection <AttachmentSet> runContextAttachments,
            ICollection <string> executorUris)
        {
            var allRunsCompleted = false;

            if (!this.SharedHosts)
            {
                this.concurrentManagerHandlerMap.Remove(proxyExecutionManager);
                proxyExecutionManager.Close();

                proxyExecutionManager = CreateNewConcurrentManager();

                var parallelEventsHandler = new ParallelRunEventsHandler(
                    proxyExecutionManager,
                    this.currentRunEventsHandler,
                    this,
                    this.currentRunDataAggregator);
                this.concurrentManagerHandlerMap.Add(proxyExecutionManager, parallelEventsHandler);
            }

            // In Case of Cancel or Abort, no need to trigger run for rest of the data
            // If there are no more sources/testcases, a parallel executor is truly done with execution
            if (testRunCompleteArgs.IsAborted || testRunCompleteArgs.IsCanceled || !this.StartTestRunOnConcurrentManager(proxyExecutionManager))
            {
                lock (this.executionStatusLockObject)
                {
                    // Each concurrent Executor calls this method
                    // So, we need to keep track of total runcomplete calls
                    this.runCompletedClients++;
                    allRunsCompleted = this.runCompletedClients == this.concurrentManagerInstances.Length;
                }

                // verify that all executors are done with the execution and there are no more sources/testcases to execute
                if (allRunsCompleted)
                {
                    // Reset enumerators
                    this.sourceEnumerator       = null;
                    this.testCaseListEnumerator = null;

                    this.currentRunDataAggregator = null;
                    this.currentRunEventsHandler  = null;

                    // Dispose concurrent executors
                    // Do not do the cleanuptask in the current thread as we will unncessarily add to execution time
                    this.lastParallelRunCleanUpTask = Task.Run(() =>
                    {
                        this.UpdateParallelLevel(0);
                    });
                }
            }

            return(allRunsCompleted);
        }
Пример #3
0
 internal ParallelRunEventsHandler(IProxyExecutionManager proxyExecutionManager,
                                   ITestRunEventsHandler actualRunEventsHandler,
                                   IParallelProxyExecutionManager parallelProxyExecutionManager,
                                   ParallelRunDataAggregator runDataAggregator,
                                   IDataSerializer dataSerializer)
 {
     this.proxyExecutionManager         = proxyExecutionManager;
     this.actualRunEventsHandler        = actualRunEventsHandler;
     this.parallelProxyExecutionManager = parallelProxyExecutionManager;
     this.runDataAggregator             = runDataAggregator;
     this.dataSerializer = dataSerializer;
 }
Пример #4
0
        private int StartTestRunPrivate(ITestRunEventsHandler runEventsHandler)
        {
            this.currentRunEventsHandler = runEventsHandler;

            // 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 execution time
            if (this.lastParallelRunCleanUpTask != null)
            {
                try
                {
                    this.lastParallelRunCleanUpTask.Wait();
                }
                catch (Exception ex)
                {
                    // if there is an exception disposing off concurrent executors ignore it
                    if (EqtTrace.IsWarningEnabled)
                    {
                        EqtTrace.Warning("ParallelTestRunnerServiceClient: Exception while invoking an action on DiscoveryManager: {0}", ex);
                    }
                }

                this.lastParallelRunCleanUpTask = null;
            }

            // Reset the runcomplete data
            this.runCompletedClients = 0;

            // One data aggregator per parallel run
            this.currentRunDataAggregator    = new ParallelRunDataAggregator();
            this.concurrentManagerHandlerMap = new Dictionary <IProxyExecutionManager, ITestRunEventsHandler>();

            foreach (var concurrentManager in this.concurrentManagerInstances)
            {
                var parallelEventsHandler = concurrentManager is ProxyExecutionManagerWithDataCollection ?
                                            new ParallelDataCollectionEventsHandler(concurrentManager,
                                                                                    this.currentRunEventsHandler,
                                                                                    this,
                                                                                    this.currentRunDataAggregator) :
                                            new ParallelRunEventsHandler(
                    concurrentManager,
                    this.currentRunEventsHandler,
                    this,
                    this.currentRunDataAggregator);

                this.concurrentManagerHandlerMap.Add(concurrentManager, parallelEventsHandler);

                Task.Run(() => this.StartTestRunOnConcurrentManager(concurrentManager));
            }

            return(1);
        }
        private int StartTestRunPrivate(ITestRunEventsHandler runEventsHandler)
        {
            this.currentRunEventsHandler = runEventsHandler;

            // 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 execution time
            if (this.lastParallelRunCleanUpTask != null)
            {
                try
                {
                    if (EqtTrace.IsVerboseEnabled)
                    {
                        EqtTrace.Verbose("ProxyParallelExecutionManager: Wait for last cleanup to complete.");
                    }

                    this.lastParallelRunCleanUpTask.Wait();
                }
                catch (Exception ex)
                {
                    // if there is an exception disposing off concurrent executors ignore it
                    if (EqtTrace.IsWarningEnabled)
                    {
                        EqtTrace.Warning("ProxyParallelExecutionManager: Exception while invoking an action on ProxyExecutionManager: {0}", ex);
                    }
                }

                this.lastParallelRunCleanUpTask = null;
            }

            // Reset the runcomplete data
            this.runCompletedClients = 0;

            // One data aggregator per parallel run
            this.currentRunDataAggregator = new ParallelRunDataAggregator();

            foreach (var concurrentManager in this.GetConcurrentManagerInstances())
            {
                var parallelEventsHandler = this.GetEventsHandler(concurrentManager);
                this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler);
                this.StartTestRunOnConcurrentManager(concurrentManager);
            }

            return(1);
        }
        private int StartTestRunPrivate(ITestRunEventsHandler runEventsHandler)
        {
            this.currentRunEventsHandler = runEventsHandler;

            // Reset the runcomplete data
            this.runCompletedClients = 0;

            // One data aggregator per parallel run
            this.currentRunDataAggregator = new ParallelRunDataAggregator();

            foreach (var concurrentManager in this.GetConcurrentManagerInstances())
            {
                var parallelEventsHandler = this.GetEventsHandler(concurrentManager);
                this.UpdateHandlerForManager(concurrentManager, parallelEventsHandler);
                this.StartTestRunOnConcurrentManager(concurrentManager);
            }

            return(1);
        }
        /// <summary>
        /// Handles Partial Run Complete event coming from a specific concurrent proxy exceution manager
        /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete
        /// </summary>
        /// <param name="proxyExecutionManager">Concurrent Execution manager that completed the run</param>
        /// <param name="testRunCompleteArgs">RunCompleteArgs for the concurrent run</param>
        /// <param name="lastChunkArgs">LastChunk testresults for the concurrent run</param>
        /// <param name="runContextAttachments">RunAttachments for the concurrent run</param>
        /// <param name="executorUris">ExecutorURIs of the adapters involved in executing the tests</param>
        /// <returns>True if parallel run is complete</returns>
        public bool HandlePartialRunComplete(
            IProxyExecutionManager proxyExecutionManager,
            TestRunCompleteEventArgs testRunCompleteArgs,
            TestRunChangedEventArgs lastChunkArgs,
            ICollection <AttachmentSet> runContextAttachments,
            ICollection <string> executorUris)
        {
            var allRunsCompleted = false;

            lock (this.executionStatusLockObject)
            {
                // Each concurrent Executor calls this method
                // So, we need to keep track of total runcomplete calls
                this.runCompletedClients++;

                if (testRunCompleteArgs.IsCanceled)
                {
                    allRunsCompleted = this.runCompletedClients == this.runStartedClients;
                }
                else
                {
                    allRunsCompleted = this.runCompletedClients == this.availableTestSources;
                }

                if (EqtTrace.IsVerboseEnabled)
                {
                    EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Total completed clients = {0}, Run complete = {1}, Run canceled: {2}.", this.runCompletedClients, allRunsCompleted, testRunCompleteArgs.IsCanceled);
                }
            }

            // verify that all executors are done with the execution and there are no more sources/testcases to execute
            if (allRunsCompleted)
            {
                // Reset enumerators
                this.sourceEnumerator       = null;
                this.testCaseListEnumerator = null;

                this.currentRunDataAggregator = null;
                this.currentRunEventsHandler  = null;

                // Dispose concurrent executors
                // Do not do the cleanuptask in the current thread as we will unncessarily add to execution time
                this.lastParallelRunCleanUpTask = Task.Run(() =>
                {
                    this.UpdateParallelLevel(0);
                });

                return(true);
            }

            // 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
            // In Case of Abort, clean old one and create new proxyExecutionManager in place of old one.
            if (!this.SharedHosts || testRunCompleteArgs.IsAborted || (proxyExecutionManager is ProxyExecutionManagerWithDataCollection))
            {
                if (EqtTrace.IsVerboseEnabled)
                {
                    EqtTrace.Verbose("ParallelProxyExecutionManager: HandlePartialRunComplete: Replace execution manager. Shared: {0}, Aborted: {1}.", this.SharedHosts, testRunCompleteArgs.IsAborted);
                }

                this.RemoveManager(proxyExecutionManager);
                proxyExecutionManager = CreateNewConcurrentManager();
                var parallelEventsHandler = this.GetEventsHandler(proxyExecutionManager);
                this.AddManager(proxyExecutionManager, parallelEventsHandler);
            }

            // If cancel is triggered for any one run, there is no reason to fetch next source
            // and queue another test run
            if (!testRunCompleteArgs.IsCanceled)
            {
                this.StartTestRunOnConcurrentManager(proxyExecutionManager);
            }

            return(false);
        }
        /// <summary>
        /// Handles Partial Run Complete event coming from a specific concurrent proxy exceution manager
        /// Each concurrent proxy execution manager will signal the parallel execution manager when its complete
        /// </summary>
        /// <param name="proxyExecutionManager">Concurrent Execution manager that completed the run</param>
        /// <param name="testRunCompleteArgs">RunCompleteArgs for the concurrent run</param>
        /// <param name="lastChunkArgs">LastChunk testresults for the concurrent run</param>
        /// <param name="runContextAttachments">RunAttachments for the concurrent run</param>
        /// <param name="executorUris">ExecutorURIs of the adapters involved in executing the tests</param>
        /// <returns>True if parallel run is complete</returns>
        public bool HandlePartialRunComplete(
            IProxyExecutionManager proxyExecutionManager,
            TestRunCompleteEventArgs testRunCompleteArgs,
            TestRunChangedEventArgs lastChunkArgs,
            ICollection <AttachmentSet> runContextAttachments,
            ICollection <string> executorUris)
        {
            var allRunsCompleted = false;

            // 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
            // In Case of Abort, clean old one and create new proxyExecutionManager in place of old one.
            if (!this.SharedHosts || testRunCompleteArgs.IsAborted || (proxyExecutionManager is ProxyExecutionManagerWithDataCollection))
            {
                this.RemoveManager(proxyExecutionManager);

                proxyExecutionManager = CreateNewConcurrentManager();

                var parallelEventsHandler = proxyExecutionManager is ProxyExecutionManagerWithDataCollection
                                                ? new ParallelDataCollectionEventsHandler(
                    proxyExecutionManager,
                    this.currentRunEventsHandler,
                    this,
                    this.currentRunDataAggregator) :
                                            new ParallelRunEventsHandler(
                    proxyExecutionManager,
                    this.currentRunEventsHandler,
                    this,
                    this.currentRunDataAggregator);

                this.AddManager(proxyExecutionManager, parallelEventsHandler);
            }

            // If there are no more sources/testcases, a parallel executor is truly done with execution
            if (testRunCompleteArgs.IsCanceled || !this.StartTestRunOnConcurrentManager(proxyExecutionManager))
            {
                lock (this.executionStatusLockObject)
                {
                    // Each concurrent Executor calls this method
                    // So, we need to keep track of total runcomplete calls
                    this.runCompletedClients++;
                    allRunsCompleted = this.runCompletedClients == this.GetConcurrentManagersCount();
                }

                // verify that all executors are done with the execution and there are no more sources/testcases to execute
                if (allRunsCompleted)
                {
                    // Reset enumerators
                    this.sourceEnumerator       = null;
                    this.testCaseListEnumerator = null;

                    this.currentRunDataAggregator = null;
                    this.currentRunEventsHandler  = null;

                    // Dispose concurrent executors
                    // Do not do the cleanuptask in the current thread as we will unncessarily add to execution time
                    this.lastParallelRunCleanUpTask = Task.Run(() =>
                    {
                        this.UpdateParallelLevel(0);
                    });
                }
            }

            return(allRunsCompleted);
        }