@@ -229,6 +229,7 @@ public async Task PurgeInstances_WithFilter_EndToEnd()
229229 [ InlineData ( true ) ]
230230 public async Task RestartAsync_EndToEnd ( bool restartWithNewInstanceId )
231231 {
232+ using var cts = new CancellationTokenSource ( TimeSpan . FromMinutes ( 1 ) ) ; // Reduced timeout to 1 minute
232233 await using HostTestLifetime server = await this . StartAsync ( ) ;
233234
234235 // Start an initial orchestration with shouldThrow = false to ensure it completes successfully
@@ -238,8 +239,8 @@ public async Task RestartAsync_EndToEnd(bool restartWithNewInstanceId)
238239 // Wait for it to start and then complete
239240 await server . Client . WaitForInstanceStartAsync ( originalInstanceId , default ) ;
240241 await server . Client . RaiseEventAsync ( originalInstanceId , "event" , default ) ;
241- await server . Client . WaitForInstanceCompletionAsync ( originalInstanceId , default ) ;
242-
242+ await server . Client . WaitForInstanceCompletionAsync ( originalInstanceId , cts . Token ) ;
243+
243244 // Verify the original orchestration completed
244245 OrchestrationMetadata ? originalMetadata = await server . Client . GetInstanceAsync ( originalInstanceId , true ) ;
245246 originalMetadata . Should ( ) . NotBeNull ( ) ;
@@ -258,32 +259,29 @@ public async Task RestartAsync_EndToEnd(bool restartWithNewInstanceId)
258259 restartedInstanceId . Should ( ) . Be ( originalInstanceId ) ;
259260 }
260261
261- // Wait for the restarted orchestration to start
262- await server . Client . WaitForInstanceStartAsync ( restartedInstanceId , default ) ;
263-
264- // Verify the restarted orchestration has the same input
265- OrchestrationMetadata ? restartedMetadata = await server . Client . GetInstanceAsync ( restartedInstanceId , true ) ;
266- restartedMetadata . Should ( ) . NotBeNull ( ) ;
267- restartedMetadata ! . Name . Should ( ) . Be ( OrchestrationName ) ;
268- restartedMetadata . SerializedInput . Should ( ) . Be ( "false" ) ;
269-
270262 // Complete the restarted orchestration
271- await server . Client . RaiseEventAsync ( restartedInstanceId , "event" , default ) ;
272- await server . Client . WaitForInstanceCompletionAsync ( restartedInstanceId , default ) ;
263+ await server . Client . RaiseEventAsync ( restartedInstanceId , "event" ) ;
264+
265+ // Wait for completion (with shorter timeout)
266+ using var completionCts = new CancellationTokenSource ( TimeSpan . FromSeconds ( 30 ) ) ;
267+ await server . Client . WaitForInstanceCompletionAsync ( restartedInstanceId , completionCts . Token ) ;
273268
274269 // Verify the restarted orchestration completed
275- restartedMetadata = await server . Client . GetInstanceAsync ( restartedInstanceId , true ) ;
270+ var restartedMetadata = await server . Client . GetInstanceAsync ( restartedInstanceId , true ) ;
276271 restartedMetadata . Should ( ) . NotBeNull ( ) ;
272+ restartedMetadata ! . Name . Should ( ) . Be ( OrchestrationName ) ;
273+ restartedMetadata . SerializedInput . Should ( ) . Be ( "false" ) ;
277274 restartedMetadata ! . RuntimeStatus . Should ( ) . Be ( OrchestrationRuntimeStatus . Completed ) ;
278275 }
279276
280277 [ Fact ]
281278 public async Task RestartAsync_InstanceNotFound_ThrowsArgumentException ( )
282279 {
280+ using var cts = new CancellationTokenSource ( TimeSpan . FromMinutes ( 1 ) ) ; // 1-minute timeout
283281 await using HostTestLifetime server = await this . StartAsync ( ) ;
284282
285283 // Try to restart a non-existent orchestration
286- Func < Task > restartAction = ( ) => server . Client . RestartAsync ( "non-existent-instance-id" ) ;
284+ Func < Task > restartAction = ( ) => server . Client . RestartAsync ( "non-existent-instance-id" , cancellation : cts . Token ) ;
287285
288286 // Should throw ArgumentException
289287 await restartAction . Should ( ) . ThrowAsync < ArgumentException > ( )
0 commit comments