Clear M1 milestone bugs (T-37, T-39, T-41, T-42, T-44, T-45, T-46, T-48, T-49, T-51, T-52)
This commit is contained in:
parent
199f7beecd
commit
9e259ca43b
18 changed files with 255 additions and 34 deletions
|
|
@ -266,6 +266,19 @@ describe('Environment safety & multi-env isolation', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('blocks leading-zero decimal and octal IPv4 loopback quads like 0127.0.0.1 and 0177.0.0.1 (T-37)', () => {
|
||||
for (const host of ['0127.0.0.1', '00127.0.0.1', '0177.0.0.1', '00.00.00.00']) {
|
||||
const cfg = makeConfig({
|
||||
environment: 'development',
|
||||
mongoUri: `mongodb://trading_admin:pass@${host}:27017/stock`,
|
||||
mongoDatabase: 'stock',
|
||||
});
|
||||
expect(() => assertEnvironmentSafety(cfg, 'dataIngestion', {})).toThrow(
|
||||
/cannot open a writable MongoDB connection to QA MongoDB/
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('blocks multi-host MongoDB seed lists targeting QA loopback :27017 for dataIngestion and dataPipeline', () => {
|
||||
const qaFirstIngestion = makeConfig({
|
||||
environment: 'development',
|
||||
|
|
|
|||
|
|
@ -230,10 +230,27 @@ describe('pipeline builder edge cases', () => {
|
|||
expect(
|
||||
(buildQmBarSpansPipeline()[2] as { $group: Record<string, unknown> }).$group.barCount
|
||||
).toEqual({
|
||||
$sum: 1,
|
||||
$sum: {
|
||||
$cond: [{ $ne: ['$normalizedDate', null] }, 1, 0],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('stored source IDs with leading/trailing spaces are not merged with trimmed IDs', async () => {
|
||||
const reader: BarSpanAggregateReader = {
|
||||
aggregate<T extends Record<string, unknown>>(): T[] {
|
||||
return [
|
||||
{ _id: 'AAPL.US', firstBarDate: '2020-01-02', lastBarDate: '2024-12-31', barCount: 10 },
|
||||
{ _id: ' AAPL.US ', firstBarDate: '2021-01-04', lastBarDate: '2022-12-30', barCount: 5 },
|
||||
] as unknown as T[];
|
||||
},
|
||||
};
|
||||
const result = await computeBarSpans(reader, { sources: ['eod'] });
|
||||
expect(result.index.get('eod', 'AAPL.US')?.barCount).toBe(10);
|
||||
expect(result.index.get('eod', ' AAPL.US ')?.barCount).toBe(5);
|
||||
expect(result.index.sizeForSource('eod')).toBe(2);
|
||||
});
|
||||
|
||||
test('dispatcher rejects unknown sources', () => {
|
||||
expect(() => buildBarSpansPipeline('ib' as unknown as BarSpanSource)).toThrow(RangeError);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -122,7 +122,11 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
_id: '$sourceId',
|
||||
firstBarDate: { $min: '$normalizedDate' },
|
||||
lastBarDate: { $max: '$normalizedDate' },
|
||||
barCount: { $sum: 1 },
|
||||
barCount: {
|
||||
$sum: {
|
||||
$cond: [{ $ne: ['$normalizedDate', null] }, 1, 0],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(eodTargeted).toHaveLength(3);
|
||||
|
|
@ -253,6 +257,10 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
const [left, right] = obj.$eq as [unknown, unknown];
|
||||
return evalExpr(left, doc, vars) === evalExpr(right, doc, vars);
|
||||
}
|
||||
if ('$ne' in obj) {
|
||||
const [left, right] = obj.$ne as [unknown, unknown];
|
||||
return evalExpr(left, doc, vars) !== evalExpr(right, doc, vars);
|
||||
}
|
||||
if ('$gte' in obj) {
|
||||
const [left, right] = obj.$gte as [unknown, unknown];
|
||||
return (evalExpr(left, doc, vars) as number) >= (evalExpr(right, doc, vars) as number);
|
||||
|
|
@ -269,6 +277,12 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
return true;
|
||||
}
|
||||
if ('$cond' in obj) {
|
||||
if (Array.isArray(obj.$cond)) {
|
||||
const [condExpr, thenExpr, elseExpr] = obj.$cond as [unknown, unknown, unknown];
|
||||
return evalExpr(condExpr, doc, vars)
|
||||
? evalExpr(thenExpr, doc, vars)
|
||||
: evalExpr(elseExpr, doc, vars);
|
||||
}
|
||||
const cfg = obj.$cond as { if: unknown; then: unknown; else: unknown };
|
||||
return evalExpr(cfg.if, doc, vars)
|
||||
? evalExpr(cfg.then, doc, vars)
|
||||
|
|
@ -425,7 +439,14 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
}
|
||||
out[field] = maxVal;
|
||||
} else if ('$sum' in accObj) {
|
||||
out[field] = bucket.length;
|
||||
let total = 0;
|
||||
for (const doc of bucket) {
|
||||
const val = evalExpr(accObj.$sum, doc);
|
||||
if (typeof val === 'number') {
|
||||
total += val;
|
||||
}
|
||||
}
|
||||
out[field] = total;
|
||||
}
|
||||
}
|
||||
grouped.push(out);
|
||||
|
|
@ -490,7 +511,7 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
sourceId: 'TZLESS_EXTREMUM.US',
|
||||
firstBarDate: '2024-06-03',
|
||||
lastBarDate: '2024-06-07',
|
||||
barCount: 5,
|
||||
barCount: 2,
|
||||
});
|
||||
expect(result.index.get('qm', 'MIXED:TO')).toEqual({
|
||||
source: 'qm',
|
||||
|
|
@ -505,7 +526,7 @@ describe('bar-span pipeline builders and safety guards', () => {
|
|||
sourceId: 'QM_OLD:TO',
|
||||
firstBarDate: '2024-06-03',
|
||||
lastBarDate: '2024-06-07',
|
||||
barCount: 3,
|
||||
barCount: 2,
|
||||
});
|
||||
// Must not falsely overlap a different listing starting June 10.
|
||||
expect(
|
||||
|
|
@ -731,7 +752,8 @@ describe('computeBarSpans', () => {
|
|||
});
|
||||
|
||||
// 5 unique eod IDs at batchSize 2 => 3 batched queries (never 5 per-symbol queries)
|
||||
expect(batchesSeen).toEqual([['A.US', 'B.US'], ['C.US', 'D.US'], ['E.US']]);
|
||||
// Exact source IDs (including surrounding spaces) are preserved so stored IDs can be targeted.
|
||||
expect(batchesSeen).toEqual([['A.US', ' B.US '], ['C.US', 'D.US'], ['E.US']]);
|
||||
expect(result.bySource.eod?.batchesRun).toBe(3);
|
||||
// Empty targeted list for qm must execute 0 queries (never fall back to a full collection scan)
|
||||
expect(result.bySource.qm?.batchesRun).toBe(0);
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ describe('parseTicker', () => {
|
|||
expect(parseTicker('..TO', 'ceo')).toBeNull();
|
||||
});
|
||||
|
||||
test('enforces listing.class_suffix VARCHAR(12) max length', () => {
|
||||
expect(parseTicker('RY.ABCDEFGHIJKL', 'eod')).toEqual({
|
||||
tickerRoot: 'RY',
|
||||
classSuffix: 'ABCDEFGHIJKL',
|
||||
});
|
||||
expect(parseTicker('RY.ABCDEFGHIJKLM', 'eod')).toBeNull();
|
||||
expect(parseTicker('RY.PR.ABCDEFGHIJ', 'eod')).toBeNull();
|
||||
});
|
||||
|
||||
test('completes 100,000 resolveIsin + parseTicker calls in under 500 ms', () => {
|
||||
const isinCorpus: readonly ResolveIsinInput[] = [
|
||||
{ isin: 'US0378331005' },
|
||||
|
|
|
|||
|
|
@ -116,6 +116,54 @@ describe('Pass 1 classifier edge cases', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
test('routes source codes longer than 32 chars to unresolved and rejects them in SQL generation (T-44)', () => {
|
||||
const exact32 = 'A'.repeat(32);
|
||||
const tooLong33 = 'B'.repeat(33);
|
||||
const result = classifySourceExchanges([
|
||||
{ source: 'eod', code: exact32, operatingMic: 'XNAS' },
|
||||
{ source: 'eod', code: tooLong33, operatingMic: 'XNAS' },
|
||||
]);
|
||||
|
||||
expect(result.mapped.map(row => row.sourceCode)).toEqual([exact32]);
|
||||
expect(result.unresolved.map(row => [row.sourceCode, row.reason])).toEqual([
|
||||
[tooLong33, 'source_code_too_long'],
|
||||
]);
|
||||
|
||||
expect(() =>
|
||||
generateExchangeSeedSql({
|
||||
mappings: [
|
||||
{
|
||||
source: 'eod',
|
||||
sourceCode: tooLong33,
|
||||
role: 'primary_venue',
|
||||
mic: 'XNAS',
|
||||
countryIso: 'US',
|
||||
method: 'operating_mic',
|
||||
},
|
||||
],
|
||||
})
|
||||
).toThrow(/length must be between 1 and 32/);
|
||||
});
|
||||
|
||||
test('deduplicates identical (source, source_code) rows and rejects conflicting duplicates in SQL generation (T-45)', () => {
|
||||
const row = {
|
||||
source: 'eod' as const,
|
||||
sourceCode: 'NASDAQ',
|
||||
role: 'primary_venue' as const,
|
||||
mic: 'XNAS',
|
||||
countryIso: 'US',
|
||||
method: 'operating_mic' as const,
|
||||
};
|
||||
const sql = generateExchangeSeedSql({ mappings: [row, { ...row }] });
|
||||
expect(sql.match(/'eod', 'NASDAQ'/g)).toHaveLength(1);
|
||||
|
||||
expect(() =>
|
||||
generateExchangeSeedSql({
|
||||
mappings: [row, { ...row, mic: 'XNYS' }],
|
||||
})
|
||||
).toThrow(/Conflicting duplicate exchange_source_map row/);
|
||||
});
|
||||
|
||||
test('classification output is identical for every rotation of the input', () => {
|
||||
const records = [
|
||||
{ source: 'eod' as const, code: 'TO', operatingMic: 'XTSE', name: 'Toronto' },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue