Beispiel #1
0
        public static void ExecuteServiceThread(Object tQ)
        {
            try
            {
                ResultMessage <List <TestQueue> > testQueue = tQ as ResultMessage <List <TestQueue> >;
                FileGenerator fileGenerator = new FileGenerator(testQueue.Item);
                string        directoryName = fileGenerator.GenerateSpecFiles();

                if (!string.IsNullOrWhiteSpace(directoryName))
                {
                    new ProtractorConfigJsBuilder().Create(testQueue.Item[0]);

                    string groupName = testQueue.Item[0].GroupName;

                    TestDataApi.Post(string.Format(EndPoints.SchedulerHistoryStatus, groupName, (int)SchedulerExecutionStatus.InProgress), new SchedulerHistory());

                    ProtractorCommandRunner protractorCommandRunner = new ProtractorCommandRunner();

                    double maxExecutionTime = TimeSpan.FromMinutes(testQueue.Item.Count * testQueue.Item[0].Browsers.Count * 10).TotalMilliseconds;

                    protractorCommandRunner.ExecuteCommand(groupName, maxExecutionTime);

                    TestDataApi.Post(string.Format(EndPoints.SchedulerHistoryStatus, groupName, (int)SchedulerExecutionStatus.Completed), new SchedulerHistory());

                    ProcessUnprocessedResultWithJson(groupName);

                    ProcessEmail(testQueue, groupName);

                    ImageProcessor.ProcessImages(groupName);
                }

                Hub hubInfo = testQueue.Item.FirstOrDefault().hubInfo;
                DeleteHub(hubInfo.ProcessId, hubInfo.SeleniumAddress);
            }
            catch (Exception ex)
            {
                ResultMessage <List <TestQueue> > testQueue = tQ as ResultMessage <List <TestQueue> >;
                Hub hubInfo = testQueue.Item.FirstOrDefault().hubInfo;
                DeleteHub(hubInfo.ProcessId, hubInfo.SeleniumAddress);
                LoggerService.LogException(ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Executes the service thread.
        /// </summary>
        /// <param name="testQueueData">The test queue data.</param>
        public static void ExecuteServiceThread(object testQueueData)
        {
            try
            {
                ResultMessage <List <TestQueue> > testQueue = testQueueData as ResultMessage <List <TestQueue> >;
                FileGenerator fileGenerator = new FileGenerator(testQueue.Item);
                string        directoryName = fileGenerator.GenerateSpecFiles();

                if (!string.IsNullOrWhiteSpace(directoryName))
                {
                    new ProtractorConfigJsBuilder().Create(testQueue.Item[0], testQueue.Item.Count);

                    string groupName = testQueue.Item[0].GroupName;

                    var schedulerHistory = testQueue.Item[0].SchedulerId > 0
                                               ? TestDataApi.Get <SchedulerHistory>(string.Format(EndPoints.SchedulerHistory, groupName))
                                               : new ResultMessage <SchedulerHistory>();

                    if (schedulerHistory.Item == null || !schedulerHistory.Item.IsCancelled)
                    {
                        TestDataApi.Post(string.Format(EndPoints.SchedulerHistoryStatus, groupName, (int)SchedulerExecutionStatus.InProgress), new List <SchedulerHistory>());

                        ProtractorCommandRunner protractorCommandRunner = new ProtractorCommandRunner();

                        var status = protractorCommandRunner.ExecuteCommand(groupName);

                        schedulerHistory = testQueue.Item[0].SchedulerId > 0
                           ? TestDataApi.Get <SchedulerHistory>(string.Format(EndPoints.SchedulerHistory, groupName))
                           : new ResultMessage <SchedulerHistory>();

                        status = (schedulerHistory.Item == null || !schedulerHistory.Item.IsCancelled)
                                     ? status
                                     : SchedulerExecutionStatus.Cancelled;

                        TestDataApi.Post(string.Format(EndPoints.SchedulerHistoryStatus, groupName, (int)status), new List <SchedulerHistory>());

                        ProcessUnprocessedResultWithJson(groupName);
                    }
                    else
                    {
                        TestDataApi.Post(string.Format(EndPoints.SchedulerHistoryStatus, groupName, schedulerHistory.Item.Status == SchedulerExecutionStatus.CancelledCallBackIssue ? (int)SchedulerExecutionStatus.CancelledCallBackIssue : (int)SchedulerExecutionStatus.Cancelled), new List <SchedulerHistory>());
                    }

                    if (schedulerHistory.Item != null)
                    {
                        ProcessEmail(testQueue, groupName, schedulerHistory.Item.Status);
                    }

                    ImageProcessor.ProcessImages(groupName);
                }

                Hub hubInfo = testQueue.Item.First().HubInfo;

                DeleteHub(hubInfo.ProcessId, hubInfo.SeleniumAddress);
            }
            catch (Exception ex)
            {
                ResultMessage <List <TestQueue> > testQueue = testQueueData as ResultMessage <List <TestQueue> >;
                Hub hubInfo = testQueue.Item.First().HubInfo;
                DeleteHub(hubInfo.ProcessId, hubInfo.SeleniumAddress);
                LoggerService.LogException("ExecuteServiceThread: " + ex.Message);
            }
        }