fix(data-plane): accept exact replacement replays
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { assertPublishMatchesDefinition } from "../src/data-product-delivery.mjs";
|
||||
import {
|
||||
assertPublishMatchesDefinition,
|
||||
classifyReplacementGeneration,
|
||||
} from "../src/data-product-delivery.mjs";
|
||||
import { normalizeDataProductDefinition } from "../src/data-product-policy.mjs";
|
||||
|
||||
const definition = normalizeDataProductDefinition({
|
||||
@@ -92,4 +95,42 @@ assert.doesNotThrow(() => assertPublishMatchesDefinition({
|
||||
}],
|
||||
}, legacyDefinition));
|
||||
|
||||
const acceptedGeneration = "2026-07-15T10:10:00.000Z";
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: null,
|
||||
generationAt: acceptedGeneration,
|
||||
}), "advance");
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: acceptedGeneration,
|
||||
generationAt: "2026-07-15T10:11:00.000Z",
|
||||
}), "advance");
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: acceptedGeneration,
|
||||
generationAt: acceptedGeneration,
|
||||
incomingCount: 903,
|
||||
currentCount: 903,
|
||||
matchingCount: 903,
|
||||
}), "replay");
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: acceptedGeneration,
|
||||
generationAt: acceptedGeneration,
|
||||
incomingCount: 903,
|
||||
currentCount: 903,
|
||||
matchingCount: 902,
|
||||
}), "conflict");
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: acceptedGeneration,
|
||||
generationAt: acceptedGeneration,
|
||||
incomingCount: 902,
|
||||
currentCount: 903,
|
||||
matchingCount: 902,
|
||||
}), "conflict");
|
||||
assert.equal(classifyReplacementGeneration({
|
||||
currentGenerationAt: acceptedGeneration,
|
||||
generationAt: "2026-07-15T10:09:00.000Z",
|
||||
incomingCount: 903,
|
||||
currentCount: 903,
|
||||
matchingCount: 903,
|
||||
}), "stale");
|
||||
|
||||
console.log("external-data-plane data product delivery policy: ok");
|
||||
|
||||
Reference in New Issue
Block a user