Ejemplo n.º 1
0
        public static async Task <CloudStampyParameters> TestRunner([QueueTrigger("test-jobs", Connection = "StampyStorageConnectionString")] CloudStampyParameters request)
        {
            var nextJob = request.Copy();

            nextJob.JobId = Guid.NewGuid().ToString();

            if ((request.JobType & StampyJobType.Test) == StampyJobType.Test && (request.FlowStatus == Status.InProgress || request.FlowStatus == default(Status)))
            {
                if (request.TestCategories.Any() && !string.IsNullOrWhiteSpace(request.BuildPath) && !string.IsNullOrWhiteSpace(request.CloudName))
                {
                    var resultTasks = new List <Task <JobResult> >();
                    var results     = new List <JobResult>();

                    foreach (var testCategorySet in request.TestCategories)
                    {
                        foreach (var testCategory in testCategorySet)
                        {
                            var testJob = request.Copy();
                            testJob.JobId          = Guid.NewGuid().ToString();
                            testJob.TestCategories = new List <List <string> > {
                                new List <string> {
                                    testCategory
                                }
                            };

                            //test should timeout after 180 minutes.
                            //TODO double check if function runtime has default timeout
                            resultTasks.Add(ExecuteJob(testJob, StampyJobType.Test, TimeSpan.FromHours(5)));
                        }

                        var testCategoryResults = await Task.WhenAll(resultTasks);

                        resultTasks.Clear();
                        results.AddRange(testCategoryResults);
                    }

                    nextJob.FlowStatus = JobStatusHelper.DetermineOverallJobStatus(results);

                    if ((nextJob.JobType & StampyJobType.RemoveResources) != StampyJobType.RemoveResources)
                    {
                        nextJob.JobType = nextJob.JobType | StampyJobType.RemoveResources;
                    }
                    nextJob.ExpiryDate = DateTime.UtcNow.AddHours(1).ToString();
                }
            }

            return(nextJob);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            JobStatusHelper.Initialize(8001);

            JobStatusHelper.SetJobProperty("Prop1", "0");
            int i = 0;

            for (int j = 0; j < 100000; j++)
            {
                for (int k = 0; k < 100000; k++)
                {
                    i += j;
                    i -= j;
                }
            }
            JobStatusHelper.SetJobProperty("Prop1", "1");
            JobStatusHelper.SetJobProperty("Prop2", "1");

            for (int j = 0; j < 100000; j++)
            {
                for (int k = 0; k < 100000; k++)
                {
                    i += j;
                    i -= j;
                }
            }
            JobStatusHelper.SetJobProperty("Prop1", "2");

            for (int j = 0; j < 100000; j++)
            {
                for (int k = 0; k < 100000; k++)
                {
                    i += j;
                    i -= j;
                }
            }

            JobStatusHelper.SetJobProperty(GalaxyJobProperties.ms_strJobStatusPropName, GalaxyJobProperties.ms_strPropValueOfSucJob);
        }
Ejemplo n.º 3
0
        public async Task <JobResult> Execute()
        {
            JobResult jobResult;

            if (!Directory.Exists(_args.BuildPath))
            {
                _logger.WriteError(_args, $"Failed to access fileshare: {_args.BuildPath}");
                jobResult = new JobResult
                {
                    JobStatus = Status.Failed,
                    Message   = $"Failed to access fileshare: {_args.BuildPath}"
                };

                return(jobResult);
            }

            if (!TryCreateTestConfig($@"\\antaresdeployment\PublicLockbox\{_args.CloudName}geo"))
            {
                jobResult           = new JobResult();
                jobResult.JobStatus = Status.Failed;
                jobResult.Message   = $"Failed to create TestCommon config file";
                return(jobResult);
            }

            if (_args.TestCategories == null || _args.TestCategories.Count == 0)
            {
                jobResult           = new JobResult();
                jobResult.JobStatus = Status.Failed;
                jobResult.Message   = $"Test names were not specified";
                return(jobResult);
            }

            var testClient = TestClientFactory.GetTestClient(_logger, _args);

            _logger.WriteInfo(_args, $"Execute {_args.TestCategories[0].First()} tests");
            var jResult = await JobStatusHelper.StartPeriodicStatusUpdates(this, (IJob)testClient, testClient.ExecuteTestAsync(_args.TestCategories[0].First()));

            return(jResult);
        }
