Test for log scanning

This commit is contained in:
Dave Bartolomeo
2022-08-10 18:07:59 -04:00
parent 28092f2b86
commit fdc209ca08
2 changed files with 13122 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
import { expect } from 'chai';
import 'mocha';
import { EvaluationLogProblemReporter, EvaluationLogScannerSet } from '../../src/log-insights/log-scanner';
import { JoinOrderScannerProvider } from '../../src/log-insights/join-order';
import * as path from 'path';
interface TestProblem {
predicateName: string;
raHash: string;
iteration: number;
message: string;
}
class TestProblemReporter implements EvaluationLogProblemReporter {
public readonly problems: TestProblem[] = [];
public reportProblem(predicateName: string, raHash: string, iteration: number, message: string): void {
this.problems.push({
predicateName,
raHash,
iteration,
message
});
}
}
describe('log scanners', function() {
it('should detect bad join orders', async function() {
const scanners = new EvaluationLogScannerSet();
scanners.registerLogScannerProvider(new JoinOrderScannerProvider());
const summaryPath = path.join(__dirname, 'evaluator-log-summaries/bad-join-order.jsonl');
const problemReporter = new TestProblemReporter();
await scanners.scanLog(summaryPath, problemReporter);
expect(problemReporter.problems.length).to.equal(1);
expect(problemReporter.problems[0].predicateName).to.equal('#select#ff');
expect(problemReporter.problems[0].raHash).to.equal('1bb43c97jpmuh8r2v0f9hktim63');
expect(problemReporter.problems[0].iteration).to.equal(0);
expect(problemReporter.problems[0].message).to.equal('Relation \'#select#ff\' has an inefficient join order. Its join order metric is 4961.834409325194, which is larger than the threshold of 50.');
});
});