@elench/testkit 0.1.143 → 0.1.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -5
- package/lib/config/database-materialization.mjs +62 -0
- package/lib/config/database.mjs +10 -30
- package/lib/config/index.mjs +27 -7
- package/lib/config-api/index.d.ts +14 -34
- package/lib/config-api/index.mjs +8 -3
- package/lib/database/index.mjs +18 -4
- package/lib/local/kiln-driver.mjs +8 -1
- package/lib/local/orchestrator.mjs +2 -0
- package/lib/runner/results.mjs +8 -2
- package/lib/runner/template.mjs +14 -7
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -230,6 +230,7 @@ import {
|
|
|
230
230
|
defineConfig,
|
|
231
231
|
defineFile,
|
|
232
232
|
environment,
|
|
233
|
+
resource,
|
|
233
234
|
toolchain,
|
|
234
235
|
} from "@elench/testkit/config";
|
|
235
236
|
|
|
@@ -257,9 +258,17 @@ export default defineConfig({
|
|
|
257
258
|
}),
|
|
258
259
|
},
|
|
259
260
|
environments: {
|
|
260
|
-
local: environment.
|
|
261
|
+
local: environment.productionLike({
|
|
261
262
|
target: "frontend",
|
|
262
263
|
data: "reuse",
|
|
264
|
+
resources: {
|
|
265
|
+
databases: {
|
|
266
|
+
api: resource.postgres({
|
|
267
|
+
version: "16",
|
|
268
|
+
extensions: ["vector"],
|
|
269
|
+
}),
|
|
270
|
+
},
|
|
271
|
+
},
|
|
263
272
|
}),
|
|
264
273
|
},
|
|
265
274
|
services: {
|
|
@@ -342,10 +351,15 @@ right way to move expensive browser targets from `next dev` / watch mode to
|
|
|
342
351
|
stable build-and-start flows.
|
|
343
352
|
|
|
344
353
|
`testkit local` starts the same service graph as a persistent local production
|
|
345
|
-
environment instead of a test run.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
354
|
+
environment instead of a test run. Service database declarations stay logical:
|
|
355
|
+
`database.postgres(...)` says the service needs Postgres, while the selected
|
|
356
|
+
environment decides where that database is materialized. Normal `testkit run`
|
|
357
|
+
uses transient host Docker Postgres. `environment.productionLike(...)` uses the
|
|
358
|
+
Kiln driver by default and maps `resources.databases.<serviceName>` to durable
|
|
359
|
+
Postgres appliances for `testkit local up`. It runs template setup,
|
|
360
|
+
`runtime.prepare`, starts dependent services, and records state under
|
|
361
|
+
`.testkit/environments/<name>/` rather than `.testkit/_runs`. Local environment
|
|
362
|
+
processes receive `TESTKIT_ACTIVE=1`, `TESTKIT_MODE=local`, and
|
|
349
363
|
`TESTKIT_LOCAL_ENV=<name>`. Use `data: "reuse"` for fast restarts against the
|
|
350
364
|
existing local runtime database, `data: "reset"` to refresh runtime databases
|
|
351
365
|
from their templates on each launch, or `--rebuild` to destroy and recreate the
|
|
@@ -741,6 +755,9 @@ Git metadata.
|
|
|
741
755
|
`@elench/testkit` provisions Docker-managed local Postgres automatically for
|
|
742
756
|
services that define `database: database.postgres(...)`.
|
|
743
757
|
|
|
758
|
+
- normal test runs always use transient host-managed Postgres
|
|
759
|
+
- named production-like local environments can place the same logical service
|
|
760
|
+
database on a Kiln Postgres appliance via `resources.databases.<serviceName>`
|
|
744
761
|
- template databases are cached
|
|
745
762
|
- runtime databases are cloned from templates when binding is `per-runtime`
|
|
746
763
|
- shared databases are reused when binding is `shared`
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const DEFAULT_LOCAL_IMAGE = "pgvector/pgvector:pg16";
|
|
2
|
+
const DEFAULT_LOCAL_USER = "testkit";
|
|
3
|
+
const DEFAULT_LOCAL_PASSWORD = "testkit";
|
|
4
|
+
|
|
5
|
+
export function buildEnvironmentDatabaseMaterialization(environment = {}) {
|
|
6
|
+
const databases = environment.resources?.databases || {};
|
|
7
|
+
return {
|
|
8
|
+
resourcesByService: Object.fromEntries(
|
|
9
|
+
Object.keys(databases).map((serviceName) => [serviceName, serviceName])
|
|
10
|
+
),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function materializeDatabaseConfig(database, serviceName, materialization = {}) {
|
|
15
|
+
if (!database) return undefined;
|
|
16
|
+
if (database.provider) {
|
|
17
|
+
return materializeExplicitProviderDatabaseConfig(database, serviceName);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const resourceName = materialization.resourcesByService?.[serviceName] || null;
|
|
21
|
+
if (resourceName) {
|
|
22
|
+
return {
|
|
23
|
+
...database,
|
|
24
|
+
provider: "resource",
|
|
25
|
+
selectedBackend: "resource",
|
|
26
|
+
resource: resourceName,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
...database,
|
|
32
|
+
provider: "local",
|
|
33
|
+
selectedBackend: "local",
|
|
34
|
+
image: database.image || DEFAULT_LOCAL_IMAGE,
|
|
35
|
+
user: database.user || DEFAULT_LOCAL_USER,
|
|
36
|
+
password: database.password || DEFAULT_LOCAL_PASSWORD,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function materializeExplicitProviderDatabaseConfig(database, serviceName) {
|
|
41
|
+
if (database.provider === "resource") {
|
|
42
|
+
const resource = String(database.resource || "").trim();
|
|
43
|
+
if (!resource) {
|
|
44
|
+
throw new Error(`Service "${serviceName}" database.resource must be a non-empty string`);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
...database,
|
|
48
|
+
resource,
|
|
49
|
+
selectedBackend: "resource",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (database.provider === "local") {
|
|
53
|
+
return {
|
|
54
|
+
...database,
|
|
55
|
+
selectedBackend: "local",
|
|
56
|
+
image: database.image || DEFAULT_LOCAL_IMAGE,
|
|
57
|
+
user: database.user || DEFAULT_LOCAL_USER,
|
|
58
|
+
password: database.password || DEFAULT_LOCAL_PASSWORD,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`Service "${serviceName}" database.provider must be "local" or "resource"`);
|
|
62
|
+
}
|
package/lib/config/database.mjs
CHANGED
|
@@ -4,50 +4,30 @@ import {
|
|
|
4
4
|
normalizeConfiguredSteps,
|
|
5
5
|
} from "../shared/configured-steps.mjs";
|
|
6
6
|
|
|
7
|
-
const DEFAULT_LOCAL_IMAGE = "pgvector/pgvector:pg16";
|
|
8
|
-
const DEFAULT_LOCAL_USER = "testkit";
|
|
9
|
-
const DEFAULT_LOCAL_PASSWORD = "testkit";
|
|
10
|
-
|
|
11
7
|
export function normalizeDatabaseConfig(explicitService, serviceName) {
|
|
12
8
|
if (explicitService.databaseFrom) return undefined;
|
|
13
9
|
if (!explicitService.database) return undefined;
|
|
14
10
|
|
|
15
11
|
const rawDatabase = explicitService.database;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(rawDatabase, "provider")) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
`Service "${serviceName}" database.provider has been removed. Configure database placement in environments.<name>.resources.databases instead.`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(rawDatabase, "resource")) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`Service "${serviceName}" database.resource has been removed. Configure database placement in environments.<name>.resources.databases instead.`
|
|
20
|
+
);
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
return {
|
|
22
24
|
...rawDatabase,
|
|
23
|
-
provider,
|
|
24
25
|
binding: normalizeDatabaseBinding(rawDatabase.binding || "per-runtime", `Service "${serviceName}" database.binding`),
|
|
25
26
|
reset: rawDatabase.reset !== false,
|
|
26
27
|
sourceSchema: normalizeSourceSchemaConfig(rawDatabase.sourceSchema, serviceName),
|
|
27
28
|
template: normalizeDatabaseTemplateConfig(rawDatabase.template, serviceName),
|
|
28
29
|
serviceName,
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
if (provider === "resource") {
|
|
32
|
-
const resource = String(rawDatabase.resource || "").trim();
|
|
33
|
-
if (!resource) {
|
|
34
|
-
throw new Error(`Service "${serviceName}" database.resource must be a non-empty string`);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
...base,
|
|
38
|
-
resource,
|
|
39
|
-
selectedBackend: "resource",
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...base,
|
|
45
|
-
provider: "local",
|
|
46
|
-
selectedBackend: "local",
|
|
47
|
-
image: rawDatabase.image || DEFAULT_LOCAL_IMAGE,
|
|
48
|
-
user: rawDatabase.user || DEFAULT_LOCAL_USER,
|
|
49
|
-
password: rawDatabase.password || DEFAULT_LOCAL_PASSWORD,
|
|
50
|
-
};
|
|
51
31
|
}
|
|
52
32
|
|
|
53
33
|
export function normalizeDatabaseTemplateConfig(value, serviceName) {
|
package/lib/config/index.mjs
CHANGED
|
@@ -244,19 +244,39 @@ function normalizeEnvironmentConfig(name, environment) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
function normalizeEnvironmentResources(environmentName, resources = {}) {
|
|
247
|
-
if (resources == null) return {};
|
|
247
|
+
if (resources == null) return { databases: {}, servers: {} };
|
|
248
248
|
if (typeof resources !== "object" || Array.isArray(resources)) {
|
|
249
249
|
throw new Error(`Environment "${environmentName}" resources must be an object`);
|
|
250
250
|
}
|
|
251
|
+
const allowedKeys = new Set(["databases", "servers"]);
|
|
252
|
+
const unexpectedKeys = Object.keys(resources).filter((key) => !allowedKeys.has(key));
|
|
253
|
+
if (unexpectedKeys.length > 0) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`Environment "${environmentName}" resources only supports "databases" and "servers". Received unexpected key(s): ${unexpectedKeys.join(", ")}`
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
databases: normalizeEnvironmentResourceGroup(environmentName, "databases", resources.databases, ["postgres"]),
|
|
260
|
+
servers: normalizeEnvironmentResourceGroup(environmentName, "servers", resources.servers, ["server"]),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function normalizeEnvironmentResourceGroup(environmentName, groupName, group = {}, allowedKinds) {
|
|
265
|
+
if (group == null) return {};
|
|
266
|
+
if (typeof group !== "object" || Array.isArray(group)) {
|
|
267
|
+
throw new Error(`Environment "${environmentName}" resources.${groupName} must be an object`);
|
|
268
|
+
}
|
|
251
269
|
return Object.fromEntries(
|
|
252
|
-
Object.entries(
|
|
253
|
-
const normalizedName = normalizeDatabaseEnvToken(name, `Environment "${environmentName}"
|
|
270
|
+
Object.entries(group).map(([name, resource]) => {
|
|
271
|
+
const normalizedName = normalizeDatabaseEnvToken(name, `Environment "${environmentName}" resources.${groupName} name`, false);
|
|
254
272
|
if (!resource || typeof resource !== "object" || Array.isArray(resource)) {
|
|
255
|
-
throw new Error(`Environment "${environmentName}"
|
|
273
|
+
throw new Error(`Environment "${environmentName}" resources.${groupName}.${name} must be an object`);
|
|
256
274
|
}
|
|
257
275
|
const kind = String(resource.kind || "").trim();
|
|
258
|
-
if (!
|
|
259
|
-
throw new Error(
|
|
276
|
+
if (!allowedKinds.includes(kind)) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
`Environment "${environmentName}" resources.${groupName}.${name} kind must be ${allowedKinds.map((entry) => `"${entry}"`).join(" or ")}`
|
|
279
|
+
);
|
|
260
280
|
}
|
|
261
281
|
return [normalizedName, { ...resource, kind }];
|
|
262
282
|
})
|
|
@@ -310,7 +330,7 @@ function normalizeEnvironmentEnv(env) {
|
|
|
310
330
|
const unexpectedKeys = Object.keys(env).filter((key) => !allowedKeys.has(key));
|
|
311
331
|
if (unexpectedKeys.length > 0) {
|
|
312
332
|
throw new Error(
|
|
313
|
-
`Environment env only supports "values" and "
|
|
333
|
+
`Environment env only supports "values", "databases", and "resources". Received unexpected key(s): ${unexpectedKeys.join(", ")}`
|
|
314
334
|
);
|
|
315
335
|
}
|
|
316
336
|
const values = env.values && typeof env.values === "object" && !Array.isArray(env.values) ? env.values : {};
|
|
@@ -85,8 +85,7 @@ export interface StepsBuildConfig {
|
|
|
85
85
|
|
|
86
86
|
export type BuildConfig = TscBuildConfig | ScriptBuildConfig | NextBuildConfig | StepsBuildConfig;
|
|
87
87
|
|
|
88
|
-
export interface
|
|
89
|
-
provider: "local";
|
|
88
|
+
export interface PostgresDatabaseConfig {
|
|
90
89
|
binding?: "shared" | "per-runtime";
|
|
91
90
|
image?: string;
|
|
92
91
|
password?: string;
|
|
@@ -96,17 +95,15 @@ export interface LocalDatabaseConfig {
|
|
|
96
95
|
user?: string;
|
|
97
96
|
}
|
|
98
97
|
|
|
99
|
-
export interface
|
|
98
|
+
export interface MaterializedLocalDatabaseConfig extends PostgresDatabaseConfig {
|
|
99
|
+
provider: "local";
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface MaterializedResourceDatabaseConfig extends PostgresDatabaseConfig {
|
|
100
103
|
provider: "resource";
|
|
101
|
-
binding?: "shared" | "per-runtime";
|
|
102
|
-
reset?: boolean;
|
|
103
104
|
resource: string;
|
|
104
|
-
sourceSchema?: DatabaseSourceSchemaConfig | null;
|
|
105
|
-
template?: DatabaseTemplateConfig;
|
|
106
105
|
}
|
|
107
106
|
|
|
108
|
-
export type PostgresDatabaseConfig = LocalDatabaseConfig | ResourceDatabaseConfig;
|
|
109
|
-
|
|
110
107
|
export interface SkipFileRule {
|
|
111
108
|
path: string;
|
|
112
109
|
reason: string;
|
|
@@ -324,7 +321,10 @@ export interface ServerResourceConfig {
|
|
|
324
321
|
vm?: KilnVMResourceConfig;
|
|
325
322
|
}
|
|
326
323
|
|
|
327
|
-
export
|
|
324
|
+
export interface EnvironmentResourceConfig {
|
|
325
|
+
databases?: Record<string, PostgresResourceConfig>;
|
|
326
|
+
servers?: Record<string, ServerResourceConfig>;
|
|
327
|
+
}
|
|
328
328
|
|
|
329
329
|
export interface LocalEnvironmentConfig {
|
|
330
330
|
kind: "local";
|
|
@@ -335,7 +335,7 @@ export interface LocalEnvironmentConfig {
|
|
|
335
335
|
portOffset?: number;
|
|
336
336
|
productionLike?: boolean;
|
|
337
337
|
publicHost?: string;
|
|
338
|
-
resources?:
|
|
338
|
+
resources?: EnvironmentResourceConfig;
|
|
339
339
|
target: string;
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -625,36 +625,16 @@ export declare const database: {
|
|
|
625
625
|
postgresConnectionFromEnv(prefix: string): unknown;
|
|
626
626
|
};
|
|
627
627
|
postgres(
|
|
628
|
-
options?: Omit<
|
|
628
|
+
options?: Omit<PostgresDatabaseConfig, "template"> & {
|
|
629
629
|
inputs?: string[];
|
|
630
630
|
migrate?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
631
631
|
seed?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
632
632
|
template?: DatabaseTemplateOptions;
|
|
633
633
|
verify?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
634
634
|
}
|
|
635
|
-
):
|
|
636
|
-
postgres(
|
|
637
|
-
options?: Omit<ResourceDatabaseConfig, "provider" | "template"> & {
|
|
638
|
-
inputs?: string[];
|
|
639
|
-
migrate?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
640
|
-
seed?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
641
|
-
template?: DatabaseTemplateOptions;
|
|
642
|
-
verify?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
643
|
-
}
|
|
644
|
-
): ResourceDatabaseConfig;
|
|
645
|
-
fixture(
|
|
646
|
-
options?: Omit<LocalDatabaseConfig, "provider" | "template"> & {
|
|
647
|
-
inputs?: string[];
|
|
648
|
-
migrate?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
649
|
-
seed?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
650
|
-
template?: DatabaseTemplateOptions;
|
|
651
|
-
verify?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
652
|
-
discovery?: DiscoveryConfig;
|
|
653
|
-
envFiles?: string[];
|
|
654
|
-
}
|
|
655
|
-
): ServiceConfig;
|
|
635
|
+
): PostgresDatabaseConfig;
|
|
656
636
|
fixture(
|
|
657
|
-
options?: Omit<
|
|
637
|
+
options?: Omit<PostgresDatabaseConfig, "template"> & {
|
|
658
638
|
inputs?: string[];
|
|
659
639
|
migrate?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
|
660
640
|
seed?: TemplateLifecycleStepConfig | TemplateLifecycleStepConfig[] | string | string[];
|
package/lib/config-api/index.mjs
CHANGED
|
@@ -27,9 +27,14 @@ export function defineFile(metadata) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function postgresDatabase(options = {}) {
|
|
30
|
-
const
|
|
30
|
+
for (const removedKey of ["provider", "resource"]) {
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(options, removedKey)) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`database.postgres(...) no longer accepts "${removedKey}". Configure database placement in environments.<name>.resources.databases instead.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
31
37
|
return {
|
|
32
|
-
provider,
|
|
33
38
|
...options,
|
|
34
39
|
};
|
|
35
40
|
}
|
|
@@ -561,7 +566,7 @@ function normalizePresetEnv(env) {
|
|
|
561
566
|
const unexpectedKeys = Object.keys(env).filter((key) => !allowedKeys.has(key));
|
|
562
567
|
if (unexpectedKeys.length > 0) {
|
|
563
568
|
throw new Error(
|
|
564
|
-
`Preset env only supports "values" and "
|
|
569
|
+
`Preset env only supports "values", "databases", and "resources". Received unexpected key(s): ${unexpectedKeys.join(", ")}`
|
|
565
570
|
);
|
|
566
571
|
}
|
|
567
572
|
|
package/lib/database/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
runTemplateStage,
|
|
29
29
|
runTemplateStep,
|
|
30
30
|
} from "./template-steps.mjs";
|
|
31
|
+
import { materializeDatabaseConfig } from "../config/database-materialization.mjs";
|
|
31
32
|
import {
|
|
32
33
|
applySourceSchemaCache,
|
|
33
34
|
createSourceSchemaMismatchError,
|
|
@@ -49,16 +50,29 @@ const LOCAL_DROP_DATABASE_TIMEOUT_MS = 15_000;
|
|
|
49
50
|
const LOCAL_DROP_DATABASE_POLL_INTERVAL_MS = 250;
|
|
50
51
|
|
|
51
52
|
export async function prepareDatabaseRuntime(config, options = {}) {
|
|
52
|
-
const db =
|
|
53
|
+
const db = materializeDatabaseConfig(
|
|
54
|
+
config.testkit.database,
|
|
55
|
+
config.name,
|
|
56
|
+
options.databaseMaterialization || {}
|
|
57
|
+
);
|
|
53
58
|
if (!db) return;
|
|
59
|
+
const runtimeConfig = db === config.testkit.database
|
|
60
|
+
? config
|
|
61
|
+
: {
|
|
62
|
+
...config,
|
|
63
|
+
testkit: {
|
|
64
|
+
...config.testkit,
|
|
65
|
+
database: db,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
54
68
|
|
|
55
|
-
fs.mkdirSync(
|
|
69
|
+
fs.mkdirSync(runtimeConfig.stateDir, { recursive: true });
|
|
56
70
|
if (db.provider === "local") {
|
|
57
|
-
await prepareLocalDatabase(
|
|
71
|
+
await prepareLocalDatabase(runtimeConfig, options);
|
|
58
72
|
return;
|
|
59
73
|
}
|
|
60
74
|
if (db.provider === "resource") {
|
|
61
|
-
await prepareResourceDatabase(
|
|
75
|
+
await prepareResourceDatabase(runtimeConfig, options);
|
|
62
76
|
return;
|
|
63
77
|
}
|
|
64
78
|
|
|
@@ -250,7 +250,7 @@ async function attachExistingVMs(client, network, vmRefs) {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
async function ensureResources(client, environment, network) {
|
|
253
|
-
const configured = environment.resources || {};
|
|
253
|
+
const configured = flattenEnvironmentResources(environment.resources || {});
|
|
254
254
|
const manifest = {};
|
|
255
255
|
const connections = {};
|
|
256
256
|
for (const [name, resource] of Object.entries(configured)) {
|
|
@@ -282,6 +282,13 @@ async function ensureResources(client, environment, network) {
|
|
|
282
282
|
return { manifest, connections };
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
export function flattenEnvironmentResources(resources = {}) {
|
|
286
|
+
return {
|
|
287
|
+
...(resources.databases || {}),
|
|
288
|
+
...(resources.servers || {}),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
285
292
|
export function buildPostgresApplianceRequest(name, resource, environment, network) {
|
|
286
293
|
const extensions = normalizePostgresExtensions(resource.extensions);
|
|
287
294
|
const image = resolvePostgresResourceImage(resource, name);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
|
+
import { buildEnvironmentDatabaseMaterialization } from "../config/database-materialization.mjs";
|
|
4
5
|
import { loadConfigContext } from "../config/index.mjs";
|
|
5
6
|
import { prepareDatabaseRuntime } from "../database/index.mjs";
|
|
6
7
|
import { prepareRuntimeServices } from "../runner/runtime-preparation.mjs";
|
|
@@ -186,6 +187,7 @@ export function buildLocalRuntimeConfigs(allConfigs, environment, runtimeDir) {
|
|
|
186
187
|
graphDirName: runtimeConfigs.map((config) => config.name).sort().join("__"),
|
|
187
188
|
portOffset: environment.portOffset || 0,
|
|
188
189
|
publicHost: environment.publicHost || null,
|
|
190
|
+
databaseMaterialization: buildEnvironmentDatabaseMaterialization(environment),
|
|
189
191
|
}).map((config) => applyLocalEnvironmentConfig(config, environment));
|
|
190
192
|
}
|
|
191
193
|
|
package/lib/runner/results.mjs
CHANGED
|
@@ -8,7 +8,7 @@ export function buildServiceTrackers(servicePlans, startedAt) {
|
|
|
8
8
|
if (plan.skipped) {
|
|
9
9
|
trackers.set(plan.config.name, {
|
|
10
10
|
name: plan.config.name,
|
|
11
|
-
dbBackend: plan.config
|
|
11
|
+
dbBackend: inferDatabaseBackend(plan.config),
|
|
12
12
|
skipped: true,
|
|
13
13
|
suiteCount: 0,
|
|
14
14
|
suites: [],
|
|
@@ -73,7 +73,7 @@ export function buildServiceTrackers(servicePlans, startedAt) {
|
|
|
73
73
|
|
|
74
74
|
trackers.set(plan.config.name, {
|
|
75
75
|
name: plan.config.name,
|
|
76
|
-
dbBackend: plan.config
|
|
76
|
+
dbBackend: inferDatabaseBackend(plan.config),
|
|
77
77
|
skipped: false,
|
|
78
78
|
suiteCount: suites.length,
|
|
79
79
|
suites,
|
|
@@ -90,6 +90,12 @@ export function buildServiceTrackers(servicePlans, startedAt) {
|
|
|
90
90
|
return trackers;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function inferDatabaseBackend(config) {
|
|
94
|
+
const database = config.testkit.database;
|
|
95
|
+
if (!database) return null;
|
|
96
|
+
return database.selectedBackend || database.provider || "local";
|
|
97
|
+
}
|
|
98
|
+
|
|
93
99
|
export function recordTaskOutcome(trackers, task, outcome, finishedAt = Date.now()) {
|
|
94
100
|
const tracker = trackers.get(task.serviceName);
|
|
95
101
|
if (!tracker || tracker.skipped) return;
|
package/lib/runner/template.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
finalizeConfiguredInputs,
|
|
4
4
|
finalizeConfiguredSteps,
|
|
5
5
|
} from "../shared/configured-steps.mjs";
|
|
6
|
+
import { materializeDatabaseConfig } from "../config/database-materialization.mjs";
|
|
6
7
|
import { readDatabaseInfo } from "./state-io.mjs";
|
|
7
8
|
|
|
8
9
|
const PORT_STRIDE = 100;
|
|
@@ -75,7 +76,8 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
|
|
|
75
76
|
publicBaseUrlByService,
|
|
76
77
|
options.publicHost || null,
|
|
77
78
|
stateDirByService,
|
|
78
|
-
urlMappings
|
|
79
|
+
urlMappings,
|
|
80
|
+
options.databaseMaterialization || {}
|
|
79
81
|
)
|
|
80
82
|
);
|
|
81
83
|
}
|
|
@@ -123,7 +125,8 @@ export function resolveRuntimeConfig(
|
|
|
123
125
|
publicBaseUrlByService,
|
|
124
126
|
publicHost,
|
|
125
127
|
stateDirByService,
|
|
126
|
-
urlMappings
|
|
128
|
+
urlMappings,
|
|
129
|
+
databaseMaterialization = {}
|
|
127
130
|
) {
|
|
128
131
|
const stateDir = resolveServiceStateDir(runtimeDir, config);
|
|
129
132
|
const prepareDir = resolveServicePrepareDir(runtimeDir, config);
|
|
@@ -147,11 +150,15 @@ export function resolveRuntimeConfig(
|
|
|
147
150
|
};
|
|
148
151
|
|
|
149
152
|
const database = config.testkit.database
|
|
150
|
-
?
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
? materializeDatabaseConfig(
|
|
154
|
+
{
|
|
155
|
+
...config.testkit.database,
|
|
156
|
+
sourceSchema: finalizeSourceSchema(config.testkit.database.sourceSchema, context),
|
|
157
|
+
template: finalizeDatabaseTemplate(config.testkit.database.template, context),
|
|
158
|
+
},
|
|
159
|
+
config.name,
|
|
160
|
+
databaseMaterialization
|
|
161
|
+
)
|
|
155
162
|
: undefined;
|
|
156
163
|
|
|
157
164
|
const runtime = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.144",
|
|
4
4
|
"description": "Browser bridge helpers for testkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@elench/testkit-protocol": "0.1.
|
|
25
|
+
"@elench/testkit-protocol": "0.1.144"
|
|
26
26
|
},
|
|
27
27
|
"private": false
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.144",
|
|
4
4
|
"description": "Assistant-first CLI for running, inspecting, and debugging local testkit suites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -98,10 +98,10 @@
|
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"@babel/code-frame": "^7.29.0",
|
|
101
|
-
"@elench/next-analysis": "0.1.
|
|
102
|
-
"@elench/testkit-bridge": "0.1.
|
|
103
|
-
"@elench/testkit-protocol": "0.1.
|
|
104
|
-
"@elench/ts-analysis": "0.1.
|
|
101
|
+
"@elench/next-analysis": "0.1.144",
|
|
102
|
+
"@elench/testkit-bridge": "0.1.144",
|
|
103
|
+
"@elench/testkit-protocol": "0.1.144",
|
|
104
|
+
"@elench/ts-analysis": "0.1.144",
|
|
105
105
|
"@oclif/core": "^4.10.6",
|
|
106
106
|
"@playwright/test": "^1.52.0",
|
|
107
107
|
"esbuild": "^0.25.11",
|