Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/stack/tests/whole-stack/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ const watchServiceLogs = Effect.fn("WholeStack.watchServiceLogs")(
return [...without, [instance.service, updated] as const];
}),
),
Effect.ignoreCause,
Effect.catchCause((cause) =>
Cause.hasInterruptsOnly(cause)
? Effect.void
: Effect.logError(
`Whole-stack ${instance.service} log stream failed: ${Cause.pretty(cause)}`,
),
),
),
),
{ discard: true },
Expand Down Expand Up @@ -214,8 +220,13 @@ export const wholeStack = Effect.fn("WholeStack.fixture")((runtime: Runtime) =>
: created;
const statuses = yield* Effect.forEach(observed, (instance) =>
instance.status.pipe(
Effect.map((status) => `${instance.service}=${status.lifecycle}`),
Effect.catchCause(() => Effect.succeed(`${instance.service}=unknown`)),
Effect.map(
(status) =>
`${instance.service}=${status.lifecycle}(health=${status.health ?? "undefined"},wakeEnabled=${status.wakeEnabled},error=${status.error?.message ?? "undefined"})`,
),
Effect.catchCause((cause) =>
Effect.succeed(`${instance.service}=unknown(${Cause.pretty(cause)})`),
),
),
);
const tails = yield* Ref.get(logTails);
Expand Down
20 changes: 13 additions & 7 deletions packages/stack/tests/whole-stack/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,23 @@ const stopWithDiagnostics = Effect.fn("WholeStack.stopWithDiagnostics")((fixture
fixture.stack.stop.pipe(
Effect.catchCause((cause) =>
Effect.gen(function* () {
const statuses = yield* statusByService(fixture).pipe(
Effect.catchCause(() => Effect.succeed([])),
const statuses = yield* Effect.forEach(serviceNames, (name) =>
service(fixture, name).status.pipe(
Effect.map(
(status) =>
`${name}=${status.lifecycle}(health=${status.health ?? "undefined"},wakeEnabled=${status.wakeEnabled},error=${status.error?.message ?? "undefined"})`,
),
Effect.catchCause((statusCause) =>
Effect.succeed(`${name}=unknown(${Cause.pretty(statusCause)})`),
),
),
);
const logs = yield* Ref.get(fixture.logTails);
const serviceIds = serviceNames
.map((name) => `${name}=${service(fixture, name).id}`)
.join(",");
yield* Effect.logError(
`Whole-stack stop diagnostics: cause=${Cause.pretty(cause)} serviceIds=${serviceIds} statuses=${statuses
.map(([name, status]) => `${name}=${status.lifecycle}`)
.join(",")} logs=${logs.map(([name, value]) => `${name}: ${value}`).join("\n")}`,
`Whole-stack stop diagnostics: cause=${Cause.pretty(cause)} serviceIds=${serviceIds} statuses=${statuses.join(",")} logs=${logs.map(([name, value]) => `${name}: ${value}`).join("\n")}`,
);
return yield* Effect.failCause(cause);
}),
Expand Down Expand Up @@ -330,9 +336,9 @@ export const defaultLifecycle = (runtime: Runtime) =>
stack: reopenedStack,
services: yield* reopenedStack.services.list,
};
yield* refreshLogTails(reopened);
yield* assertPersistedPolicy(reopened);
yield* clearIdleTimers(reopened);
yield* refreshLogTails(reopened);
yield* reopened.stack.composition.start;
yield* assertColdStart(reopened);
const reopenedColdWorkloads = yield* captureWorkloads(runtime, reopened);
Expand Down Expand Up @@ -471,8 +477,8 @@ export const parallel = (runtime: Runtime) =>
stack: reopenedLeft,
services: yield* reopenedLeft.services.list,
};
yield* refreshLogTails(reopenedLeftFixture);
yield* clearIdleTimers(reopenedLeftFixture);
yield* refreshLogTails(reopenedLeftFixture);
yield* reopenedLeft.composition.start;
expect(
yield* sql(
Expand Down
Loading