public async Task <ActionResult> Status(bool all = false, bool error = false, DateTimeOffset?startDate = null) { var startDateValue = startDate ?? DateTimeOffset.UtcNow; var key = BuildStateEntity.GetPartitionKey(startDateValue); var table = _storageAccount.CreateCloudTableClient().GetTableReference(AzureConstants.TableNames.BuildState); var filter = TableQueryUtil.Column(nameof(TableEntity.PartitionKey), key, ColumnOperator.GreaterThanOrEqual); if (error) { filter = TableQueryUtil.And( filter, TableQueryUtil.Column(nameof(BuildStateEntity.Error), (string)null, ColumnOperator.NotEqual)); } else if (!all) { filter = TableQueryUtil.And( filter, TableQueryUtil.Column(nameof(BuildStateEntity.IsDataComplete), false)); } var list = await AzureUtil.QueryAsync <BuildStateEntity>(table, filter); var model = new BuildStatusModel(all, error, startDateValue, list); return(View(viewName: "Status", model: model)); }
private static async Task TestFailureYesterday(int days = -1) { var account = GetStorageAccount(); var tableClient = account.CreateCloudTableClient(); var table = tableClient.GetTableReference(TableNames.BuildState); var date = DateTimeOffset.UtcNow.AddDays(days); var query = TableQueryUtil.And( TableQueryUtil.PartitionKey(DateTimeKey.GetDateKey(date)), TableQueryUtil.Column(nameof(BuildStateEntity.IsBuildFinished), true), TableQueryUtil.Column(nameof(BuildStateEntity.IsDataComplete), false)); var list = await AzureUtil.QueryAsync <BuildStateEntity>(table, query); foreach (var entity in list) { var populator = new BuildTablePopulator(tableClient, CounterUtilFactory, CreateClient(entity.BoundBuildId), TextWriter.Null); try { Console.Write($"{entity.BuildId} ... "); await populator.PopulateBuild(entity.BoundBuildId); Console.WriteLine("good"); } catch (Exception ex) { Console.WriteLine("ERRROR"); Console.WriteLine(ex); } } }
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(testboundBuildId); 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 = TableQueryUtil.And( TableQueryUtil.Column(ColumnName.PartitionKey, dateKey.Key, ColumnOperator.GreaterThanOrEqual), TableQueryUtil.Column("MachineName", "Azure0602081822")); var all = await AzureUtil.QueryAsync <BuildResultEntity>(table, query); foreach (var entity in all) { Console.WriteLine(entity.BoundBuildId.BuildUri); } }
public List <BuildFailureEntity> GetTestCaseFailures(DateTimeOffset startDate, string name, string viewName) { var filter = TableQueryUtil.And( FilterSinceDate(startDate), TableQueryUtil.Column(nameof(BuildFailureEntity.Identifier), name)); filter = FilterView(filter, viewName); var query = new TableQuery <BuildFailureEntity>().Where(filter); return(_buildFailureDateTable.ExecuteQuery(query).ToList()); }
public List <BuildResultEntity> GetBuildResultsByKindName(DateTimeOffset startDate, string kindName, string viewName) { var filter = TableQueryUtil.And( FilterSinceDate(startDate), TableQueryUtil.Column(nameof(BuildResultEntity.ClassificationName), kindName)); filter = FilterView(filter, viewName); var query = new TableQuery <BuildResultEntity>().Where(filter); return(_buildResultDateTable.ExecuteQuery(query).ToList()); }
private static string FilterView(string query, string viewName) { Debug.Assert(nameof(BuildResultEntity.ViewName) == nameof(BuildFailureEntity.ViewName)); if (viewName == AzureUtil.ViewNameAll) { return(query); } return(TableQueryUtil.And( query, TableQueryUtil.Column(nameof(BuildResultEntity.ViewName), viewName, ColumnOperator.Equal))); }
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, jobXml: @"<freeStyleProject></freeStyleProject>"); await _populator.PopulateBuild(new BoundBuildId(new Uri("http://example.com"), buildId)); var filter = TableQueryUtil.Column(nameof(BuildFailureEntity.JobName), buildId.JobName); 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); } }
private static string FilterSinceDate(DateTimeOffset startDate) { var key = DateTimeKey.GetDateKey(startDate); return(TableQueryUtil.Column(ColumnName.PartitionKey, key, ColumnOperator.GreaterThanOrEqual)); }