test(engine): scale the Default time-limit test's limit from the unlimited solve

DefaultUnderATimeLimitReturnsAValidPlanNoWorseThanUnlimited failed on CI
(runs 41219924107 and 41224809174, Engine.Tests job): the fixed 5 s limit
assumed the unlimited Default solve takes well under a second, but it takes
about 4 s locally and longer on a loaded runner. A limit shorter than the
normal Irregular search correctly returns an earlier, worse plan, so the
assertion only holds when the limit covers that search. Use the larger of
5 s and three times the measured unlimited solve.

Red: the old test fails on one CPU shared with three busy loops; the new
one passes there. Full Engine.Tests: 2780 passed, 2 skipped.
This commit is contained in:
aj committed 2026-10-31 17:31:46 -04:00
1 parent 561f5be06c
commit 817c4482eb
1 file changed
+7 -4
@@ -213,13 +213,16 @@ public class IrregularSearchUntilCancelledTests
public void DefaultUnderATimeLimitReturnsAValidPlanNoWorseThanUnlimited()
{
// Irregular runs last under Default and searches until the limit; its plans compete
// with the Rectangles and Circles results already reported. The limit leaves a wide
// margin over the unlimited solve (well under a second here) so a slow machine passes.
// with the Rectangles and Circles results already reported. A limit shorter than the
// normal search correctly returns an earlier, worse plan, so the limit is scaled from
// the measured unlimited solve: seconds on a loaded CI runner, not a fixed constant.
var job = MixedJob(false);
var watch = System.Diagnostics.Stopwatch.StartNew();
var normal = new DefaultNestingEngine().Solve(job);
var limit = TimeSpan.FromTicks(
System.Math.Max(TimeSpan.FromSeconds(5).Ticks, 3 * watch.Elapsed.Ticks));
var limited = new DeadlineNestingEngine(new DefaultNestingEngine(), TimeSpan.FromSeconds(5))
.Solve(job);
var limited = new DeadlineNestingEngine(new DefaultNestingEngine(), limit).Solve(job);
LayoutAssert.Valid(job, limited);
Assert.False(CandidateScore.Of(job, normal, 0).IsBetterThan(CandidateScore.Of(job, limited, 0)));