public async Task CreateChannels_Succeeds() { string language = LanguageWorkerConstants.JavaLanguageWorkerName; ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(language); var initializedChannel = await _languageWorkerChannelManager.GetChannelAsync(language); ILanguageWorkerChannel javaWorkerChannel2 = CreateTestChannel(LanguageWorkerConstants.JavaLanguageWorkerName); Assert.NotNull(initializedChannel); Assert.Equal(javaWorkerChannel.Id, initializedChannel.Id); Assert.Equal(_languageWorkerChannelManager.GetChannels(LanguageWorkerConstants.JavaLanguageWorkerName).Count(), 2); }
public async Task ShutdownStandByChannels_WorkerRuntinmeDotNet_Succeeds() { _testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.DotNetLanguageWorkerName); _languageWorkerChannelManager = new WebHostLanguageWorkerChannelManager(_eventManager, _testEnvironment, _loggerFactory, _languageWorkerChannelFactory, _optionsMonitor); ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(LanguageWorkerConstants.JavaLanguageWorkerName); ILanguageWorkerChannel nodeWorkerChannel = CreateTestChannel(LanguageWorkerConstants.NodeLanguageWorkerName); _languageWorkerChannelManager.ScheduleShutdownStandbyChannels(); ILanguageWorkerChannel initializedChannel = await _languageWorkerChannelManager.GetChannelAsync(LanguageWorkerConstants.NodeLanguageWorkerName); Assert.Null(initializedChannel); initializedChannel = await _languageWorkerChannelManager.GetChannelAsync(LanguageWorkerConstants.JavaLanguageWorkerName); Assert.Null(initializedChannel); }
public async Task InitializeLanguageWorkerChannel_ThrowsOnProcessStartup() { var languageWorkerChannelFactory = new TestLanguageWorkerChannelFactory(_eventManager, null, _scriptRootPath, throwOnProcessStartUp: true); var languageWorkerChannelManager = new WebHostLanguageWorkerChannelManager(_eventManager, _testEnvironment, _loggerFactory, languageWorkerChannelFactory, _optionsMonitor); var languageWorkerChannel = await languageWorkerChannelManager.InitializeLanguageWorkerChannel("test", _scriptRootPath); var ex = await Assert.ThrowsAsync <AggregateException>(async() => await languageWorkerChannelManager.GetChannelAsync("test")); Assert.Contains("Process startup failed", ex.InnerException.Message); }
public async Task SpecializeAsync_Node_NotReadOnly_KillsProcess() { _testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.NodeLanguageWorkerName); // This is an invalid setting configuration, but just to show that run from zip is NOT set _testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteZipDeployment, "0"); _languageWorkerChannelManager = new WebHostLanguageWorkerChannelManager(_eventManager, _testEnvironment, _loggerFactory, _rpcWorkerChannelFactory, _optionsMonitor); ILanguageWorkerChannel nodeWorkerChannel = CreateTestChannel(LanguageWorkerConstants.NodeLanguageWorkerName); await _languageWorkerChannelManager.SpecializeAsync(); // Verify logs var traces = _testLogger.GetLogMessages(); Assert.True(traces.Count() == 0); // Verify channel var initializedChannel = await _languageWorkerChannelManager.GetChannelAsync(LanguageWorkerConstants.NodeLanguageWorkerName); Assert.Null(initializedChannel); }
public async Task SpecializeAsync_Java_ReadOnly_KeepsProcessAlive() { _testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.JavaLanguageWorkerName); _testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteZipDeployment, "1"); _languageWorkerChannelManager = new WebHostLanguageWorkerChannelManager(_eventManager, _testEnvironment, _loggerFactory, _rpcWorkerChannelFactory, _optionsMonitor); ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(LanguageWorkerConstants.JavaLanguageWorkerName); await _languageWorkerChannelManager.SpecializeAsync(); // Verify logs var traces = _testLogger.GetLogMessages(); var functionLoadLogs = traces.Where(m => string.Equals(m.FormattedMessage, "SendFunctionEnvironmentReloadRequest called")); Assert.True(functionLoadLogs.Count() == 1); // Verify channel var initializedChannel = await _languageWorkerChannelManager.GetChannelAsync(LanguageWorkerConstants.JavaLanguageWorkerName); Assert.Equal(javaWorkerChannel, initializedChannel); }