test(clock): exercise suspended lifecycle actions

This commit is contained in:
2026-09-03 17:29:18 +00:00
parent 000e7e8fa5
commit 0aa549a6c5
7 changed files with 1292 additions and 11 deletions
@@ -306,11 +306,27 @@ export const buildTournamentRuntimeKeys = (profileName: string): string[] => [
`sammo:${profileName}:tournament:source-revision`,
];
export const buildGameClockRuntimeKeys = (profileName: string): string[] => [
`sammo:${profileName}:clock:active-revision`,
`sammo:${profileName}:clock:deadline-generation`,
`sammo:${profileName}:clock:phase`,
];
export const buildProfileResetRuntimeKeys = (profileName: string): string[] => [
...buildTournamentRuntimeKeys(profileName),
...buildGameClockRuntimeKeys(profileName),
];
export const clearTournamentRuntimeKeys = async (
redis: { del(keys: string[]): Promise<number> },
profileName: string
): Promise<number> => redis.del(buildTournamentRuntimeKeys(profileName));
export const clearProfileResetRuntimeKeys = async (
redis: { del(keys: string[]): Promise<number> },
profileName: string
): Promise<number> => redis.del(buildProfileResetRuntimeKeys(profileName));
const buildServerId = (profileName: string, now: Date, installOperationId?: string): string => {
const year = String(now.getFullYear()).slice(-2);
const month = String(now.getMonth() + 1).padStart(2, '0');
@@ -965,6 +981,7 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
private readonly profileReadinessTimeoutMs: number;
private readonly now: () => Date;
private readonly fetchImpl: typeof fetch;
/** Backwards-compatible injection name; the default clears all season-owned RESET keys. */
private readonly clearTournamentRuntimeState: (profileName: string) => Promise<void>;
private readonly cancelGame: typeof defaultCancelGame;
private readonly transitionProfileClockOverride?: GatewayOrchestratorOptions['transitionProfileClock'];
@@ -2779,7 +2796,7 @@ export class GatewayOrchestrator implements GatewayOrchestratorHandle {
const connector = createRedisConnector(resolveRedisConfigFromEnv(this.processConfig.baseEnv ?? process.env));
await connector.connect();
try {
await clearTournamentRuntimeKeys(connector.client, profileName);
await clearProfileResetRuntimeKeys(connector.client, profileName);
} finally {
await connector.disconnect();
}