@elench/testkit 0.1.38 → 0.1.39

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.
@@ -1,11 +1,6 @@
1
1
  import { formatError } from "./formatting.mjs";
2
2
  import { runDalBatch, runHttpK6Batch } from "./default-runtime-runner.mjs";
3
3
  import { runPlaywrightBatch } from "./playwright-runner.mjs";
4
- import {
5
- cleanupWorker,
6
- ensureWorkerGraph,
7
- resetCurrentGraph,
8
- } from "./runtime-contexts.mjs";
9
4
 
10
5
  const HTTP_K6_TYPES = new Set(["integration", "e2e", "load"]);
11
6
 
@@ -14,7 +9,6 @@ export function createWorker(workerId, productDir) {
14
9
  workerId,
15
10
  productDir,
16
11
  currentGraphKey: null,
17
- graphContexts: new Map(),
18
12
  graphSwitches: 0,
19
13
  taskCount: 0,
20
14
  };
@@ -23,7 +17,7 @@ export function createWorker(workerId, productDir) {
23
17
  export async function runWorker(
24
18
  worker,
25
19
  queue,
26
- graphByKey,
20
+ stackManager,
27
21
  trackers,
28
22
  timingUpdates,
29
23
  lifecycle,
@@ -32,7 +26,7 @@ export async function runWorker(
32
26
  recordGraphError
33
27
  ) {
34
28
  const startedAt = Date.now();
35
- console.log(`\n══ global worker ${worker.workerId} ══`);
29
+ console.log(`\n══ worker ${worker.workerId} ══`);
36
30
  const errors = [];
37
31
 
38
32
  try {
@@ -41,9 +35,14 @@ export async function runWorker(
41
35
  const batch = claimNextBatch(queue, worker.currentGraphKey);
42
36
  if (!batch) break;
43
37
 
38
+ let lease = null;
44
39
  try {
45
- const context = await ensureWorkerGraph(worker, batch, graphByKey, lifecycle);
46
- const outcomes = await runBatch(context, batch, lifecycle);
40
+ if (worker.currentGraphKey && worker.currentGraphKey !== batch.graphKey) {
41
+ worker.graphSwitches += 1;
42
+ }
43
+ worker.currentGraphKey = batch.graphKey;
44
+ lease = await stackManager.acquire(batch);
45
+ const outcomes = await runBatch(lease.context, batch, lifecycle);
47
46
  for (const outcome of outcomes) {
48
47
  recordTaskOutcome(trackers, outcome.task, outcome);
49
48
  timingUpdates.push({
@@ -52,15 +51,19 @@ export async function runWorker(
52
51
  });
53
52
  worker.taskCount += 1;
54
53
  }
54
+ await stackManager.release(lease, { accessMode: batch.accessMode });
55
55
  } catch (error) {
56
56
  const message = formatError(error);
57
57
  errors.push(message);
58
- recordGraphError(trackers, graphByKey.get(batch.graphKey), message);
59
- await resetCurrentGraph(worker, lifecycle);
58
+ recordGraphError(trackers, { assignedTargets: lease?.context?.assignedTargets || [batch.targetName] }, message);
59
+ await stackManager.release(lease, {
60
+ accessMode: batch.accessMode,
61
+ invalidate: lease !== null,
62
+ });
60
63
  }
61
64
  }
62
65
  } finally {
63
- await cleanupWorker(worker, lifecycle);
66
+ worker.currentGraphKey = null;
64
67
  }
65
68
 
66
69
  return {
@@ -76,7 +79,7 @@ export async function runWorker(
76
79
  async function runBatch(context, batch, lifecycle) {
77
80
  const targetConfig = context.configByName.get(batch.targetName);
78
81
  if (!targetConfig) {
79
- throw new Error(`Worker graph missing target config "${batch.targetName}"`);
82
+ throw new Error(`Stack is missing target config "${batch.targetName}"`);
80
83
  }
81
84
 
82
85
  if (batch.framework === "playwright") {
@@ -33,6 +33,27 @@ export interface SkipConfig {
33
33
  suites?: SkipSuiteRule[];
34
34
  }
35
35
 
36
+ export interface SuiteExecutionRule {
37
+ selector: string;
38
+ stackMode: "shared" | "pooled" | "isolated";
39
+ }
40
+
41
+ export interface FileExecutionRule {
42
+ path: string;
43
+ stackMode: "shared" | "pooled" | "isolated";
44
+ }
45
+
46
+ export interface ServiceExecutionConfig {
47
+ suites?: SuiteExecutionRule[];
48
+ files?: FileExecutionRule[];
49
+ }
50
+
51
+ export interface TestkitExecutionConfig {
52
+ workers?: number;
53
+ stackMode?: "shared" | "pooled" | "isolated";
54
+ stackCount?: number;
55
+ }
56
+
36
57
  export interface ServiceConfig {
37
58
  database?: LocalDatabaseConfig;
38
59
  databaseFrom?: string;
@@ -55,9 +76,11 @@ export interface ServiceConfig {
55
76
  migrate?: LifecycleConfig;
56
77
  seed?: LifecycleConfig;
57
78
  skip?: SkipConfig;
79
+ execution?: ServiceExecutionConfig;
58
80
  }
59
81
 
60
82
  export interface TestkitSetup {
83
+ execution?: TestkitExecutionConfig;
61
84
  profiles?: {
62
85
  http?: Record<string, HttpSuiteConfig>;
63
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
5
5
  "type": "module",
6
6
  "types": "./lib/index.d.ts",