9
9
using System . Threading . Tasks ;
10
10
using System . Threading . Tasks . Dataflow ;
11
11
using Microsoft . AspNetCore . Hosting ;
12
+ using Microsoft . Azure . WebJobs . Host ;
12
13
using Microsoft . Azure . WebJobs . Host . Executors . Internal ;
13
14
using Microsoft . Azure . WebJobs . Script . Config ;
14
15
using Microsoft . Azure . WebJobs . Script . Description ;
@@ -559,25 +560,21 @@ public async Task FunctionDispatcher_RestartOfTimedOutChannels_WebHostFailsCurre
559
560
560
561
SetUpMocksForTimeoutTests ( mockWebHostChannelManager , mockJobHostChannelManager , mockChannel , invocationId , true ) ;
561
562
562
- // Setup for initialization of a new channel
563
563
var workerConfig = new RpcWorkerConfig
564
564
{
565
565
Description = new RpcWorkerDescription { Language = "test" } ,
566
566
CountOptions = new WorkerProcessCountOptions { ProcessCount = 1 }
567
567
} ;
568
568
569
- // Create the dispatcher with our mocks
570
569
var dispatcher = GetTestFunctionDispatcher ( mockwebHostLanguageWorkerChannelManager : mockWebHostChannelManager , mockJobHostLanguageWorkerChannelManager : mockJobHostChannelManager ) ;
571
570
572
- // Act
573
- var result = await dispatcher . RestartWorkerWithInvocationIdAsync ( invocationId ) ;
571
+ var result = await dispatcher . RestartWorkerWithInvocationIdAsync ( invocationId , new FunctionTimeoutException ( ) ) ;
574
572
575
- // Assert
576
573
Assert . True ( result ) ;
577
574
mockWebHostChannelManager . Verify ( m => m . ShutdownChannelIfExistsAsync (
578
575
It . IsAny < string > ( ) ,
579
576
It . Is < string > ( id => id == "testChannelId" ) ,
580
- It . Is < Exception > ( ex => ex is TimeoutException && ex . Message == $ "Executing invocation ` { invocationId } ` timed out" ) ) ,
577
+ It . Is < Exception > ( ex => ex is FunctionTimeoutException ) ) ,
581
578
Times . Once ) ;
582
579
}
583
580
@@ -591,24 +588,20 @@ public async Task FunctionDispatcher_RestartOfTimedOutChannels_JobHostFailsCurre
591
588
592
589
SetUpMocksForTimeoutTests ( mockWebHostChannelManager , mockJobHostChannelManager , mockChannel , invocationId , false ) ;
593
590
594
- // Setup for initialization of a new channel
595
591
var workerConfig = new RpcWorkerConfig
596
592
{
597
593
Description = new RpcWorkerDescription { Language = "test" } ,
598
594
CountOptions = new WorkerProcessCountOptions { ProcessCount = 1 }
599
595
} ;
600
596
601
- // Create the dispatcher with our mocks
602
597
var dispatcher = GetTestFunctionDispatcher ( mockwebHostLanguageWorkerChannelManager : mockWebHostChannelManager , mockJobHostLanguageWorkerChannelManager : mockJobHostChannelManager ) ;
603
598
604
- // Act
605
- var result = await dispatcher . RestartWorkerWithInvocationIdAsync ( invocationId ) ;
599
+ var result = await dispatcher . RestartWorkerWithInvocationIdAsync ( invocationId , new FunctionTimeoutException ( ) ) ;
606
600
607
- // Assert
608
601
Assert . True ( result ) ;
609
602
mockJobHostChannelManager . Verify ( m => m . ShutdownChannelIfExistsAsync (
610
603
It . Is < string > ( id => id == "testChannelId" ) ,
611
- It . Is < Exception > ( ex => ex is TimeoutException && ex . Message == $ "Executing invocation ` { invocationId } ` timed out" ) ) ,
604
+ It . Is < Exception > ( ex => ex is FunctionTimeoutException ) ) ,
612
605
Times . Once ) ;
613
606
}
614
607
@@ -956,13 +949,13 @@ private void SetUpMocksForTimeoutTests(Mock<IWebHostRpcWorkerChannelManager> moc
956
949
mockWebHostChannelManager . Setup ( m => m . ShutdownChannelIfExistsAsync (
957
950
It . IsAny < string > ( ) ,
958
951
It . Is < string > ( id => id == "testChannelId" ) ,
959
- It . Is < Exception > ( ex => ex is TimeoutException && ex . Message == $ "Executing invocation ` { invocationId } ` timed out" ) ) )
952
+ It . Is < Exception > ( ex => ex is FunctionTimeoutException ) ) )
960
953
. ReturnsAsync ( webHostShutdownSucceeds ) ;
961
954
962
955
// Set up JobHost ShutdownChannelIfExistsAsync to be called with the right exception type
963
956
mockJobHostChannelManager . Setup ( m => m . ShutdownChannelIfExistsAsync (
964
957
It . Is < string > ( id => id == "testChannelId" ) ,
965
- It . Is < Exception > ( ex => ex is TimeoutException && ex . Message == $ "Executing invocation ` { invocationId } ` timed out" ) ) )
958
+ It . Is < Exception > ( ex => ex is FunctionTimeoutException ) ) )
966
959
. ReturnsAsync ( ! webHostShutdownSucceeds ) ;
967
960
}
968
961
}
0 commit comments