Skip to content

Commit 16f9246

Browse files
committed
custom tests
1 parent 48cfaae commit 16f9246

1 file changed

Lines changed: 72 additions & 72 deletions

File tree

test/e2e-azuremanaged/orchestration.spec.ts

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -581,78 +581,78 @@ describe("Durable Task Scheduler (DTS) E2E Tests", () => {
581581

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

584-
// it("should set and retrieve custom status", async () => {
585-
// const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
586-
// ctx.setCustomStatus("Step 1: Starting");
587-
// yield ctx.createTimer(1);
588-
589-
// // Use longer timer to give CI environments more time to observe this status
590-
// ctx.setCustomStatus({ step: 2, message: "Processing" });
591-
// yield ctx.createTimer(5);
592-
593-
// ctx.setCustomStatus("Step 3: Completed");
594-
// return "done";
595-
// };
596-
597-
// taskHubWorker.addOrchestrator(orchestrator);
598-
// await taskHubWorker.start();
599-
600-
// const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
601-
602-
// // Poll for custom status changes - collect all observed statuses
603-
// let foundObjectStatus = false;
604-
// const observedStatuses: string[] = [];
605-
// const startTime = Date.now();
606-
// while (Date.now() - startTime < 20000) {
607-
// const state = await taskHubClient.getOrchestrationState(id);
608-
// if (state?.serializedCustomStatus) {
609-
// const status = state.serializedCustomStatus;
610-
// // Track unique statuses for debugging
611-
// if (!observedStatuses.includes(status)) {
612-
// observedStatuses.push(status);
613-
// }
614-
// if (status.includes("step") && status.includes("Processing")) {
615-
// foundObjectStatus = true;
616-
// break;
617-
// }
618-
// }
619-
// // Poll more frequently
620-
// await new Promise((resolve) => setTimeout(resolve, 200));
621-
// }
622-
623-
// const finalState = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
624-
625-
// expect(finalState).toBeDefined();
626-
// expect(finalState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
627-
// expect(finalState?.serializedCustomStatus).toEqual(JSON.stringify("Step 3: Completed"));
628-
// // Provide better error message on failure - log observed statuses if assertion fails
629-
// if (!foundObjectStatus) {
630-
// console.log("Observed statuses during polling:", observedStatuses);
631-
// }
632-
// expect(foundObjectStatus).toBe(true);
633-
// }, 60000);
634-
635-
// it("should update custom status to empty string when explicitly set", async () => {
636-
// const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
637-
// ctx.setCustomStatus("Initial status");
638-
// yield ctx.createTimer(1);
639-
640-
// // Update custom status to an empty string; this is a valid value and does not clear it.
641-
// ctx.setCustomStatus("");
642-
// return "done";
643-
// };
644-
645-
// taskHubWorker.addOrchestrator(orchestrator);
646-
// await taskHubWorker.start();
647-
648-
// const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
649-
// const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
650-
651-
// expect(state).toBeDefined();
652-
// expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
653-
// // When set to empty string, the serialized value should be '""' (JSON-encoded empty string)
654-
// expect(state?.serializedCustomStatus).toEqual('""');
655-
// }, 31000);
584+
it("should set and retrieve custom status", async () => {
585+
const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
586+
ctx.setCustomStatus("Step 1: Starting");
587+
yield ctx.createTimer(1);
588+
589+
// Use longer timer to give CI environments more time to observe this status
590+
ctx.setCustomStatus({ step: 2, message: "Processing" });
591+
yield ctx.createTimer(5);
592+
593+
ctx.setCustomStatus("Step 3: Completed");
594+
return "done";
595+
};
596+
597+
taskHubWorker.addOrchestrator(orchestrator);
598+
await taskHubWorker.start();
599+
600+
const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
601+
602+
// Poll for custom status changes - collect all observed statuses
603+
let foundObjectStatus = false;
604+
const observedStatuses: string[] = [];
605+
const startTime = Date.now();
606+
while (Date.now() - startTime < 20000) {
607+
const state = await taskHubClient.getOrchestrationState(id);
608+
if (state?.serializedCustomStatus) {
609+
const status = state.serializedCustomStatus;
610+
// Track unique statuses for debugging
611+
if (!observedStatuses.includes(status)) {
612+
observedStatuses.push(status);
613+
}
614+
if (status.includes("step") && status.includes("Processing")) {
615+
foundObjectStatus = true;
616+
break;
617+
}
618+
}
619+
// Poll more frequently
620+
await new Promise((resolve) => setTimeout(resolve, 200));
621+
}
622+
623+
const finalState = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
624+
625+
expect(finalState).toBeDefined();
626+
expect(finalState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
627+
expect(finalState?.serializedCustomStatus).toEqual(JSON.stringify("Step 3: Completed"));
628+
// Provide better error message on failure - log observed statuses if assertion fails
629+
if (!foundObjectStatus) {
630+
console.log("Observed statuses during polling:", observedStatuses);
631+
}
632+
expect(foundObjectStatus).toBe(true);
633+
}, 60000);
634+
635+
it("should update custom status to empty string when explicitly set", async () => {
636+
const orchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
637+
ctx.setCustomStatus("Initial status");
638+
yield ctx.createTimer(1);
639+
640+
// Update custom status to an empty string; this is a valid value and does not clear it.
641+
ctx.setCustomStatus("");
642+
return "done";
643+
};
644+
645+
taskHubWorker.addOrchestrator(orchestrator);
646+
await taskHubWorker.start();
647+
648+
const id = await taskHubClient.scheduleNewOrchestration(orchestrator);
649+
const state = await taskHubClient.waitForOrchestrationCompletion(id, undefined, 30);
650+
651+
expect(state).toBeDefined();
652+
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
653+
// When set to empty string, the serialized value should be '""' (JSON-encoded empty string)
654+
expect(state?.serializedCustomStatus).toEqual('""');
655+
}, 31000);
656656

657657
// ==================== sendEvent Tests ====================
658658

0 commit comments

Comments
 (0)