public ServiceBusEndToEndTests()
 {
     _serviceBusConfig = new ServiceBusConfiguration();
     _nameResolver = new RandomNameResolver();
     _namespaceManager = NamespaceManager.CreateFromConnectionString(_serviceBusConfig.ConnectionString);
     _secondaryConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString("ServiceBusSecondary");
     _secondaryNamespaceManager = NamespaceManager.CreateFromConnectionString(_secondaryConnectionString);
 }
Exemplo n.º 2
0
        public Task <JobHostContext> CreateAndLogHostStartedAsync(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator         typeLocator  = new DefaultTypeLocator(new StringWriter(), new DefaultExtensionRegistry());
            INameResolver        nameResolver = new RandomNameResolver();
            JobHostConfiguration config       = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator  = typeLocator
            };

            return(JobHostContextFactory.CreateAndLogHostStartedAsync(
                       host, StorageAccountProvider, Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                       new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken, new WebJobsExceptionHandler(),
                       functionIndexProvider: FunctionIndexProvider, singletonManager: SingletonManager, hostIdProvider: HostIdProvider));
        }
        public Task<JobHostContext> CreateAndLogHostStartedAsync(CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator typeLocator = new DefaultTypeLocator(new StringWriter());
            INameResolver nameResolver = new RandomNameResolver();
            JobHostConfiguration config = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator = typeLocator
            };

            return JobHostContextFactory.CreateAndLogHostStartedAsync(
                StorageAccountProvider, Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken,
                functionIndexProvider: FunctionIndexProvider);
        }
        public Task <JobHostContext> CreateAndLogHostStartedAsync(CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator         typeLocator  = new DefaultTypeLocator(new StringWriter());
            INameResolver        nameResolver = new RandomNameResolver();
            JobHostConfiguration config       = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator  = typeLocator
            };

            return(JobHostContextFactory.CreateAndLogHostStartedAsync(
                       StorageAccountProvider, Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                       new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken,
                       functionIndexProvider: FunctionIndexProvider));
        }
        public Task<JobHostContext> CreateAndLogHostStartedAsync(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            INameResolver nameResolver = new RandomNameResolver();
            JobHostConfiguration config = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator = TypeLocator
            };

            return JobHostContextFactory.CreateAndLogHostStartedAsync(
                host, StorageAccountProvider, QueueConfiguration, TypeLocator, DefaultJobActivator.Instance, nameResolver, 
                ConsoleProvider, new JobHostConfiguration(), shutdownToken, cancellationToken, HostIdProvider, FunctionExecutor,
                FunctionIndexProvider, BindingProvider, HostInstanceLoggerProvider, FunctionInstanceLoggerProvider,
                FunctionOutputLoggerProvider, BackgroundExceptionDispatcher);
        }
        public LeaseExpirationTests()
        {
            RandomNameResolver nameResolver = new RandomNameResolver();
            _config = new JobHostConfiguration()
            {
                NameResolver = nameResolver,
                TypeLocator = new FakeTypeLocator(typeof(LeaseExpirationTests))
            };

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(_config.StorageConnectionString);
            _queueClient = storageAccount.CreateCloudQueueClient();

            _queue = _queueClient.GetQueueReference(nameResolver.ResolveInString(TestQueueName));
            _queue.CreateIfNotExists();
        }
        public Task<JobHostContext> CreateAndLogHostStartedAsync(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator typeLocator = new DefaultTypeLocator(new StringWriter(), new DefaultExtensionRegistry());
            INameResolver nameResolver = new RandomNameResolver();
            JobHostConfiguration config = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator = typeLocator
            };

            return JobHostContextFactory.CreateAndLogHostStartedAsync(
                host, StorageAccountProvider, config.Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken,
                new FixedHostIdProvider(Guid.NewGuid().ToString("N")),
                null, new EmptyFunctionIndexProvider(),
                null, new NullHostInstanceLoggerProvider(), new NullFunctionInstanceLoggerProvider(), new NullFunctionOutputLoggerProvider(), null, SingletonManager);
        }
        public BlobTriggerTests()
        {
            _timesProcessed = 0;

            RandomNameResolver nameResolver = new RandomNameResolver();
            _hostConfiguration = new JobHostConfiguration()
            {
                NameResolver = nameResolver,
                TypeLocator = new FakeTypeLocator(typeof(BlobTriggerTests)),
            };

            _storageAccount = CloudStorageAccount.Parse(_hostConfiguration.StorageConnectionString);
            CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();
            _testContainer = blobClient.GetContainerReference(nameResolver.ResolveInString(ContainerName));
            Assert.False(_testContainer.Exists());
            _testContainer.Create();
        }
        public AsyncCancellationEndToEndTests()
        {
            _resolver = new RandomNameResolver();

            _hostConfiguration = new JobHostConfiguration()
            {
                NameResolver = _resolver,
                TypeLocator = new FakeTypeLocator(typeof(AsyncCancellationEndToEndTests))
            };

            _storageAccount = CloudStorageAccount.Parse(_hostConfiguration.StorageConnectionString);

            _invokeInFunction = () => { };
            _tokenCancelled = false;
            _functionStarted = new ManualResetEvent(initialState: false);
            _functionCompleted = new ManualResetEvent(initialState: false);
        }
        public void MaxDegreeOfParallelism_Queues(int batchSize, int maxExpectedParallelism)
        {
            _receivedMessages = 0;
            _currentSimultaneouslyRunningFunctions = 0;
            _maxSimultaneouslyRunningFunctions = 0;
            _numberOfQueueMessages = batchSize * 3;

            RandomNameResolver nameResolver = new RandomNameResolver();
            JobHostConfiguration hostConfiguration = new JobHostConfiguration()
            {
                NameResolver = nameResolver,
                TypeLocator = new FakeTypeLocator(typeof(ParallelExecutionTests)),
            };
            hostConfiguration.Queues.BatchSize = batchSize;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(hostConfiguration.StorageConnectionString);
            _queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue queue = _queueClient.GetQueueReference(nameResolver.ResolveInString(TestQueueName));

            queue.CreateIfNotExists();

            for (int i = 0; i < _numberOfQueueMessages; i++)
            {
                int sleepTimeInSeconds = i % 2 == 0 ? 5 : 1;
                queue.AddMessage(new CloudQueueMessage(sleepTimeInSeconds.ToString()));
            }

            using (_allMessagesProcessed = new ManualResetEvent(initialState: false))
            using (JobHost host = new JobHost(hostConfiguration))
            {
                host.Start();
                _allMessagesProcessed.WaitOne(TimeSpan.FromSeconds(90));
                host.Stop();
            }

            Assert.Equal(_numberOfQueueMessages, _receivedMessages);
            Assert.Equal(0, _currentSimultaneouslyRunningFunctions);

            // the actual value will vary sometimes based on the speed of the machine
            // running the test.
            int delta = _maxSimultaneouslyRunningFunctions - maxExpectedParallelism;
            Assert.True(delta == 0 || delta == 1);
        }
 public ServiceBusEndToEndTests()
 {
     _serviceBusConfig = new ServiceBusConfiguration();
     _nameResolver = new RandomNameResolver();
     _namespaceManager = NamespaceManager.CreateFromConnectionString(_serviceBusConfig.ConnectionString);
 }