Skip to content

Commit

Permalink
Limit items (#186)
Browse files Browse the repository at this point in the history
* Lower the days

* Limit the test case count

* Centralize limits
  • Loading branch information
jaredpar authored Dec 30, 2023
1 parent cf60912 commit 1bce481
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion DevOps.Status/Pages/Status.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DevOps.Util.DotNet;
using DevOps.Util.DotNet.Triage;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand Down Expand Up @@ -32,7 +33,7 @@ public async Task OnGetAsync()

var todayLimit = DateTime.UtcNow - TimeSpan.FromDays(1);
TodayCount = await context.ModelBuilds.Where(x => x.StartTime > todayLimit).CountAsync();
var expiredLimit = DateTime.UtcNow - TimeSpan.FromDays(30);
var expiredLimit = DateTime.UtcNow - TimeSpan.FromDays(DotNetConstants.MaxBuildDays);
ExpiredCount = await context.ModelBuilds.Where(x => x.StartTime < expiredLimit).CountAsync();
}
}
Expand Down
3 changes: 3 additions & 0 deletions DevOps.Util.DotNet/DotNetConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ public static class DotNetConstants
public static string AzureOrganization => "dnceng-public";
public static string DefaultAzureProject => "public";

public const int MaxBuildDays = 14;
public const int MaxTestCaseCount = 200;
public const int MaxStringLength = 4096;
}
}
13 changes: 10 additions & 3 deletions DevOps.Util.DotNet/Triage/TriageContextUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.Extensions.Options;
using Microsoft.VisualBasic;

namespace DevOps.Util.DotNet.Triage
{
Expand Down Expand Up @@ -400,8 +401,15 @@ public async Task<ModelTestRun> EnsureTestRunAsync(ModelBuildAttempt modelBuildA
};
Context.ModelTestRuns.Add(modelTestRun);

int count = 0;
foreach (var dotnetTestCaseResult in testRun.TestCaseResults)
{
count++;
if (count >= DotNetConstants.MaxTestCaseCount)
{
break;
}

var testCaseResult = dotnetTestCaseResult.TestCaseResult;
var testResult = new ModelTestResult()
{
Expand Down Expand Up @@ -476,10 +484,9 @@ string NormalizeString(string? value)
return "";
}

var maxLen = 4096;
if (value.Length > maxLen)
if (value.Length > DotNetConstants.MaxStringLength)
{
value = $"{value.AsSpan().Slice(0, maxLen)}...";
value = $"{value.AsSpan().Slice(0, DotNetConstants.MaxStringLength)}...";
}

return value;
Expand Down

0 comments on commit 1bce481

Please sign in to comment.