public void ShutdownStandyChannels_WorkerRuntime_Node_Set() { _testEnvironment = new TestEnvironment(); _testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.NodeLanguageWorkerName); _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor); string javaWorkerId = Guid.NewGuid().ToString(); ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(javaWorkerId, LanguageWorkerConstants.JavaLanguageWorkerName); FunctionMetadata funcJs1 = new FunctionMetadata() { Name = "funcJs1", Language = "node" }; FunctionMetadata funcCS1 = new FunctionMetadata() { Name = "funcCS1", Language = "csharp" }; IEnumerable <FunctionMetadata> functionsList = new Collection <FunctionMetadata>() { funcJs1, funcCS1 }; _languageWorkerChannelManager.ShutdownStandbyChannels(functionsList); var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName); Assert.Null(initializedChannel); }
public void ShutdownStandbyChannels_OnlyProxies() { _testEnvironment = new TestEnvironment(); _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor); string javaWorkerId = Guid.NewGuid().ToString(); ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(javaWorkerId, LanguageWorkerConstants.JavaLanguageWorkerName); FunctionMetadata proxy1 = new FunctionMetadata() { Name = "funcproxy1", IsProxy = true }; FunctionMetadata proxy2 = new FunctionMetadata() { Name = "funcproxy2", IsProxy = true }; IEnumerable <FunctionMetadata> functionsList = new Collection <FunctionMetadata>() { proxy2, proxy1 }; _languageWorkerChannelManager.ShutdownStandbyChannels(functionsList); var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName); Assert.Null(initializedChannel); }
public async void FunctionDispatcherState_Default_DotNetFunctions() { FunctionDispatcher functionDispatcher = GetTestFunctionDispatcher(); Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = "dotnet" }; var functions = new List <FunctionMetadata>() { func1 }; await functionDispatcher.InitializeAsync(functions); Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State); await functionDispatcher.InitializeAsync(functions); Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State); await functionDispatcher.InitializeAsync(functions); Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State); }
public void IsSupported_Returns_False(string language, string funcMetadataLanguage) { IFunctionDispatcher functionDispatcher = GetTestFunctionDispatcher(); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = funcMetadataLanguage }; Assert.False(functionDispatcher.IsSupported(func1, language)); }
public static void IsSupported_Returns_False(string language, string funcMetadataLanguage) { var workerConfigs = TestHelpers.GetTestWorkerConfigs(); var eventManager = new Mock <IScriptEventManager>(); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = funcMetadataLanguage }; FunctionDispatcher functionDispatcher = new FunctionDispatcher(eventManager.Object, new TestRpcServer(), null, workerConfigs, language); Assert.False(functionDispatcher.IsSupported(func1)); }
public async void FunctionDispatcherState_Transitions_From_Starting_To_Initialized() { FunctionDispatcher functionDispatcher = GetTestFunctionDispatcher(); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = "node" }; var functions = new List <FunctionMetadata>() { func1 }; await functionDispatcher.InitializeAsync(functions); Assert.True(functionDispatcher.State == FunctionDispatcherState.Initializing || functionDispatcher.State == FunctionDispatcherState.Initialized); await WaitForFunctionDispactherStateInitialized(functionDispatcher); }
public async Task FunctionDispatcherState_Transitions_From_Starting_To_Initialized() { RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = "node" }; var functions = new List <FunctionMetadata>() { func1 }; await functionDispatcher.InitializeAsync(functions); Assert.Equal(FunctionInvocationDispatcherState.Initializing, functionDispatcher.State); await WaitForFunctionDispactherStateInitialized(functionDispatcher); Assert.Equal(FunctionInvocationDispatcherState.Initialized, functionDispatcher.State); }
public async void ShutdownChannels_DotNetFunctions() { FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = "dotnet" }; var functions = new List <FunctionMetadata>() { func1 }; var mockLanguageWorkerChannelManager = new Mock <IWebHostLanguageWorkerChannelManager>(); FunctionDispatcher functionDispatcher = (FunctionDispatcher)GetTestFunctionDispatcher(mockwebHostLanguageWorkerChannelManager: mockLanguageWorkerChannelManager); Assert.Equal(FunctionDispatcherState.Default, functionDispatcher.State); await functionDispatcher.InitializeAsync(functions); // Wait longer than debouce action. await Task.Delay(6000); mockLanguageWorkerChannelManager.Verify(m => m.ShutdownChannels(), Times.Once); }
public async Task FunctionDispatcherState_Transitions_From_Default_To_Initialized_To_Disposing() { RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(); Assert.Equal(FunctionInvocationDispatcherState.Default, functionDispatcher.State); FunctionMetadata func1 = new FunctionMetadata() { Name = "func1", Language = "node" }; var functions = new List <FunctionMetadata>() { func1 }; await functionDispatcher.InitializeAsync(functions); Assert.Equal(FunctionInvocationDispatcherState.Initializing, functionDispatcher.State); await WaitForFunctionDispactherStateInitialized(functionDispatcher); Assert.Equal(FunctionInvocationDispatcherState.Initialized, functionDispatcher.State); functionDispatcher.Dispose(); Assert.True(functionDispatcher == null || functionDispatcher.State == FunctionInvocationDispatcherState.Disposing || functionDispatcher.State == FunctionInvocationDispatcherState.Disposed); }