Ejemplo n.º 1
0
        public async Task SaveTestResultsForCurrentRunAsync(string testTechnology, string testResultsFilePath, string retriedResultsFilePath, Guid testRunId)
        {
            _nativeTestsRunnerPluginService = _pluginService.GetNativeTestRunnerService(testTechnology);
            var testResultsDir = _pathProvider.GetDirectoryName(testResultsFilePath);

            EnsureResultsDirectoryExists(testResultsDir);
            DeleteAllFilesInResultsDirectory(testResultsDir);
            await WriteTestAgentRunsResultsToFilesInResultsDirectoryAsync(testResultsFilePath, testRunId);
            await WriteTestAgentRunsRetriedResultsToFilesInResultsDirectoryAsync(retriedResultsFilePath, testRunId);
        }
Ejemplo n.º 2
0
        public async Task <string> ExecuteTestsAsync(string testTechnology, string distributedTestsList, string workingDir, Guid testRunId, string testsLibraryPath, string assemblyName, bool runInParallel, string nativeArguments, int testAgentRunTimeout, bool isTimeBasedBalance, bool sameMachineByClass, CancellationTokenSource cancellationTokenSource)
        {
            _currentTestRunId  = testRunId;
            _nativeTestsRunner = _pluginService.GetNativeTestRunnerService(testTechnology);
            var testRun = await _testRunRepository.GetAsync(testRunId).ConfigureAwait(false);

            var distributedTestCases = _jsonSerializer.Deserialize <List <TestCase> >(distributedTestsList);
            var testTestResults      = await ExecuteTestsWithNativeRunnerAsync(workingDir, testsLibraryPath, assemblyName, runInParallel, testRun.MaxParallelProcessesCount, nativeArguments, testAgentRunTimeout, isTimeBasedBalance, sameMachineByClass, distributedTestCases, cancellationTokenSource).ConfigureAwait(false);

            return(testTestResults);
        }
Ejemplo n.º 3
0
        public async Task <string> ExecuteTestsWithRetryAsync(
            string testTechnology,
            string originalRunTestResults,
            string distributedTestsList,
            string workingDir,
            Guid testRunId,
            string testsLibraryPath,
            string assemblyName,
            bool runInParallel,
            string nativeArguments,
            int testAgentRunTimeout,
            int retriesCount,
            double threshold,
            bool isTimeBasedBalance,
            bool sameMachineByClass,
            CancellationTokenSource cancellationTokenSource)
        {
            _currentTestRunId  = testRunId;
            _nativeTestsRunner = _pluginService.GetNativeTestRunnerService(testTechnology);
            var testRun = await _testRunRepository.GetAsync(testRunId).ConfigureAwait(false);

            var distributedTestCases = _jsonSerializer.Deserialize <List <TestCase> >(distributedTestsList);

            if (string.IsNullOrEmpty(originalRunTestResults))
            {
                return(null);
            }

            var    originalTestRun       = _nativeTestsRunner.DeserializeTestResults(originalRunTestResults);
            var    failedTests           = _testResultsService.GetAllNotPassedTests(testTechnology, originalRunTestResults);
            double failedTestsPercentage = _testResultsService.CalculatedFailedTestsPercentage(failedTests, distributedTestCases);
            await _testRunLogService.CreateTestRunLogAsync($"failedTestsPercentage= {failedTestsPercentage} < threshold = {threshold}", testRunId).ConfigureAwait(false);

            if (failedTests.Count > 0 && failedTestsPercentage < threshold)
            {
                await _testRunLogService.CreateTestRunLogAsync($"The failed test % {failedTestsPercentage} < threshold % {threshold}. The failed tests will be retried {retriesCount} times.", testRunId).ConfigureAwait(false);

                for (int i = 0; i < retriesCount; i++)
                {
                    if (cancellationTokenSource.Token.IsCancellationRequested)
                    {
                        return(null);
                    }

                    await _testRunLogService.CreateTestRunLogAsync($"Start failed tests retry number {i + 1}.", testRunId).ConfigureAwait(false);

                    string retriedTestTestResults;
                    if (failedTests.Count > 0)
                    {
                        await _testRunLogService.CreateTestRunLogAsync($"{failedTests.Count} tests will be retried.", testRunId).ConfigureAwait(false);

                        retriedTestTestResults = await ExecuteTestsWithNativeRunnerAsync(workingDir, testsLibraryPath, assemblyName, runInParallel, testRun.MaxParallelProcessesCount, nativeArguments, testAgentRunTimeout, isTimeBasedBalance, sameMachineByClass, failedTests, cancellationTokenSource).ConfigureAwait(false);

                        var passedTests = _nativeTestsRunner.GetAllPassesTests(retriedTestTestResults);
                        _nativeTestsRunner.UpdatePassedTests(passedTests, originalTestRun);
                        _nativeTestsRunner.UpdateResultsSummary(originalTestRun);
                    }
                    else
                    {
                        break;
                    }

                    if (!string.IsNullOrEmpty(retriedTestTestResults))
                    {
                        failedTests = _testResultsService.GetAllNotPassedTests(testTechnology, retriedTestTestResults);
                    }
                }
            }
            else
            {
                await _testRunLogService.CreateTestRunLogAsync($"Percentage of failed tests {failedTestsPercentage} is over threshold {threshold}, will not retry tests.", testRunId).ConfigureAwait(false);
            }

            string retriedRunTestResults = _nativeTestsRunner.SerializeTestResults(originalTestRun);

            return(retriedRunTestResults);
        }
Ejemplo n.º 4
0
 public List <TestCase> GetAllNotPassedTests(string testTechnology, string testResultsFileContent)
 {
     _nativeTestsRunnerPluginService = _pluginService.GetNativeTestRunnerService(testTechnology);
     return(_nativeTestsRunnerPluginService.GetAllNotPassedTests(testResultsFileContent));
 }