Ejemplo n.º 1
0
        public async Task ShutdownTests()
        {
            int expectedProcessCount = 2;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount.ToString());
            await functionDispatcher.InitializeAsync(GetTestFunctionsList(RpcWorkerConstants.NodeLanguageWorkerName));

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            foreach (var currChannel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
            {
                var initializedChannel = (TestRpcWorkerChannel)currChannel;
                initializedChannel.ExecutionContexts.Add(Task.Factory.StartNew(() => { }));
            }

            await functionDispatcher.ShutdownAsync();

            foreach (var currChannel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
            {
                Assert.True(((TestRpcWorkerChannel)currChannel).ExecutionContexts.Count == 0);
            }
        }
        public async Task ShutdownTests_WithInfinitelyRunningTasks_Timesout()
        {
            int expectedProcessCount = 2;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount, runtime: RpcWorkerConstants.NodeLanguageWorkerName);
            await functionDispatcher.InitializeAsync(GetTestFunctionsList(RpcWorkerConstants.NodeLanguageWorkerName));

            await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount);

            foreach (var currChannel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
            {
                var initializedChannel = (TestRpcWorkerChannel)currChannel;
                initializedChannel.ExecutionContexts.Add(new Task <bool>(() => true));   // A task that never starts and therefore never runs to completion
            }

            await functionDispatcher.ShutdownAsync();

            foreach (var currChannel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
            {
                Assert.True(((TestRpcWorkerChannel)currChannel).ExecutionContexts.Count > 0);
            }
        }