Ejemplo n.º 4
0
        protected override void OnCellPainting(DataGridViewCellPaintingEventArgs e)
        {
            var centerY = CenterY(e.Graphics, e.CellBounds, out var width);

            if (e.RowIndex < 0)
            {
                var t = e.Value.ToString();
                if (Running)
                {
                    e.Graphics.FillRectangle(CursorBlink ? Brushes.DarkBlue : Brushes.DarkRed, e.CellBounds);
                    var brush = CursorBlink ? Brushes.Cyan : Brushes.Yellow;
                    e.Graphics.DrawString(t, Font, brush, e.CellBounds.X + 3, e.CellBounds.Y + centerY);
                }
                else
                {
                    e.Graphics.FillRectangle(Brushes.Black, e.CellBounds);
                    e.Graphics.DrawString(t, Font, Brushes.White, e.CellBounds.X + 3, e.CellBounds.Y + centerY);
                }
            }
            else
            {
                var job = (Job)Rows[e.RowIndex].Tag;
                if (job.Status == JobStatus.Running)
                {
                    e.Graphics.FillRectangle(CursorBlink ? BackgroundFromStatus(job) : Brushes.Black, e.CellBounds);
                }
                else
                {
                    e.Graphics.FillRectangle(BackgroundFromStatus(job), e.CellBounds);
                }
                switch (e.ColumnIndex)
                {
                case 0:
                {
                    var x = e.CellBounds.X + e.CellBounds.Width - 2 - width;
                    var y = e.CellBounds.Y + centerY;
                    e.Graphics.DrawString(job.Number.ToString(), Font, ForgroundFromStatus(job), x, y);
                    break;
                }

                case 1:
                {
                    var y = e.CellBounds.Y + centerY;
                    e.Graphics.DrawString(job.Name, Font, ForgroundFromStatus(job), e.CellBounds.X + 3, y);
                    break;
                }

                case 2:
                    if (job.StartTime.HasValue)
                    {
                        var d    = job.StartTime.Value.ToShortDateString();
                        var text = $"{d} {job.StartTime.Value.ToLongTimeString()}";
                        var y    = e.CellBounds.Y + centerY;
                        e.Graphics.DrawString(text, Font, ForgroundFromStatus(job), e.CellBounds.X + 3, y);
                    }
                    break;

                case 3:
                    if (job.EndTime.HasValue)
                    {
                        var d    = job.EndTime.Value.ToShortDateString();
                        var text = $"{d} {job.EndTime.Value.ToLongTimeString()}";
                        var x    = e.CellBounds.X + 3;
                        var y    = e.CellBounds.Y + centerY;
                        e.Graphics.DrawString(text, Font, ForgroundFromStatus(job), x, y);
                    }
                    else if (job.StartTime.HasValue)
                    {
                        var span  = DateTime.Now.Subtract(job.StartTime.Value);
                        var h     = Math.Abs(span.Hours);
                        var m     = Math.Abs(span.Minutes);
                        var s     = Math.Abs(span.Seconds);
                        var x     = $"{h:00}:{m:00}:{s:00}";
                        var brush = CursorBlink ? Brushes.Black : Brushes.White;
                        e.Graphics.DrawString(x, Font, brush, e.CellBounds.X + 3, e.CellBounds.Y + centerY);
                    }
                    break;

                case 4:
                    if (job.StartTime.HasValue && job.EndTime.HasValue)
                    {
                        var span = job.EndTime.Value.Subtract(job.StartTime.Value);
                        var h    = Math.Abs(span.Hours);
                        var m    = Math.Abs(span.Minutes);
                        var s    = Math.Abs(span.Seconds);
                        var x    = $"{h:00}:{m:00}:{s:00}";
                        var y    = e.CellBounds.Y + centerY;
                        e.Graphics.DrawString(x, Font, ForgroundFromStatus(job), e.CellBounds.X + 3, y);
                    }
                    break;

                case 5:
                    if (job.AllJobsStartTime.HasValue && job.EndTime.HasValue)
                    {
                        var span = job.EndTime.Value.Subtract(job.AllJobsStartTime.Value);
                        var h    = Math.Abs(span.Hours);
                        var m    = Math.Abs(span.Minutes);
                        var s    = Math.Abs(span.Seconds);
                        var x    = $"{h:00}:{m:00}:{s:00}";
                        var y    = e.CellBounds.Y + centerY;
                        e.Graphics.DrawString(x, Font, ForgroundFromStatus(job), e.CellBounds.X + 3, y);
                    }
                    break;

                case 6:
                {
                    var x = e.CellBounds.X + 3;
                    var y = e.CellBounds.Y + centerY;
                    e.Graphics.DrawString(JobStatusHelper.GetStatusText(job.Status), Font, ForgroundFromStatus(job), x, y);
                }
                break;

                case 7:
                {
                    var text = $"{(job.ExitCode == 0 ? "" : $"{job.ExitCode}: ")}{job.FailMessage}";
                    var x    = e.CellBounds.X + 3;
                    var y    = e.CellBounds.Y + centerY;
                    e.Graphics.DrawString(text, Font, ForgroundFromStatus(job), x, y);
                }
                break;
                }
            }