Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        public void CreateChannel_Succeeds()
        {
            _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor);
            string workerId = Guid.NewGuid().ToString();
            string language = LanguageWorkerConstants.JavaLanguageWorkerName;

            ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(workerId, language);
            var initializedChannel = _languageWorkerChannelManager.GetChannel(language);

            Assert.NotNull(initializedChannel);
            Assert.Equal(workerId, initializedChannel.Id);
        }
        public void ShutdownStandbyChannels_WorkerRuntime_Not_Set()
        {
            _testEnvironment = new TestEnvironment();

            _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor, null);
            string javaWorkerId = Guid.NewGuid().ToString();
            ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(javaWorkerId, LanguageWorkerConstants.JavaLanguageWorkerName);

            _languageWorkerChannelManager.ShutdownChannels();

            var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName);

            Assert.Null(initializedChannel);
        }
Example #5
0
        public void ShutdownStandByChannels_WorkerRuntinmeDotNet_Succeeds()
        {
            _testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.DotNetLanguageWorkerName);
            _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor);

            string javaWorkerId = Guid.NewGuid().ToString();
            ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(javaWorkerId, LanguageWorkerConstants.JavaLanguageWorkerName);

            string nodeWorkerId = Guid.NewGuid().ToString();
            ILanguageWorkerChannel nodeWorkerChannel = CreateTestChannel(nodeWorkerId, LanguageWorkerConstants.NodeLanguageWorkerName);

            _languageWorkerChannelManager.ScheduleShutdownStandbyChannels();
            var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.NodeLanguageWorkerName);

            Assert.Null(initializedChannel);
            initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName);
            Assert.Null(initializedChannel);
        }
        public void ShutdownChannelsIfExist_Succeeds()
        {
            _testEnvironment = new TestEnvironment();
            _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor, null);
            string javaWorkerId1 = Guid.NewGuid().ToString();
            ILanguageWorkerChannel javaWorkerChannel1 = CreateTestChannel(javaWorkerId1, LanguageWorkerConstants.JavaLanguageWorkerName);

            string javaWorkerId2 = Guid.NewGuid().ToString();
            ILanguageWorkerChannel javaWorkerChannel2 = CreateTestChannel(javaWorkerId2, LanguageWorkerConstants.JavaLanguageWorkerName);

            _languageWorkerChannelManager.ShutdownChannelIfExists(LanguageWorkerConstants.JavaLanguageWorkerName, javaWorkerId1);
            _languageWorkerChannelManager.ShutdownChannelIfExists(LanguageWorkerConstants.JavaLanguageWorkerName, javaWorkerId2);

            Assert.Empty(_languageWorkerChannelManager.GetChannels(LanguageWorkerConstants.JavaLanguageWorkerName));

            var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName);

            Assert.Null(initializedChannel);
        }
Example #7
0
        public void ShutdownChannels_Succeeds()
        {
            _languageWorkerChannelManager = new LanguageWorkerChannelManager(_eventManager, _testEnvironment, _rpcServer, _loggerFactory, new OptionsWrapper <LanguageWorkerOptions>(_languageWorkerOptions), _optionsMonitor);

            string javaWorkerId = Guid.NewGuid().ToString();
            ILanguageWorkerChannel javaWorkerChannel = CreateTestChannel(javaWorkerId, LanguageWorkerConstants.JavaLanguageWorkerName);

            string nodeWorkerId = Guid.NewGuid().ToString();
            ILanguageWorkerChannel nodeWorkerChannel = CreateTestChannel(nodeWorkerId, LanguageWorkerConstants.NodeLanguageWorkerName);

            // Shutdown
            _languageWorkerChannelManager.ShutdownChannels();

            //Verify disposed
            var initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.NodeLanguageWorkerName);

            Assert.Null(initializedChannel);
            initializedChannel = _languageWorkerChannelManager.GetChannel(LanguageWorkerConstants.JavaLanguageWorkerName);
            Assert.Null(initializedChannel);
        }