mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
test(base): wire integration + parity specs to duckdb runtime
This commit is contained in:
@@ -16,7 +16,7 @@ import { KyselyDB } from '@docmost/db/types/kysely.types';
|
|||||||
import { BaseQueryCacheService } from './base-query-cache.service';
|
import { BaseQueryCacheService } from './base-query-cache.service';
|
||||||
import { QueryCacheConfigProvider } from './query-cache.config';
|
import { QueryCacheConfigProvider } from './query-cache.config';
|
||||||
import { CollectionLoader } from './collection-loader';
|
import { CollectionLoader } from './collection-loader';
|
||||||
import { PostgresExtensionService } from './postgres-extension.service';
|
import { DuckDbRuntime } from './duckdb-runtime';
|
||||||
import { BaseQueryCacheWriteConsumer } from './base-query-cache.write-consumer';
|
import { BaseQueryCacheWriteConsumer } from './base-query-cache.write-consumer';
|
||||||
import { BaseQueryCacheSubscriber } from './base-query-cache.subscriber';
|
import { BaseQueryCacheSubscriber } from './base-query-cache.subscriber';
|
||||||
import { BaseQueryRouter } from './base-query-router';
|
import { BaseQueryRouter } from './base-query-router';
|
||||||
@@ -68,6 +68,9 @@ class FakeEnvService {
|
|||||||
getBaseQueryCacheTempDirectory() {
|
getBaseQueryCacheTempDirectory() {
|
||||||
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
||||||
}
|
}
|
||||||
|
getBaseQueryCacheReaderPoolSize() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
getRedisUrl() {
|
getRedisUrl() {
|
||||||
return REDIS_URL;
|
return REDIS_URL;
|
||||||
}
|
}
|
||||||
@@ -140,7 +143,7 @@ describeIntegration('kill switch: BASE_QUERY_CACHE_ENABLED=false', () => {
|
|||||||
let spaceId: string;
|
let spaceId: string;
|
||||||
let creatorUserId: string | null;
|
let creatorUserId: string | null;
|
||||||
let seededBaseId: string | null = null;
|
let seededBaseId: string | null = null;
|
||||||
let pgExtension: PostgresExtensionService;
|
let runtime: DuckDbRuntime;
|
||||||
let router: BaseQueryRouter;
|
let router: BaseQueryRouter;
|
||||||
let rowService: BaseRowService;
|
let rowService: BaseRowService;
|
||||||
let basePropertyRepo: BasePropertyRepo;
|
let basePropertyRepo: BasePropertyRepo;
|
||||||
@@ -186,7 +189,7 @@ describeIntegration('kill switch: BASE_QUERY_CACHE_ENABLED=false', () => {
|
|||||||
{ provide: EnvironmentService, useClass: DisabledEnvService },
|
{ provide: EnvironmentService, useClass: DisabledEnvService },
|
||||||
{ provide: RedisService, useValue: mockRedisService },
|
{ provide: RedisService, useValue: mockRedisService },
|
||||||
QueryCacheConfigProvider,
|
QueryCacheConfigProvider,
|
||||||
PostgresExtensionService,
|
DuckDbRuntime,
|
||||||
BaseRepo,
|
BaseRepo,
|
||||||
BasePropertyRepo,
|
BasePropertyRepo,
|
||||||
BaseRowRepo,
|
BaseRowRepo,
|
||||||
@@ -202,11 +205,11 @@ describeIntegration('kill switch: BASE_QUERY_CACHE_ENABLED=false', () => {
|
|||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
// Use .init() so onApplicationBootstrap runs. Under the flag-off config
|
// Use .init() so onApplicationBootstrap runs. Under the flag-off config
|
||||||
// every bootstrap hook (extension install, warm-up, subscriber psubscribe)
|
// every bootstrap hook (runtime bootstrap, warm-up, subscriber psubscribe)
|
||||||
// must short-circuit.
|
// must short-circuit.
|
||||||
await moduleRef.init();
|
await moduleRef.init();
|
||||||
|
|
||||||
pgExtension = moduleRef.get(PostgresExtensionService);
|
runtime = moduleRef.get(DuckDbRuntime);
|
||||||
router = moduleRef.get(BaseQueryRouter);
|
router = moduleRef.get(BaseQueryRouter);
|
||||||
rowService = moduleRef.get(BaseRowService);
|
rowService = moduleRef.get(BaseRowService);
|
||||||
basePropertyRepo = moduleRef.get(BasePropertyRepo);
|
basePropertyRepo = moduleRef.get(BasePropertyRepo);
|
||||||
@@ -267,13 +270,13 @@ describeIntegration('kill switch: BASE_QUERY_CACHE_ENABLED=false', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it(
|
it(
|
||||||
'never creates a DuckDB instance and never installs the extension',
|
'never creates a DuckDB instance and never bootstraps the runtime',
|
||||||
async () => {
|
async () => {
|
||||||
// Bootstrap has already run via moduleRef.init() in beforeAll. If any
|
// Bootstrap has already run via moduleRef.init() in beforeAll. If any
|
||||||
// bootstrap hook forgot to gate on the feature flag, DuckDBInstance.create
|
// bootstrap hook forgot to gate on the feature flag, DuckDBInstance.create
|
||||||
// would have fired at least once.
|
// would have fired at least once.
|
||||||
expect(duckdbCreateSpy).toHaveBeenCalledTimes(0);
|
expect(duckdbCreateSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(pgExtension.isReady()).toBe(false);
|
expect(runtime.isReady()).toBe(false);
|
||||||
|
|
||||||
const properties = await basePropertyRepo.findByBaseId(seededBaseId!);
|
const properties = await basePropertyRepo.findByBaseId(seededBaseId!);
|
||||||
const estimateProp = properties.find((p) => p.name === 'Estimate');
|
const estimateProp = properties.find((p) => p.name === 'Estimate');
|
||||||
@@ -459,6 +462,9 @@ describeIntegration('BaseQueryCacheService LRU eviction', () => {
|
|||||||
getBaseQueryCacheTempDirectory() {
|
getBaseQueryCacheTempDirectory() {
|
||||||
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
||||||
}
|
}
|
||||||
|
getBaseQueryCacheReaderPoolSize() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
getRedisUrl() {
|
getRedisUrl() {
|
||||||
return REDIS_URL;
|
return REDIS_URL;
|
||||||
}
|
}
|
||||||
@@ -504,7 +510,7 @@ describeIntegration('BaseQueryCacheService LRU eviction', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: EnvironmentService, useClass: TinyCapEnvService },
|
{ provide: EnvironmentService, useClass: TinyCapEnvService },
|
||||||
QueryCacheConfigProvider,
|
QueryCacheConfigProvider,
|
||||||
PostgresExtensionService,
|
DuckDbRuntime,
|
||||||
BaseRepo,
|
BaseRepo,
|
||||||
BasePropertyRepo,
|
BasePropertyRepo,
|
||||||
BaseRowRepo,
|
BaseRowRepo,
|
||||||
@@ -661,7 +667,7 @@ describeIntegration('BaseQueryCacheService integration', () => {
|
|||||||
const providers: any[] = [
|
const providers: any[] = [
|
||||||
{ provide: EnvironmentService, useClass: FakeEnvService },
|
{ provide: EnvironmentService, useClass: FakeEnvService },
|
||||||
QueryCacheConfigProvider,
|
QueryCacheConfigProvider,
|
||||||
PostgresExtensionService,
|
DuckDbRuntime,
|
||||||
BaseRepo,
|
BaseRepo,
|
||||||
BasePropertyRepo,
|
BasePropertyRepo,
|
||||||
BaseRowRepo,
|
BaseRowRepo,
|
||||||
@@ -1110,6 +1116,9 @@ describeIntegration('BaseQueryCacheService warm-up on boot', () => {
|
|||||||
getBaseQueryCacheTempDirectory() {
|
getBaseQueryCacheTempDirectory() {
|
||||||
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
return require('node:os').tmpdir() + '/docmost-duckdb-test';
|
||||||
}
|
}
|
||||||
|
getBaseQueryCacheReaderPoolSize() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
getRedisUrl() {
|
getRedisUrl() {
|
||||||
return REDIS_URL;
|
return REDIS_URL;
|
||||||
}
|
}
|
||||||
@@ -1148,7 +1157,7 @@ describeIntegration('BaseQueryCacheService warm-up on boot', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: EnvironmentService, useClass: WarmUpEnvService },
|
{ provide: EnvironmentService, useClass: WarmUpEnvService },
|
||||||
QueryCacheConfigProvider,
|
QueryCacheConfigProvider,
|
||||||
PostgresExtensionService,
|
DuckDbRuntime,
|
||||||
BaseRepo,
|
BaseRepo,
|
||||||
BasePropertyRepo,
|
BasePropertyRepo,
|
||||||
BaseRowRepo,
|
BaseRowRepo,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { KyselyDB } from '@docmost/db/types/kysely.types';
|
|||||||
import { BaseQueryCacheService, CacheListOpts } from './base-query-cache.service';
|
import { BaseQueryCacheService, CacheListOpts } from './base-query-cache.service';
|
||||||
import { QueryCacheConfigProvider } from './query-cache.config';
|
import { QueryCacheConfigProvider } from './query-cache.config';
|
||||||
import { CollectionLoader } from './collection-loader';
|
import { CollectionLoader } from './collection-loader';
|
||||||
import { PostgresExtensionService } from './postgres-extension.service';
|
import { DuckDbRuntime } from './duckdb-runtime';
|
||||||
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
import { EnvironmentService } from '../../../integrations/environment/environment.service';
|
||||||
import { FilterNode, PropertySchema, SortSpec } from '../engine';
|
import { FilterNode, PropertySchema, SortSpec } from '../engine';
|
||||||
|
|
||||||
@@ -54,6 +54,9 @@ class ParityEnvService {
|
|||||||
getBaseQueryCacheThreads() {
|
getBaseQueryCacheThreads() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
getBaseQueryCacheReaderPoolSize() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
getRedisUrl() {
|
getRedisUrl() {
|
||||||
return 'redis://localhost:6379';
|
return 'redis://localhost:6379';
|
||||||
}
|
}
|
||||||
@@ -424,7 +427,7 @@ describeIntegration('BaseQueryCacheService ↔ Postgres parity matrix', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: EnvironmentService, useClass: ParityEnvService },
|
{ provide: EnvironmentService, useClass: ParityEnvService },
|
||||||
QueryCacheConfigProvider,
|
QueryCacheConfigProvider,
|
||||||
PostgresExtensionService,
|
DuckDbRuntime,
|
||||||
BaseRepo,
|
BaseRepo,
|
||||||
BasePropertyRepo,
|
BasePropertyRepo,
|
||||||
BaseRowRepo,
|
BaseRowRepo,
|
||||||
|
|||||||
Reference in New Issue
Block a user