Skip to content

Commit 2e0b91d

Browse files
committed
enable guid tests
1 parent 99b73c2 commit 2e0b91d

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

test/e2e-azuremanaged/orchestration.spec.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -508,76 +508,76 @@ describe("Durable Task Scheduler (DTS) E2E Tests", () => {
508508

509509
// // ==================== newGuid Tests ====================
510510

511-
// it("should generate deterministic GUIDs with newGuid", async () => {
512-
// const orchestrator: TOrchestrator = async (ctx: OrchestrationContext) => {
513-
// const guid1 = ctx.newGuid();
514-
// const guid2 = ctx.newGuid();
515-
// const guid3 = ctx.newGuid();
516-
// return { guid1, guid2, guid3 };
517-
// };
511+
it("should generate deterministic GUIDs with newGuid", async () => {
512+
const orchestrator: TOrchestrator = async (ctx: OrchestrationContext) => {
513+
const guid1 = ctx.newGuid();
514+
const guid2 = ctx.newGuid();
515+
const guid3 = ctx.newGuid();
516+
return { guid1, guid2, guid3 };
517+
};
518518

519-
// taskHubWorker.addOrchestrator(orchestrator);
520-
// await taskHubWorker.start();
519+
taskHubWorker.addOrchestrator(orchestrator);
520+
await taskHubWorker.start();
521521

522-
// const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
523-
// const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
522+
const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
523+
const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
524524

525-
// expect(state).toBeDefined();
526-
// expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
525+
expect(state).toBeDefined();
526+
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
527527

528-
// const output = JSON.parse(state?.serializedOutput ?? "{}");
528+
const output = JSON.parse(state?.serializedOutput ?? "{}");
529529

530-
// // Verify GUIDs are in valid format (8-4-4-4-12 hex chars)
531-
// const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
532-
// expect(output.guid1).toMatch(uuidRegex);
533-
// expect(output.guid2).toMatch(uuidRegex);
534-
// expect(output.guid3).toMatch(uuidRegex);
530+
// Verify GUIDs are in valid format (8-4-4-4-12 hex chars)
531+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
532+
expect(output.guid1).toMatch(uuidRegex);
533+
expect(output.guid2).toMatch(uuidRegex);
534+
expect(output.guid3).toMatch(uuidRegex);
535535

536-
// // Verify all GUIDs are unique
537-
// expect(output.guid1).not.toEqual(output.guid2);
538-
// expect(output.guid2).not.toEqual(output.guid3);
539-
// expect(output.guid1).not.toEqual(output.guid3);
540-
// }, 31000);
536+
// Verify all GUIDs are unique
537+
expect(output.guid1).not.toEqual(output.guid2);
538+
expect(output.guid2).not.toEqual(output.guid3);
539+
expect(output.guid1).not.toEqual(output.guid3);
540+
}, 31000);
541541

542-
// it("should generate consistent GUIDs across replays", async () => {
543-
// // This test verifies that newGuid produces the same values across replays
544-
// // by running an orchestration that generates GUIDs, waits, and then returns them
545-
// const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
546-
// // Generate GUIDs before and after a timer
547-
// const guid1 = ctx.newGuid();
548-
// const guid2 = ctx.newGuid();
542+
it("should generate consistent GUIDs across replays", async () => {
543+
// This test verifies that newGuid produces the same values across replays
544+
// by running an orchestration that generates GUIDs, waits, and then returns them
545+
const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
546+
// Generate GUIDs before and after a timer
547+
const guid1 = ctx.newGuid();
548+
const guid2 = ctx.newGuid();
549549

550-
// yield ctx.createTimer(1);
550+
yield ctx.createTimer(1);
551551

552-
// // Generate more GUIDs after replay
553-
// const guid3 = ctx.newGuid();
554-
// const guid4 = ctx.newGuid();
552+
// Generate more GUIDs after replay
553+
const guid3 = ctx.newGuid();
554+
const guid4 = ctx.newGuid();
555555

556-
// // Return all GUIDs - if deterministic, guid3/guid4 should be different from guid1/guid2
557-
// // but consistent across replays (which we verify by the orchestration completing successfully)
558-
// return { guid1, guid2, guid3, guid4 };
559-
// };
556+
// Return all GUIDs - if deterministic, guid3/guid4 should be different from guid1/guid2
557+
// but consistent across replays (which we verify by the orchestration completing successfully)
558+
return { guid1, guid2, guid3, guid4 };
559+
};
560560

561-
// taskHubWorker.addOrchestrator(orchestrator);
562-
// await taskHubWorker.start();
561+
taskHubWorker.addOrchestrator(orchestrator);
562+
await taskHubWorker.start();
563563

564-
// const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
565-
// const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
564+
const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
565+
const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
566566

567-
// expect(state).toBeDefined();
568-
// expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
567+
expect(state).toBeDefined();
568+
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
569569

570-
// const output = JSON.parse(state?.serializedOutput ?? "{}");
570+
const output = JSON.parse(state?.serializedOutput ?? "{}");
571571

572-
// // Verify all 4 GUIDs are unique
573-
// const guids = [output.guid1, output.guid2, output.guid3, output.guid4];
574-
// const uniqueGuids = new Set(guids);
575-
// expect(uniqueGuids.size).toBe(4);
572+
// Verify all 4 GUIDs are unique
573+
const guids = [output.guid1, output.guid2, output.guid3, output.guid4];
574+
const uniqueGuids = new Set(guids);
575+
expect(uniqueGuids.size).toBe(4);
576576

577-
// // Verify all GUIDs are valid UUID v5 format
578-
// const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
579-
// guids.forEach((guid) => expect(guid).toMatch(uuidRegex));
580-
// }, 31000);
577+
// Verify all GUIDs are valid UUID v5 format
578+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
579+
guids.forEach((guid) => expect(guid).toMatch(uuidRegex));
580+
}, 31000);
581581

582582
// // ==================== setCustomStatus Tests ====================
583583

0 commit comments

Comments
 (0)