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