public async Task WorkerRuntime_Setting_ChannelInitializationState_Succeeds(string workerRuntime)
        {
            _testLoggerProvider.ClearAllLogMessages();
            int expectedProcessCount = 1;
            RpcFunctionInvocationDispatcher functionDispatcher = GetTestFunctionDispatcher(expectedProcessCount, false, runtime: workerRuntime, workerIndexing: true);

            // create channels and ensure that they aren't ready for invocation requests yet
            await functionDispatcher.InitializeAsync(new List <FunctionMetadata>());

            if (!string.IsNullOrEmpty(workerRuntime))
            {
                int createdChannelsCount = await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount, false);

                Assert.Equal(expectedProcessCount, createdChannelsCount);

                IEnumerable <IRpcWorkerChannel> channels = await functionDispatcher.GetInitializedWorkerChannelsAsync();

                Assert.Equal(0, channels.Count());

                // set up invocation buffers, send load requests, and ensure that the channels are now set up for invocation requests
                var functions = GetTestFunctionsList(RpcWorkerConstants.JavaLanguageWorkerName);
                await functionDispatcher.FinishInitialization(functions);

                int initializedChannelsCount = await WaitForJobhostWorkerChannelsToStartup(functionDispatcher, expectedProcessCount, true);

                Assert.Equal(expectedProcessCount, initializedChannelsCount);
            }
            else
            {
                foreach (var currChannel in functionDispatcher.JobHostLanguageWorkerChannelManager.GetChannels())
                {
                    Assert.True(((TestRpcWorkerChannel)currChannel).ExecutionContexts.Count == 0);
                }
            }
        }
Exemplo n.º 2
0
        public async Task WorkerStatus_NewWorkerAdded()
        {
            RpcFunctionInvocationDispatcher fd       = null;
            IEnumerable <IRpcWorkerChannel> channels = null;

            // Latency > 1s
            TestScriptEventManager.WaitBeforePublish = TimeSpan.FromSeconds(2);
            await TestHelpers.Await(async() =>
            {
                fd       = Fixture.JobHost.FunctionDispatcher as RpcFunctionInvocationDispatcher;
                channels = await fd.GetInitializedWorkerChannelsAsync();
                return(channels.Count() == 2);
            }, pollingInterval : 1000, timeout : 120 * 1000);
        }