public void IsLanguageWorkerConsoleLog_Returns_True_RemovesLogPrefix(string msg)
        {
            LanguageWorkerChannel languageWorkerChannel = new LanguageWorkerChannel();

            Assert.True(languageWorkerChannel.IsLanguageWorkerConsoleLog(msg));
            Assert.Equal(" Connection established", languageWorkerChannel.RemoveLogPrefix(msg));
        }
        private async Task WaitForJobHostChannelReady()
        {
            await TestHelpers.Await(() =>
            {
                var currentChannel = GetCurrentJobHostWorkerChannel();
                return(currentChannel != null);
            }, pollingInterval : 4 * 1000, timeout : 60 * 1000);

            _nodeWorkerChannel = GetCurrentJobHostWorkerChannel();
        }
Ejemplo n.º 3
0
        public IEnumerable <string> Get()
        {
            if (_languageWorkerChannel == null)
            {
                _languageWorkerChannel = _functionDispatcher.WorkerChannels.FirstOrDefault();
            }


            return(new string[] { "value1", "value2" });
        }
        private async Task WaitForWorkerProcessRestart(int restartCount)
        {
            await TestHelpers.Await(() =>
            {
                var currentChannel = GetCurrentJobHostWorkerChannel();
                return(currentChannel != null && currentChannel.Id != _nodeWorkerChannel.Id);
            }, pollingInterval : 4 * 1000, timeout : 60 * 1000);

            _nodeWorkerChannel = GetCurrentJobHostWorkerChannel();
        }
        private async Task WaitForWorkerProcessRestart(int restartCount)
        {
            await TestHelpers.Await(() =>
            {
                return(GetCurrentWorkerChannel().Id != _nodeWorkerChannel.Id ||
                       FunctionErrorsAdded());
            }, pollingInterval : 4 * 1000, timeout : 60 * 1000);

            _nodeWorkerChannel = GetCurrentWorkerChannel();
        }
        public void ErrorMessageQueue_Enqueue_Success()
        {
            LanguageWorkerChannel languageWorkerChannel = new LanguageWorkerChannel();

            languageWorkerChannel.AddStdErrMessage("Error1");
            languageWorkerChannel.AddStdErrMessage("Error2");

            Assert.True(languageWorkerChannel.ProcessStdErrDataQueue.Count == 2);
            string exceptionMessage = string.Join(",", languageWorkerChannel.ProcessStdErrDataQueue.Where(s => !string.IsNullOrEmpty(s)));

            Assert.Equal("Error1,Error2", exceptionMessage);
        }
Ejemplo n.º 7
0
        public Task <string> Get(int id)
        {
            if (_languageWorkerChannel == null)
            {
                _languageWorkerChannel = _functionDispatcher.WorkerChannels.FirstOrDefault();
            }
            ScriptInvocationContext invocationContext = new ScriptInvocationContext()
            {
                FunctionId   = id.ToString(),
                InvocationId = Guid.NewGuid().ToString(),
                ResultSource = new TaskCompletionSource <string>()
            };

            _languageWorkerChannel.SendInvocationRequest(invocationContext);
            return(invocationContext.ResultSource.Task);
            //return $"{id}-succeeed-{invocationContext.InvocationId}";
        }
Ejemplo n.º 8
0
        public async Task StartWorkerProcessAsync_WorkerProcess_Throws()
        {
            Mock <ILanguageWorkerProcess> mockLanguageWorkerProcessThatThrows = new Mock <ILanguageWorkerProcess>();

            mockLanguageWorkerProcessThatThrows.Setup(m => m.StartProcessAsync()).Throws <FileNotFoundException>();

            _workerChannel = new LanguageWorkerChannel(
                _workerId,
                _scriptRootPath,
                _eventManager,
                _testWorkerConfig,
                mockLanguageWorkerProcessThatThrows.Object,
                _logger,
                _mockMetricsLogger.Object,
                0);
            await Assert.ThrowsAsync <FileNotFoundException>(async() => await _workerChannel.StartWorkerProcessAsync());
        }
Ejemplo n.º 9
0
        public LanguageWorkerChannelTests()
        {
            _logger = new TestLogger("FunctionDispatcherTests");
            _testFunctionRpcService = new TestFunctionRpcService(_eventManager, _workerId, _logger, _expectedLogMsg);
            _testWorkerConfig       = TestHelpers.GetTestWorkerConfigs().FirstOrDefault();
            _mockLanguageWorkerProcess.Setup(m => m.StartProcessAsync()).Returns(Task.CompletedTask);

            _workerChannel = new LanguageWorkerChannel(
                _workerId,
                _scriptRootPath,
                _eventManager,
                _testWorkerConfig,
                _mockLanguageWorkerProcess.Object,
                _logger,
                _mockMetricsLogger.Object,
                0);
        }
        public void IsLanguageWorkerConsoleLog_Returns_False(string msg)
        {
            LanguageWorkerChannel languageWorkerChannel = new LanguageWorkerChannel();

            Assert.False(languageWorkerChannel.IsLanguageWorkerConsoleLog(msg));
        }
        public void ErrorMessageQueue_Empty()
        {
            LanguageWorkerChannel languageWorkerChannel = new LanguageWorkerChannel();

            Assert.Empty(languageWorkerChannel.ProcessStdErrDataQueue);
        }
 public FunctionDispatcherEndToEndTests(TestFixture fixture)
 {
     Fixture            = fixture;
     _channelStates     = Fixture.JobHost.FunctionDispatcher.LanguageWorkerChannelStates;
     _nodeWorkerChannel = GetCurrentWorkerChannel();
 }