Exemplo n.º 1
0
        public async Task TaoFailure()
        {
            var buildId = new BuildId(4, JobId.ParseName("test"));

            _restClient.AddJson(
                buildId: buildId,
                buildResultJson: TestResources.Tao1BuildResult,
                buildInfoJson: TestResources.Tao1BuildInfo,
                failureInfoJson: TestResources.Tao1FailureInfo,
                testReportJson: TestResources.Tao1TestResult);

            var entity = await _populator.PopulateBuild(buildId);

            var filter = FilterUtil
                         .Column(nameof(BuildFailureEntity.JobName), buildId.JobName)
                         .Filter;
            var list = AzureUtil.Query <BuildFailureEntity>(_buildFailureExactTable, filter).ToList();

            Assert.Equal(2, list.Count);
            foreach (var item in list)
            {
                Assert.Equal(BuildFailureKind.TestCase, item.BuildFailureKind);
                Assert.Equal(buildId, item.BuildId);
            }
        }
Exemplo n.º 2
0
        private static async Task Random()
        {
            /*
             * var boundBuildId = BoundBuildId.Parse("https://dotnet-ci.cloudapp.net/job/dotnet_corefx/job/master/job/fedora23_debug_tst/134/");
             * var buildId = boundBuildId.BuildId;
             * var client = CreateClient(uri: boundBuildId.HostUri, auth: true);
             * var buildInfo = await client.GetBuildInfoAsync(buildId);
             * var buildResult = await client.GetBuildResultAsync(buildInfo);
             * var test = await client.GetFailedTestCasesAsync(buildId);
             * var prInfo = await client.GetPullRequestInfoAsync(buildId);
             */
            var testboundBuildId = BoundBuildId.Parse("https://dotnet-ci.cloudapp.net/job/dotnet_coreclr/job/release_1.0.0/job/x64_release_rhel7.2_pri1_flow/30/");
            var testbuildId      = testboundBuildId.BuildId;
            var client           = CreateClient(uri: testboundBuildId.HostUri, auth: true);
            var elapsedTimeObj   = client.GetBuildInfo(testbuildId).Duration;

            Console.WriteLine($"\tET: {elapsedTimeObj.TotalMilliseconds}");

            var account = GetStorageAccount();
            var dateKey = new DateKey(DateTimeOffset.UtcNow - TimeSpan.FromDays(1));
            var table   = account.CreateCloudTableClient().GetTableReference(AzureConstants.TableNames.BuildResultDate);
            var query   = new TableQuery <BuildResultEntity>()
                          .Where(FilterUtil
                                 .Column(ColumnNames.PartitionKey, dateKey, ColumnOperator.GreaterThanOrEqual)
                                 .And(FilterUtil.Column("MachineName", "Azure0602081822")));
            var all = await AzureUtil.QueryAsync(table, query);

            foreach (var entity in all)
            {
                var boundBuildId = new BoundBuildId(SharedConstants.DotnetJenkinsUri.Host, entity.BuildId);
                Console.WriteLine(boundBuildId.Uri);
            }
        }
Exemplo n.º 3
0
        internal async Task <SendGridMessage> Clean(CancellationToken cancellationToken)
        {
            var limit  = DateTimeOffset.UtcNow - TimeSpan.FromHours(12);
            var filter = FilterUtil.Column(
                nameof(UnprocessedBuildEntity.LastUpdate),
                limit,
                ColumnOperator.LessThanOrEqual);
            var query = new TableQuery <UnprocessedBuildEntity>().Where(filter);
            var list  = await AzureUtil.QueryAsync(_unprocessedBuildTable, query, cancellationToken);

            if (list.Count == 0)
            {
                return(null);
            }

            var textBuilder = new StringBuilder();
            var htmlBuilder = new StringBuilder();

            foreach (var entity in list)
            {
                var boundBuildId = entity.BoundBuildId;
                var buildId      = boundBuildId.BuildId;

                // GC Stress jobs can correctly execute for up to 3 days.  This is a bit of an outlier but one we
                // need to handle;
                if (JobUtil.IsGCStressJob(buildId.JobId))
                {
                    var stressLimit = DateTimeOffset.UtcNow - TimeSpan.FromDays(3);
                    if (entity.LastUpdate >= stressLimit)
                    {
                        continue;
                    }
                }

                _logger.WriteLine($"Deleting stale data {boundBuildId.Uri}");

                textBuilder.Append($"Deleting stale data: {boundBuildId.Uri}");
                textBuilder.Append($"Eror: {entity.StatusText}");

                htmlBuilder.Append($@"<div>");
                htmlBuilder.Append($@"<div>Build <a href=""{boundBuildId.Uri}"">{buildId.JobName} {buildId.Number}</a></div>");
                htmlBuilder.Append($@"<div>Error: {WebUtility.HtmlEncode(entity.StatusText)}</div>");
                htmlBuilder.Append($@"</div>");
            }

            await AzureUtil.DeleteBatchUnordered(_unprocessedBuildTable, list);

            return(new SendGridMessage()
            {
                Text = textBuilder.ToString(),
                Html = htmlBuilder.ToString()
            });
        }