コード例 #1
0
 private async Task AbortTestAgentRunAsync(TestAgentRunDto testAgentRun)
 {
     testAgentRun.Status = TestAgentRunStatus.Aborted;
     testAgentRun.TestAgentOriginalRunResults = string.Empty;
     testAgentRun.TestAgentRetriedRunResults  = string.Empty;
     await _testAgentRunRepository.UpdateAsync(testAgentRun.TestAgentRunId, testAgentRun).ConfigureAwait(false);
 }
コード例 #2
0
        public async Task <List <TestAgentRunDto> > CreateNewTestAgentRunsAsync(Guid testRunId, List <TestAgentDto> testAgents, List <string> testLists)
        {
            if (testAgents.Count == 0 || testLists.Count == 0)
            {
                throw new ArgumentException("The test lists' or test agents' count cannot be 0.");
            }

            if (testAgents.Count < testLists.Count)
            {
                throw new ArgumentException("The test lists' count cannot be greater than test agents' count.");
            }

            var testAgentRuns = new List <TestAgentRunDto>();

            for (var i = 0; i < testLists.Count; i++)
            {
                if (!string.IsNullOrEmpty(testLists[i]))
                {
                    var testAgentRun = new TestAgentRunDto
                    {
                        TestAgentId = testAgents[i].TestAgentId,
                        Status      = TestAgentRunStatus.New,
                        TestList    = testLists[i],
                        TestRunId   = testRunId,
                    };
                    testAgentRun = await _testAgentRunRepository.CreateAsync(testAgentRun).ConfigureAwait(false);

                    testAgentRuns.Add(testAgentRun);
                }
            }

            return(testAgentRuns);
        }
コード例 #3
0
 private void SendTestAgentRunExceptionToRunner(TestAgentRunDto newTestAgentRun, Task executeTestAgentRunTask)
 {
     if (executeTestAgentRunTask.IsFaulted)
     {
         if (executeTestAgentRunTask.Exception != null)
         {
             foreach (var ex in executeTestAgentRunTask.Exception.InnerExceptions)
             {
                 _logger.LogErrorAsync(ex.GetType().Name, ex).Wait();
                 _testRunLogService.CreateTestRunLogAsync(ex.ToString(), newTestAgentRun.TestRunId);
             }
         }
     }
 }
コード例 #4
0
        public async Task <IActionResult> CreateTestAgentRunAsync([FromBody] TestAgentRunDto logDto)
        {
            if (logDto == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var log = Mapper.Map <TestAgentRun>(logDto);

            var result = await _meissaRepository.InsertWithSaveAsync(log);

            var resultDto = Mapper.Map <TestAgentRunDto>(result);

            return(Ok(resultDto));
        }
コード例 #5
0
        private async Task ExecuteTestAgentRunAsync(TestAgentRunDto testAgentRun, int testAgentRunTimeout, CancellationTokenSource cancellationTokenSource)
        {
            _pluginService.ExecuteAllTestAgentPluginsPreTestRunLogic();

            testAgentRun.Status = TestAgentRunStatus.InProgress;
            await CreateEnvironmentVariablesForCustomArgumentsAsync(testAgentRun.TestRunId).ConfigureAwait(false);

            await _testAgentRunRepository.UpdateAsync(testAgentRun.TestAgentRunId, testAgentRun).ConfigureAwait(false);

            var testRun = await _testRunRepository.GetAsync(testAgentRun.TestRunId).ConfigureAwait(false);

            var tempExecutionFolder = _pathProvider.Combine(_pathProvider.GetTempFolderPath(), _guidService.NewGuid().ToString());
            var tempZipFileName     = _pathProvider.GetTempFileName();
            var testRunOutput       = await _testRunOutputServiceClient.GetTestRunOutputByTestRunIdAsync(testRun.TestRunId).ConfigureAwait(false);

            if (testRunOutput == null)
            {
                // DEBUG:
                await _testRunLogService.CreateTestRunLogAsync("The test run output cannot be null.", testAgentRun.TestRunId).ConfigureAwait(false);

                throw new ArgumentException("The test run output cannot be null.");
            }

            _fileProvider.WriteAllBytes(tempZipFileName, testRunOutput.TestOutputFilesPackage);
            _fileProvider.ExtractZip(tempZipFileName, tempExecutionFolder);
            var testRunTestsAssemblyPath = _pathProvider.Combine(tempExecutionFolder, testRun.TestAssemblyName);

            if (cancellationTokenSource.IsCancellationRequested)
            {
                return;
            }

            var testsResults = await _nativeTestsRunner.ExecuteTestsAsync(
                testRun.TestTechnology,
                testAgentRun.TestList,
                tempExecutionFolder,
                testAgentRun.TestRunId,
                testRunTestsAssemblyPath,
                testRun.TestAssemblyName,
                testRun.RunInParallel,
                testRun.NativeArguments,
                testAgentRunTimeout,
                testRun.IsTimeBasedBalance,
                testRun.SameMachineByClass,
                cancellationTokenSource).ConfigureAwait(false);

            var retriedTestResults = string.Empty;

            if (testRun.RetriesCount > 0)
            {
                retriedTestResults = await _nativeTestsRunner.ExecuteTestsWithRetryAsync(
                    testRun.TestTechnology,
                    testsResults,
                    testAgentRun.TestList,
                    tempExecutionFolder,
                    testAgentRun.TestRunId,
                    testRunTestsAssemblyPath,
                    testRun.TestAssemblyName,
                    testRun.RunInParallel,
                    testRun.NativeArguments,
                    testAgentRunTimeout,
                    testRun.RetriesCount,
                    testRun.Threshold,
                    testRun.IsTimeBasedBalance,
                    testRun.SameMachineByClass,
                    cancellationTokenSource).ConfigureAwait(false);
            }

            if (cancellationTokenSource.IsCancellationRequested)
            {
                return;
            }

            await CompleteTestAgentRunAsync(testAgentRun.TestAgentRunId, testsResults, retriedTestResults).ConfigureAwait(false);

            _pluginService.ExecuteAllTestAgentPluginsPostTestRunLogic();

            DeleteTempExecutionFolder(tempExecutionFolder);
        }