Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 public void LogStandardOutput(string message)
 {
     if (!string.IsNullOrEmpty(message) && !message.Contains("Test:"))
     {
         _consoleProvider.WriteLine(message);
         var testRunLog = new TestRunLogDto
         {
             Message   = message,
             TestRunId = _currentTestRunId,
             Status    = TestRunLogStatus.New,
         };
         try
         {
             _testRunLogRepository.CreateAsync(testRunLog).Wait();
         }
         catch (Exception e)
         {
             Debug.WriteLine(e);
             _consoleProvider.WriteLine(e.Message);
         }
     }
 }
Ejemplo n.º 3
0
        public async Task <Guid> CreateNewTestRunAsync(string testAssemblyName, byte[] outputFilesZip, int retriesCount, double threshold, bool runInParallel, int maxParallelProcessesCount, string nativeArguments, string testTechnology, bool isTimeBasedBalance, bool sameMachineByClass, IEnumerable <string> customArgumentsPairs = null)
        {
            if (testAssemblyName == null)
            {
                throw new ArgumentException("testAssemblyName must be provided.");
            }

            var newTestRun = new TestRunDto
            {
                TestRunId                 = _guidService.NewGuid(),
                DateStarted               = _dateTimeProvider.GetCurrentTime(),
                TestAssemblyName          = testAssemblyName,
                Status                    = TestRunStatus.InProgress,
                RetriesCount              = retriesCount,
                Threshold                 = threshold,
                RunInParallel             = runInParallel,
                NativeArguments           = nativeArguments,
                MaxParallelProcessesCount = maxParallelProcessesCount,
                TestTechnology            = testTechnology,
                IsTimeBasedBalance        = isTimeBasedBalance,
                SameMachineByClass        = sameMachineByClass,
            };

            newTestRun = await _testRunServiceClient.CreateAsync(newTestRun);

            var newTestRunOutput = new TestRunOutputDto()
            {
                TestRunId = newTestRun.TestRunId,
                TestOutputFilesPackage = outputFilesZip,
            };
            await _testRunOutputServiceClient.CreateAsync(newTestRunOutput);

            if (customArgumentsPairs != null)
            {
                await CreateTestRunCustomArgumentsAsync(newTestRun.TestRunId, customArgumentsPairs);
            }

            return(newTestRun.TestRunId);
        }
Ejemplo n.º 4
0
        public async Task LoadTestCaseHistoryCollectionAsync()
        {
            var testCaseHistoryCollection = new List <TestCaseHistoryDto>();

            var testCasesHistoryFilePath   = GetTestCasesHistoryFileNamePath();
            var testCaseHistoryFileContent = string.Empty;

            if (_fileProvider.Exists(testCasesHistoryFilePath))
            {
                testCaseHistoryFileContent = await _fileProvider.ReadAllTextAsync(testCasesHistoryFilePath).ConfigureAwait(false);
            }

            if (!string.IsNullOrEmpty(testCaseHistoryFileContent))
            {
                testCaseHistoryCollection = _jsonSerializer.Deserialize <List <TestCaseHistoryDto> >(testCaseHistoryFileContent);
            }

            if (testCaseHistoryCollection.Any())
            {
                foreach (var testCaseHistory in testCaseHistoryCollection)
                {
                    var createdTestCaseHistory = await _testCaseHistoryRepository.CreateAsync(testCaseHistory).ConfigureAwait(false);

                    if (testCaseHistory.Durations.Any())
                    {
                        foreach (var currentDuration in testCaseHistory.Durations)
                        {
                            var testCaseHistoryEntry = new TestCaseHistoryEntryDto
                            {
                                TestCaseHistoryId = createdTestCaseHistory.TestCaseHistoryId,
                                AvgDuration       = currentDuration,
                            };

                            await _testCaseHistoryEntryRepository.CreateAsync(testCaseHistoryEntry).ConfigureAwait(false);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 private async Task CreateTestRunCustomArgumentsAsync(Guid testRunId, IEnumerable <string> customArgumentsPairs)
 {
     // TODO: add a validation that it is correctly formatted?
     foreach (var customArgumentPair in customArgumentsPairs)
     {
         var customArgumentPairString = customArgumentPair.Split('=');
         if (customArgumentPairString.Length == 2)
         {
             string key   = customArgumentPairString[0];
             string value = customArgumentPairString[1];
             if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
             {
                 var testRunCustomArgumentDto = new TestRunCustomArgumentDto
                 {
                     Key       = key,
                     Value     = value,
                     TestRunId = testRunId,
                 };
                 await _testRunCustomArgumentRepository.CreateAsync(testRunCustomArgumentDto);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public async Task CreateTestRunLogAsync(string message, Guid testRunId)
        {
            if (!string.IsNullOrEmpty(message))
            {
                var testRunLog = new TestRunLogDto
                {
                    Message   = message,
                    TestRunId = testRunId,
                    Status    = TestRunLogStatus.New,
                };
                try
                {
                    await _testRunLogRepository.CreateAsync(testRunLog);

                    _consoleProvider.WriteLine(message);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                    _consoleProvider.WriteLine(e.Message);
                }
            }
        }