Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tests: GameInputsTests fetch tests get a timeout above the 600 s cap (refs #503) (#522)

Eyal Golandaa1c47d432b
diff --git a/docs/m3-rulings.md b/docs/m3-rulings.md
index 3e9935d8b..4286869b5 100644
--- a/docs/m3-rulings.md
+++ b/docs/m3-rulings.md
@@ -105,7 +105,7 @@ These are the decisions made while building M3 where the spec or plan was silent
- The Mac IL2CPP player prints the same golden lines.
- The brotli build is checked with web_check at release.
- Cost if wrong: WebGL parity regressions go unnoticed.
-- **Content ships through ContentSync.** Content goes to git-ignored StreamingAssets, verified against the manifest. WebGL fetch uses a 60 s wall-clock wait in tests, never a frame count. The original 600-frame wait was flaky.
+- **Content ships through ContentSync.** Content goes to git-ignored StreamingAssets, verified against the manifest. WebGL fetch waits in tests on the wall clock, never a frame count. The original 600-frame wait was flaky. The fixed 60 s wait that replaced it also failed under load (#503), so the tests now fail a fetch only after 60 s without progress, with a 600 s cap on the whole wait and a test timeout above that cap.
- **Build safety.**
- Settings changes are staged before any build, because `git checkout --` restores from the index and would discard unstaged settings.
- Build logs use the `unity-*.log` names that are already git-ignored.
diff --git a/unity/Assets/Tests/EditMode/GameInputsTests.cs b/unity/Assets/Tests/EditMode/GameInputsTests.cs
index 1f8b04736..5f0d614b4 100644
--- a/unity/Assets/Tests/EditMode/GameInputsTests.cs
+++ b/unity/Assets/Tests/EditMode/GameInputsTests.cs
@@ -64,7 +64,7 @@ public class GameInputsTests
return site;
}
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator FetchingOverUrlsLoadsTheSameContentAsTheDisk()
{
var site = StagedSite();
@@ -82,7 +82,7 @@ public class GameInputsTests
Directory.Delete(site, true);
}
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator AMissingFileNamesTheFile()
{
var site = StagedSite();
@@ -94,7 +94,7 @@ public class GameInputsTests
Directory.Delete(site, true);
}
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator AFailedFetchLeavesNoRequestOpen()
{
var site = StagedSite();
@@ -185,11 +185,15 @@ public class GameInputsTests
/// <summary>A generous cap on the whole wait, ten times the stall limit: a fetch that keeps changing its open requests
/// but never finishes (a retry loop) still fails instead of hanging the EditMode run.</summary>
const float CapSeconds = 600f;
+ /// <summary>The Unity Test Framework's own limit for each test that waits on a fetch, in milliseconds: the cap plus a
+ /// minute. Without it UTF stops a [UnityTest] after its default 180 s, before a slow fetch that is still making
+ /// progress reaches the cap, and with a bare timeout message instead of the wait's own.</summary>
+ const int FetchTestTimeoutMs = (int)(CapSeconds * 1000) + 60_000;
- /// <summary>Waits for a fetch for as long as it makes progress: it fails only when GameInputs.OpenRequests (requests
- /// started and not yet released) has not changed for StallSeconds. The manifest's request is released and every file's
- /// started, then each file's request is released as the fetch takes it (a retry releases one and starts another), so
- /// the count keeps moving while the fetch works.
+ /// <summary>Waits for a fetch for as long as it makes progress: it fails when GameInputs.OpenRequests (requests
+ /// started and not yet released) has not changed for StallSeconds, or once CapSeconds have passed in all. The
+ /// manifest's request is released and every file's started, then each file's request is released as the fetch takes
+ /// it (a retry releases one and starts another), so the count keeps moving while the fetch works.
/// A batch-mode editor runs the player loop (which resumes Awaitable.NextFrameAsync) only now and then while idle: a
/// retry's 0.5 s backoff measured 57 s over 2 frames. Each tick queues a player-loop update, as a player runs one
/// every frame.</summary>
@@ -272,12 +276,12 @@ public class GameInputsTests
finally { Directory.Delete(site, true); }
}
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator DroppedConnectionsAreRetried() =>
FetchesTheDiskContentDespite(new Dictionary<string, (string, int)> { ["content/events/israel_bonds.yaml"] = ("drop", 2) },
server => Assert.AreEqual(3, server.Hits("content/events/israel_bonds.yaml")));
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator AServerErrorIsRetried() =>
FetchesTheDiskContentDespite(new Dictionary<string, (string, int)> { ["content/people.yaml"] = ("503", 1), ["map/heightmap.r16z"] = ("500", 2) },
server =>
@@ -286,7 +290,7 @@ public class GameInputsTests
Assert.AreEqual(3, server.Hits("map/heightmap.r16z"));
});
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator AConnectionThatKeepsDroppingFailsNamingTheFileWithNothingLeftOpen()
{
var site = StagedSite();
@@ -320,7 +324,7 @@ public class GameInputsTests
CollectionAssert.AreEqual(new[] { 0.5f, 1f, 2f }, new[] { GameInputs.Backoff(1), GameInputs.Backoff(2), GameInputs.Backoff(3) });
}
- [UnityTest]
+ [UnityTest, Timeout(FetchTestTimeoutMs)]
public IEnumerator ANotFoundFileIsNotRetried()
{
var site = StagedSite();