Exemple #1
0
        public async Task FunctionDispatcher_Restart_ErroredChannels_And_DoesNot_Change_State()
        {
            int expectedProcessCount = 2;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount);

            Assert.Equal(FunctionInvocationDispatcherState.Default, functionDispatcher.State);
            // Add worker
            await functionDispatcher.InitializeAsync(GetTestFunctionsList(RpcWorkerConstants.NodeLanguageWorkerName));

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            TestRpcWorkerChannel testWorkerChannel = (TestRpcWorkerChannel)functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels().FirstOrDefault();

            // Restart one channel
            testWorkerChannel.RaiseWorkerRestart();
            Assert.Equal(FunctionInvocationDispatcherState.Initialized, functionDispatcher.State);
            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            Assert.Equal(FunctionInvocationDispatcherState.Initialized, functionDispatcher.State);
        }
Exemple #2
0
        public async Task FunctionDispatcher_Restart_ErroredChannels_OnWorkerRestart_NotAffectedByLimit()
        {
            int expectedProcessCount = 2;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount);
            await functionDispatcher.InitializeAsync(GetTestFunctionsList(RpcWorkerConstants.NodeLanguageWorkerName));

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            for (int restartCount = 0; restartCount < expectedProcessCount * 3; restartCount++)
            {
                foreach (var channel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
                {
                    TestRpcWorkerChannel testWorkerChannel = channel as TestRpcWorkerChannel;
                    testWorkerChannel.RaiseWorkerRestart();
                }

                var finalChannelCount = await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

                Assert.Equal(expectedProcessCount, finalChannelCount);
            }
        }
Exemple #3
0
        public async Task FunctionDispatcher_Restart_ErroredChannels_And_Changes_State()
        {
            int expectedProcessCount = 1;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount.ToString());

            Assert.Equal(FunctionInvocationDispatcherState.Default, functionDispatcher.State);
            // Add worker
            await functionDispatcher.InitializeAsync(GetTestFunctionsList(RpcWorkerConstants.NodeLanguageWorkerName));

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            TestRpcWorkerChannel testWorkerChannel = (TestRpcWorkerChannel)functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels().FirstOrDefault();

            // Restart this channel
            testWorkerChannel.RaiseWorkerRestart();
            await TestHelpers.Await(() =>
            {
                return(functionDispatcher.State == FunctionInvocationDispatcherState.WorkerProcessRestarting);
            }, 3000);

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            Assert.Equal(FunctionInvocationDispatcherState.Initialized, functionDispatcher.State);
        }