public void Run( int messageCount, LinqMethodTypes linqMethodTypes) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateCompiled, 0, oCreation.Scope); } #if NETFULL else { producer.RunTestDynamic <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateDynamic, 0, oCreation.Scope); } #endif } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int timeOut, int workerCount, bool useTransactions, bool enableChaos) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <SqlServerMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = !useTransactions; oCreation.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions; oCreation.Options.EnableStatus = !useTransactions; oCreation.Options.EnableStatusTable = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); //create data var producer = new ProducerShared(); producer.RunTest <SqlServerMessageQueueInit, FakeMessage>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, oCreation.Scope, false); //process data var consumer = new ConsumerPoisonMessageShared <FakeMessage>(); consumer.RunConsumer <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, workerCount, logProvider, timeOut, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", null, enableChaos); ValidateErrorCounts(queueName, messageCount); new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(messageCount, true, true); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { //create data var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <RedisQueueInit>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateNoOpCompiled, 0, null, false); } #if NETFULL else { producer.RunTestDynamic <RedisQueueInit>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateNoOpDynamic, 0, null, false); } #endif //process data var consumer = new ConsumerMethodAsyncPoisonMessageShared(); consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, workerCount, logProvider, timeOut, readerCount, queueSize, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", false); ValidateErrorCounts(queueName, connectionString, messageCount); using ( var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(messageCount, true, 2); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int timeOut, int workerCount, int readerCount, int queueSize, bool inMemoryDb) { using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb)) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <SqLiteMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = true; oCreation.Options.EnableStatus = true; oCreation.Options.EnableStatusTable = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); //create data var producer = new ProducerShared(); producer.RunTest <SqLiteMessageQueueInit, FakeMessage>(queueName, connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, oCreation.Scope); //process data var consumer = new ConsumerAsyncPoisonMessageShared <FakeMessage>(); consumer.RunConsumer <SqLiteMessageQueueInit>(queueName, connectionInfo.ConnectionString, false, workerCount, logProvider, timeOut, readerCount, queueSize, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", null); ValidateErrorCounts(queueName, connectionInfo.ConnectionString, messageCount); new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options).Verify(messageCount, true, true); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool useTransactions, bool enableChaos) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using ( var queueCreator = new QueueCreationContainer <PostgreSqlMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = !useTransactions; oCreation.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions; oCreation.Options.EnableStatus = !useTransactions; oCreation.Options.EnableStatusTable = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var id = Guid.NewGuid(); var producer = new ProducerMethodMultipleDynamicShared(); producer.RunTestDynamic <PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateMultipleDynamic, runtime, oCreation.Scope, false); var consumer = new ConsumerMethodShared(); consumer.RunConsumer <PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, logProvider, runtime, messageCount, workerCount, timeOut, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)", enableChaos); new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int timeOut, int workerCount, ConnectionInfoTypes type, bool route) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { //create data if (route) { var producer = new ProducerShared(); producer.RunTest <RedisQueueInit, FakeMessage>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateRouteData, Helpers.Verify, false, null); } else { var producer = new ProducerShared(); producer.RunTest <RedisQueueInit, FakeMessage>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, null); } //process data var defaultRoute = route ? Helpers.DefaultRoute : null; var consumer = new ConsumerPoisonMessageShared <FakeMessage>(); consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, workerCount, logProvider, timeOut, messageCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", defaultRoute); ValidateErrorCounts(queueName, connectionString, messageCount); using ( var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(messageCount, true, 2); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run(int messageCount, int timeOut, int workerCount) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); //create data var producer = new ProducerShared(); producer.RunTest <MemoryMessageQueueInit, FakeMessage>(queueName, connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, oCreation.Scope, false); //process data var consumer = new ConsumerErrorShared <FakeMessage>(); consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, false, logProvider, workerCount, timeOut, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", null, false); ValidateErrorCounts(oCreation.Scope, messageCount); new VerifyQueueRecordCount().Verify(oCreation.Scope, messageCount, false); //purge error records consumer.PurgeErrorMessages <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, false, logProvider, true); //memory queue doesn't actually keep errors, so nothing to check for... } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using ( var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var producer = new ProducerMethodMultipleDynamicShared(); var id = Guid.NewGuid(); producer.RunTestDynamic <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateMultipleDynamic, runtime, oCreation.Scope); var consumer = new ConsumerMethodShared(); consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, false, logProvider, runtime, messageCount, workerCount, timeOut, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id, "second(*%10)"); new VerifyQueueRecordCount() .Verify(oCreation.Scope, 0, true); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <RedisQueueInit>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateExpiredData, Helpers.Verify, false, id, GenerateMethod.CreateCompiled, runtime, null); } #if NETFULL else { producer.RunTestDynamic <RedisQueueInit>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateExpiredData, Helpers.Verify, false, id, GenerateMethod.CreateDynamic, runtime, null); } #endif Thread.Sleep(2000); var consumer = new ConsumerMethodExpiredMessageShared(); consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, logProvider, runtime, messageCount, workerCount, timeOut, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%10)", id); using (var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(0, false, -1); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run <TTransportInit, TTransportCreate>( QueueConnection queueConnection, int messageCount, LinqMethodTypes linqMethodTypes, bool interceptors, bool enableChaos, bool sendViaBatch, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify) where TTransportInit : ITransportInit, new() where TTransportCreate : class, IQueueCreation { var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name); using (var queueCreator = new QueueCreationContainer <TTransportInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); try { setOptions(oCreation); var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <TTransportInit>(queueConnection, interceptors, messageCount, logProvider, generateData, verify, sendViaBatch, id, GenerateMethod.CreateCompiled, 0, oCreation.Scope, enableChaos); } else { producer.RunTestDynamic <TTransportInit>(queueConnection, interceptors, messageCount, logProvider, generateData, verify, sendViaBatch, id, GenerateMethod.CreateDynamic, 0, oCreation.Scope, enableChaos); } } finally { oCreation.RemoveQueue(); oCreation.Dispose(); scope?.Dispose(); } } }
public void Run <TTransportInit, TMessage, TTransportCreate>( QueueConnection queueConnection, int messageCount, int runtime, int timeOut, int workerCount, bool enableChaos, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify, Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount) where TTransportInit : ITransportInit, new() where TMessage : class where TTransportCreate : class, IQueueCreation { var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name); using ( var queueCreator = new QueueCreationContainer <TTransportInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); try { setOptions(oCreation); var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; var producer = new ProducerShared(); producer.RunTest <TTransportInit, TMessage>(queueConnection, false, messageCount, logProvider, generateData, verify, false, scope, false); var consumer = new ConsumerShared <TMessage>(); consumer.RunConsumer <TTransportInit>(queueConnection, false, logProvider, runtime, messageCount, workerCount, timeOut, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", enableChaos, scope); verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, 0, false, false); } finally { oCreation?.RemoveQueue(); oCreation?.Dispose(); scope?.Dispose(); } } }
public void Run(int messageCount, int runtime, int timeOut, int readerCount, int routeCount, bool enableChaos, IntegrationConnectionInfo.ConnectionTypes connectionType) { using (var connectionInfo = new IntegrationConnectionInfo(connectionType)) { var queueName = GenerateQueueName.Create(); var consumer = new DotNetWorkQueue.IntegrationTests.Shared.Route.Implementation.RouteMultiTests(); consumer.Run <LiteDbMessageQueueInit, LiteDbMessageQueueCreation>(new QueueConnection(queueName, connectionInfo.ConnectionString), messageCount, runtime, timeOut, readerCount, routeCount, enableChaos, x => { Helpers.SetOptions(x, false, false, true, true); }, Helpers.GenerateData, Helpers.Verify, Helpers.VerifyQueueCount); } using (var connectionInfo = new IntegrationConnectionInfo(connectionType)) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <LiteDbMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { var queueConnection = new DotNetWorkQueue.Configuration.QueueConnection(queueName, connectionInfo.ConnectionString); ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <LiteDbMessageQueueCreation>(queueConnection); try { oCreation.Options.EnableStatusTable = true; oCreation.Options.EnableRoute = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; var routeTest = new RouteMultiTestsShared(); routeTest.RunTest <LiteDbMessageQueueInit, FakeMessageA>(queueConnection, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, GenerateRoutes(routeCount, 1), GenerateRoutes(routeCount, routeCount + 1), runtime, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), oCreation.Scope, "second(*%3)", enableChaos); new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options, scope) .Verify(0, false, false); } finally { oCreation?.RemoveQueue(); oCreation?.Dispose(); scope?.Dispose(); } } } }
public void Run(int messageCount, int runtime, int timeOut, int readerCount, bool inMemoryDb, int routeCount) { using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb)) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <SqLiteMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = true; oCreation.Options.EnableStatus = true; oCreation.Options.EnableStatusTable = true; oCreation.Options.EnableRoute = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var routeTest = new RouteTestsShared(); routeTest.RunTest <SqLiteMessageQueueInit, FakeMessageA>(queueName, connectionInfo.ConnectionString, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, GenerateRoutes(routeCount), runtime, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), oCreation.Scope, "second(*%3)"); new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options).Verify(0, false, false); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run( bool dynamic) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); using (var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>()) { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { using (var queueContainer = new QueueContainer <MemoryMessageQueueInit>(x => { })) { try { var tests = new JobSchedulerTestsShared(); if (!dynamic) { tests.RunEnqueueTestCompiled <MemoryMessageQueueInit, JobQueueCreation>( queueName, connectionInfo.ConnectionString, true, Helpers.Verify, Helpers.SetError, queueContainer.CreateTimeSync(connectionInfo.ConnectionString), oCreation.Scope, LoggerShared.Create(queueName, GetType().Name)); } #if NETFULL else { tests.RunEnqueueTestDynamic <MemoryMessageQueueInit, JobQueueCreation>( queueName, connectionInfo.ConnectionString, true, Helpers.Verify, Helpers.SetError, queueContainer.CreateTimeSync(connectionInfo.ConnectionString), oCreation.Scope, LoggerShared.Create(queueName, GetType().Name)); } #endif } finally { oCreation.RemoveQueue(); } } } } } }
public void Run <TTransportInit, TJobQueueCreator, TTransportCreate>( QueueConnection queueConnection, bool interceptors, bool dynamic, Action <QueueConnection, long, ICreationScope> verify, Action <QueueConnection, ICreationScope> setErrorFlag) where TTransportInit : ITransportInit, new() where TJobQueueCreator : class, IJobQueueCreation where TTransportCreate : class, IQueueCreation { using (var trace = SharedSetup.CreateTrace("jobscheduler")) { using (var queueCreator = new QueueCreationContainer <TTransportInit>((x) => x.RegisterNonScopedSingleton(trace.Source))) { var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); ICreationScope scope = oCreation.Scope; using (var queueContainer = new QueueContainer <TTransportInit>(x => x.RegisterNonScopedSingleton(scope).RegisterNonScopedSingleton(trace.Source))) { try { var tests = new JobSchedulerTestsShared(); if (!dynamic) { tests.RunEnqueueTestCompiled <TTransportInit, TJobQueueCreator>( queueConnection, interceptors, verify, setErrorFlag, queueContainer.CreateTimeSync(queueConnection.Connection), oCreation.Scope, LoggerShared.Create(queueConnection.Queue, GetType().Name)); } else { tests.RunEnqueueTestDynamic <TTransportInit, TJobQueueCreator>( queueConnection, interceptors, verify, setErrorFlag, queueContainer.CreateTimeSync(queueConnection.Connection), oCreation.Scope, LoggerShared.Create(queueConnection.Queue, GetType().Name)); } } finally { oCreation.RemoveQueue(); oCreation.Dispose(); scope?.Dispose(); } } } } }
public async void Run( int messageCount, LinqMethodTypes linqMethodTypes) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using ( var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var producer = new ProducerMethodAsyncShared(); var id = Guid.NewGuid(); await producer.RunTestAsync <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, 0, id, linqMethodTypes, oCreation.Scope, false).ConfigureAwait(false); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int readerCount, int routeCount, ConnectionInfoTypes type, bool batch) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using (var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var routeTest = new RouteTestsShared(); routeTest.RunTest <RedisQueueInit, FakeMessageA>(queueName, connectionString, true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, batch, GenerateRoutes(routeCount), runtime, timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), oCreation.Scope, "second(*%3)", false); using (var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(0, false, -1); } } } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public async Task <bool> Run <TTransportInit, TMessage, TTransportCreate>( QueueConnection queueConnection, int messageCount, bool interceptors, bool enableChaos, bool sendViaBatch, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify) where TTransportInit : ITransportInit, new() where TMessage : class where TTransportCreate : class, IQueueCreation { var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name); using ( var queueCreator = new QueueCreationContainer <TTransportInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); try { setOptions(oCreation); var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; var producer = new ProducerAsyncShared(); await producer.RunTestAsync <TTransportInit, TMessage>(queueConnection, interceptors, messageCount, logProvider, generateData, verify, sendViaBatch, oCreation.Scope, enableChaos).ConfigureAwait(false); } finally { oCreation?.RemoveQueue(); oCreation?.Dispose(); scope?.Dispose(); } return(true); } }
public void Run( int messageCount, bool interceptors) { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var producer = new ProducerShared(); producer.RunTest <MemoryMessageQueueInit, FakeMessage>(queueName, connectionInfo.ConnectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, true, oCreation.Scope, false); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, ConnectionInfoTypes type) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { var id = Guid.NewGuid(); var producer = new ProducerMethodMultipleDynamicShared(); producer.RunTestDynamic <RedisQueueInit>(queueName, connectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateMultipleDynamic, runtime, null); var consumer = new ConsumerMethodShared(); consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false, logProvider, runtime, messageCount, workerCount, timeOut, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)"); using (var count = new VerifyQueueRecordCount(queueName, connectionString)) { count.Verify(0, false, -1); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run <TTransportInit, TMessage, TTransportCreate>( QueueConnection queueConnection, int messageCount, bool enableChaos, int queueCount, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify, Action <QueueConnection, IBaseTransportOptions, ICreationScope, long, long, string> verifyQueueData) where TTransportInit : ITransportInit, new() where TMessage : class where TTransportCreate : class, IQueueCreation { var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name); using (var queueCreator = new QueueCreationContainer <TTransportInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); try { setOptions(oCreation); var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; RunTest <TTransportInit, TMessage>(queueConnection, messageCount, queueCount, logProvider, oCreation.Scope, enableChaos, generateData, verify); LoggerShared.CheckForErrors(queueConnection.Queue); verifyQueueData(queueConnection, oCreation.BaseTransportOptions, oCreation.Scope, messageCount, queueCount, null); } finally { oCreation?.RemoveQueue(); oCreation?.Dispose(); scope?.Dispose(); } } }
public void Run(int messageCount, bool inMemoryDb, LinqMethodTypes linqMethodTypes, bool enableChaos) { using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb)) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <SqLiteMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); RunTest(queueName, messageCount, 10, logProvider, connectionInfo.ConnectionString, linqMethodTypes, oCreation.Scope, enableChaos); LoggerShared.CheckForErrors(queueName); new VerifyQueueData(queueName, connectionInfo.ConnectionString, oCreation.Options).Verify(messageCount * 10, null); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, bool async, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes) { var queueNameSend = GenerateQueueName.Create(); var logProviderSend = LoggerShared.Create(queueNameSend, GetType().Name); var connectionString = new ConnectionInfo(type).ConnectionString; using (var queueCreatorSend = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProviderSend, LifeStyles.Singleton))) { try { var id = Guid.NewGuid(); var rpc = new RpcMethodShared <RedisQueueInit, RedisQueueRpcConnection>(); rpc.Run(queueNameSend, queueNameSend, connectionString, connectionString, logProviderSend, logProviderSend, runtime, messageCount, workerCount, timeOut, async, new RedisQueueRpcConnection(connectionString, queueNameSend), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, linqMethodTypes, "second(*%3)"); using (var count = new VerifyQueueRecordCount(queueNameSend, connectionString)) { count.Verify(0, false, -1); } } finally { using ( var oCreation = queueCreatorSend.GetQueueCreation <RedisQueueCreation>(queueNameSend, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run() { using (var connectionInfo = new IntegrationConnectionInfo()) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <MemoryMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); RunTest(queueName, 100, 10, logProvider, connectionInfo.ConnectionString, oCreation.Scope); LoggerShared.CheckForErrors(queueName); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <MessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run() { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <PostgreSqlMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); RunTest(queueName, 1000, 10, logProvider, oCreation.Scope); LoggerShared.CheckForErrors(queueName); new VerifyQueueData(queueName, oCreation.Options).Verify(1000 * 10, null); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }
public async void Run( int messageCount, bool interceptors, bool batchSending, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes) { var id = Guid.NewGuid(); var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); var producer = new ProducerMethodAsyncShared(); var connectionString = new ConnectionInfo(type).ConnectionString; using ( var queueCreator = new QueueCreationContainer <RedisQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { await producer.RunTestAsync <RedisQueueInit>(queueName, connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, batchSending, 0, id, linqMethodTypes, null).ConfigureAwait(false); } finally { using ( var oCreation = queueCreator.GetQueueCreation <RedisQueueCreation>(queueName, connectionString) ) { oCreation.RemoveQueue(); } } } }
public void Run( bool inMemoryDb) { using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb)) { var queueName = GenerateQueueName.Create(); using (var queueCreator = new QueueCreationContainer <SqLiteMessageQueueInit>()) { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { using (var queueContainer = new QueueContainer <SqLiteMessageQueueInit>(x => { })) { try { var tests = new JobSchedulerTestsShared(); tests.RunEnqueueTestCompiled <SqLiteMessageQueueInit, SqliteJobQueueCreation>( queueName, connectionInfo.ConnectionString, true, Helpers.Verify, Helpers.SetError, queueContainer.CreateTimeSync(connectionInfo.ConnectionString), oCreation.Scope, LoggerShared.Create(queueName, GetType().Name)); } finally { oCreation.RemoveQueue(); } } } } } }
public void Run <TTransportInit, TTransportCreate>( QueueConnection queueConnection, int messageCount, int timeOut, int workerCount, LinqMethodTypes linqMethodTypes, bool enableChaos, Action <TTransportCreate> setOptions, Func <QueueProducerConfiguration, AdditionalMessageData> generateData, Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify, Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount, Action <QueueConnection, int, ICreationScope> validateErrorCounts) where TTransportInit : ITransportInit, new() where TTransportCreate : class, IQueueCreation { var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name); using (var queueCreator = new QueueCreationContainer <TTransportInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { ICreationScope scope = null; var oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection); try { setOptions(oCreation); var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); scope = oCreation.Scope; //create data var producer = new ProducerMethodShared(); var id = Guid.NewGuid(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <TTransportInit>(queueConnection, false, messageCount, logProvider, generateData, verify, false, id, GenerateMethod.CreateNoOpCompiled, 0, oCreation.Scope, false); } else { producer.RunTestDynamic <TTransportInit>(queueConnection, false, messageCount, logProvider, generateData, verify, false, id, GenerateMethod.CreateNoOpDynamic, 0, oCreation.Scope, false); } //process data var consumer = new ConsumerMethodPoisonMessageShared(); consumer.RunConsumer <TTransportInit>(queueConnection, false, workerCount, logProvider, timeOut, messageCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), "second(*%10)", enableChaos, scope); validateErrorCounts(queueConnection, messageCount, scope); verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, messageCount, true, true); } finally { oCreation.RemoveQueue(); oCreation.Dispose(); scope?.Dispose(); } } }
public void Run( int messageCount, bool interceptors, bool enableDelayedProcessing, bool enableHeartBeat, bool enableMessageExpiration, bool enablePriority, bool enableStatus, bool enableStatusTable, bool additionalColumn, bool inMemoryDb, LinqMethodTypes linqMethodTypes, bool enableChaos) { using (var connectionInfo = new IntegrationConnectionInfo(inMemoryDb)) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using (var queueCreator = new QueueCreationContainer <SqLiteMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing; oCreation.Options.EnableHeartBeat = enableHeartBeat; oCreation.Options.EnableMessageExpiration = enableMessageExpiration; oCreation.Options.EnablePriority = enablePriority; oCreation.Options.EnableStatus = enableStatus; oCreation.Options.EnableStatusTable = enableStatusTable; if (additionalColumn) { oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Integer, true, null)); } var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <SqLiteMessageQueueInit>(queueName, connectionInfo.ConnectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateCompiled, 0, oCreation.Scope, enableChaos); } else { producer.RunTestDynamic <SqLiteMessageQueueInit>(queueName, connectionInfo.ConnectionString, interceptors, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateDynamic, 0, oCreation.Scope, enableChaos); } } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqLiteMessageQueueCreation>(queueName, connectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } } }
public void Run(int messageCount, int runtime, int timeOut, int workerCount, LinqMethodTypes linqMethodTypes) { var queueName = GenerateQueueName.Create(); var logProvider = LoggerShared.Create(queueName, GetType().Name); using ( var queueCreator = new QueueCreationContainer <SqlServerMessageQueueInit>( serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton))) { try { using ( var oCreation = queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.Options.EnableDelayedProcessing = true; oCreation.Options.EnableHeartBeat = true; oCreation.Options.EnableHoldTransactionUntilMessageCommitted = false; oCreation.Options.EnableStatus = true; oCreation.Options.EnableStatusTable = true; var result = oCreation.CreateQueue(); Assert.True(result.Success, result.ErrorMessage); var id = Guid.NewGuid(); var producer = new ProducerMethodShared(); if (linqMethodTypes == LinqMethodTypes.Compiled) { producer.RunTestCompiled <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateCancelCompiled, runtime, oCreation.Scope); } #if NETFULL else { producer.RunTestDynamic <SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false, id, GenerateMethod.CreateCancelDynamic, runtime, oCreation.Scope); } #endif var consumer = new ConsumerMethodCancelWorkShared <SqlServerMessageQueueInit>(); consumer.RunConsumer(queueName, ConnectionInfo.ConnectionString, false, logProvider, runtime, messageCount, workerCount, timeOut, serviceRegister => serviceRegister.Register <IMessageMethodHandling>(() => new MethodMessageProcessingCancel(id), LifeStyles.Singleton), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), "second(*%3)", id); new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false); GenerateMethod.ClearCancel(id); } } finally { using ( var oCreation = queueCreator.GetQueueCreation <SqlServerMessageQueueCreation>(queueName, ConnectionInfo.ConnectionString) ) { oCreation.RemoveQueue(); } } } }