mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +00:00
test(qa): wheel floor against the floor's own ground; polite tile cache
The Navara wheel check measures clearance against engine.groundFloor's ground (threshold 29 m: the floor keeps 30 m), so tiles streaming under a still camera cannot flake it. The tile cache identifies itself with the repository URL, keeps at most two misses in flight and merges identical ones.
This commit is contained in:
1 parent
da6141be4b
commit
ce985768bc
2 files changed
+94
-2
No files matched your search
@@ -2,6 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
backoffMs,
|
||||
createMissLoader,
|
||||
fetchTile,
|
||||
tileCacheFile,
|
||||
} from '../../scripts/qa/tileCache.mjs';
|
||||
@@ -69,3 +70,46 @@ test('a tile fetch retries 429s, stops after four retries, keeps Accept', async
|
||||
assert.equal(limited.status, 429);
|
||||
assert.equal(calls, 5);
|
||||
});
|
||||
|
||||
test('misses: at most two fetches in flight, identical ones merged, a contact UA', async () => {
|
||||
let inFlight = 0;
|
||||
let most = 0;
|
||||
const calls = [];
|
||||
const releases = [];
|
||||
const loader = createMissLoader({
|
||||
fetchImpl: (url, init) => {
|
||||
calls.push([url, init.headers['User-Agent']]);
|
||||
inFlight++;
|
||||
most = Math.max(most, inFlight);
|
||||
return new Promise((resolve) =>
|
||||
releases.push(() => {
|
||||
inFlight--;
|
||||
resolve(response(200, { 'content-type': 'image/png' }));
|
||||
}),
|
||||
);
|
||||
},
|
||||
wait: async () => {},
|
||||
});
|
||||
const loads = [
|
||||
loader.load('a', null),
|
||||
loader.load('a', null),
|
||||
loader.load('b', null),
|
||||
loader.load('c', null),
|
||||
loader.load('a', 'image/webp'),
|
||||
];
|
||||
for (let round = 0; round < 10 && releases.length; round++) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
releases.splice(0).forEach((release) => release());
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
const tiles = await Promise.all(loads);
|
||||
assert.ok(tiles.every((tile) => tile.status === 200));
|
||||
assert.equal(tiles[0], tiles[1], 'one fetch for two identical misses');
|
||||
assert.equal(calls.length, 4, 'a, b, c and a with another Accept');
|
||||
assert.ok(most <= 2, `${most} fetches in flight`);
|
||||
assert.ok(
|
||||
calls.every(([, agent]) =>
|
||||
agent.includes('https://github.com/bilawalsidhu/gods-eye-view'),
|
||||
),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user