@@ -221,7 +221,7 @@ public async Task Specialization_ResetsSharedLoadContext()
221
221
}
222
222
223
223
[ Fact ]
224
- public async Task StartAsync_SetsCorrectActiveHost ( )
224
+ public async Task StartAsync_SetsCorrectActiveHost_RefreshesLanguageWorkerOptions ( )
225
225
{
226
226
var builder = CreateStandbyHostBuilder ( ) ;
227
227
@@ -231,27 +231,40 @@ public async Task StartAsync_SetsCorrectActiveHost()
231
231
Task ignore = Task . Delay ( 3000 ) . ContinueWith ( _ => _pauseAfterStandbyHostBuild . Release ( ) ) ;
232
232
233
233
IWebHost host = builder . Build ( ) ;
234
- var manager = host . Services . GetService < WebJobsScriptHostService > ( ) ;
234
+ var scriptHostService = host . Services . GetService < WebJobsScriptHostService > ( ) ;
235
+ var channelFactory = host . Services . GetService < IRpcWorkerChannelFactory > ( ) ;
236
+ var workerOptionsPlaceholderMode = host . Services . GetService < IOptions < LanguageWorkerOptions > > ( ) ;
237
+ Assert . Equal ( 4 , workerOptionsPlaceholderMode . Value . WorkerConfigs . Count ) ;
238
+ var rpcChannelInPlaceholderMode = ( RpcWorkerChannel ) channelFactory . Create ( "/" , "powershell" , null , 0 , workerOptionsPlaceholderMode . Value . WorkerConfigs ) ;
239
+ Assert . Equal ( "6" , rpcChannelInPlaceholderMode . Config . Description . DefaultRuntimeVersion ) ;
240
+
235
241
236
242
// TestServer will block in the constructor so pull out the StandbyManager and use it
237
243
// directly for this test.
238
244
var standbyManager = host . Services . GetService < IStandbyManager > ( ) ;
239
245
240
- var standbyStart = Task . Run ( async ( ) => await manager . StartAsync ( CancellationToken . None ) ) ;
246
+ var standbyStart = Task . Run ( async ( ) => await scriptHostService . StartAsync ( CancellationToken . None ) ) ;
241
247
242
248
// Wait until we've completed the build once. The standby host is built and now waiting for
243
249
// _pauseAfterHostBuild to release it.
244
250
await TestHelpers . Await ( ( ) => _buildCount . CurrentCount == 1 ) ;
245
251
246
252
_environment . SetEnvironmentVariable ( EnvironmentSettingNames . AzureWebsiteContainerReady , "1" ) ;
247
- _environment . SetEnvironmentVariable ( EnvironmentSettingNames . AzureWebsitePlaceholderMode , "0" ) ;
253
+ _environment . SetEnvironmentVariable ( EnvironmentSettingNames . AzureWebsitePlaceholderMode , "0" ) ;
254
+ _environment . SetEnvironmentVariable ( RpcWorkerConstants . FunctionWorkerRuntimeSettingName , "powershell" ) ;
255
+ _environment . SetEnvironmentVariable ( RpcWorkerConstants . FunctionWorkerRuntimeVersionSettingName , "7" ) ;
248
256
249
257
var specializeTask = Task . Run ( async ( ) => await standbyManager . SpecializeHostAsync ( ) ) ;
250
258
251
259
await Task . WhenAll ( standbyStart , specializeTask ) ;
252
260
253
- var options = manager . Services . GetService < IOptions < ScriptJobHostOptions > > ( ) ;
261
+ var options = scriptHostService . Services . GetService < IOptions < ScriptJobHostOptions > > ( ) ;
254
262
Assert . Equal ( _specializedScriptRoot , options . Value . RootScriptPath ) ;
263
+
264
+ var workerOptionsAtJobhostLevel = scriptHostService . Services . GetService < IOptions < LanguageWorkerOptions > > ( ) ;
265
+ Assert . Equal ( 1 , workerOptionsAtJobhostLevel . Value . WorkerConfigs . Count ) ;
266
+ var rpcChannelAfterSpecialization = ( RpcWorkerChannel ) channelFactory . Create ( "/" , "powershell" , null , 0 , workerOptionsAtJobhostLevel . Value . WorkerConfigs ) ;
267
+ Assert . Equal ( "7" , rpcChannelAfterSpecialization . Config . Description . DefaultRuntimeVersion ) ;
255
268
}
256
269
257
270
private IWebHostBuilder CreateStandbyHostBuilder ( params string [ ] functions )
0 commit comments