public async Task ServiceBusSessionTopicSubscription_OrderGuaranteed() { var host = BuildSessionHost <ServiceBusSessionsTestJobs1>(); using (host) { await WriteTopicMessage("message1", "test-session1"); await WriteTopicMessage("message2", "test-session1"); await WriteTopicMessage("message3", "test-session1"); await WriteTopicMessage("message4", "test-session1"); await WriteTopicMessage("message5", "test-session1"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); List <LogMessage> logMessages = GetLogMessages(host).Where(m => m.Category == "Function.SBSub1Trigger.User").ToList(); Assert.True(logMessages.Count() == 5, ServiceBusSessionsTestHelper.GetLogsAsString(logMessages)); int i = 1; foreach (LogMessage logMessage in logMessages) { StringAssert.StartsWith("message" + i++, logMessage.FormattedMessage); } await host.StopAsync(); } }
public async Task ServiceBusSessionTopicSubscription_OrderGuaranteed() { var(jobHost, host) = BuildSessionHost <ServiceBusSessionsTestJobs1>(); using (jobHost) { _waitHandle1 = new ManualResetEvent(initialState: false); await WriteTopicMessage("message1", "test-session1"); await WriteTopicMessage("message2", "test-session1"); await WriteTopicMessage("message3", "test-session1"); await WriteTopicMessage("message4", "test-session1"); await WriteTopicMessage("message5", "test-session1"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); IEnumerable <LogMessage> logMessages = host.GetTestLoggerProvider().GetAllLogMessages(); // filter out anything from the custom processor for easier validation. List <LogMessage> consoleOutput = logMessages.Where(m => m.Category == "Function.SBSub1Trigger.User").ToList(); Assert.True(consoleOutput.Count() == 5, ServiceBusSessionsTestHelper.GetLogsAsString(consoleOutput)); int i = 1; foreach (LogMessage logMessage in consoleOutput) { StringAssert.StartsWith("message" + i++, logMessage.FormattedMessage); } } }
public async Task ServiceBusSessionQueue_OrderGuaranteed() { var(jobHost, host) = BuildSessionHost <ServiceBusSessionsTestJobs1>(); using (jobHost) { await WriteQueueMessage("message1", "test-session1"); await WriteQueueMessage("message2", "test-session1"); await WriteQueueMessage("message3", "test-session1"); await WriteQueueMessage("message4", "test-session1"); await WriteQueueMessage("message5", "test-session1"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); IEnumerable <LogMessage> logMessages = host.GetTestLoggerProvider().GetAllLogMessages(); Assert.False(logMessages.Where(p => p.Level == LogLevel.Error).Any()); // filter out anything from the custom processor for easier validation. List <LogMessage> consoleOutput = logMessages.Where(m => m.Category == "Function.SBQueue1Trigger.User").ToList(); Assert.True(consoleOutput.Count() == 5, ServiceBusSessionsTestHelper.GetLogsAsString(consoleOutput)); int i = 1; foreach (LogMessage logMessage in consoleOutput) { StringAssert.StartsWith("message" + i++, logMessage.FormattedMessage); } await jobHost.StopAsync(); } }
public async Task ServiceBusSessionTopicSubscription_OrderGuaranteed() { using (var host = ServiceBusSessionsTestHelper.CreateHost <ServiceBusSessionsTestJobs1>(_nameResolver)) { await host.StartAsync(); _waitHandle1 = new ManualResetEvent(initialState: false); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message1", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message2", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message3", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message4", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message5", "test-session1"); Assert.True(_waitHandle1.WaitOne(SBTimeout)); IEnumerable <LogMessage> logMessages = host.GetTestLoggerProvider().GetAllLogMessages(); // filter out anything from the custom processor for easier validation. List <LogMessage> consoleOutput = logMessages.Where(m => m.Category == "Function.SBSub1Trigger.User").ToList(); Assert.True(consoleOutput.Count() == 5, ServiceBusSessionsTestHelper.GetLogsAsString(consoleOutput)); int i = 1; foreach (LogMessage logMessage in consoleOutput) { Assert.True(logMessage.FormattedMessage.StartsWith("message" + i++)); } } }
public async Task ServiceBusSessionSub_SessionLocks() { using (var host = ServiceBusSessionsTestHelper.CreateHost <ServiceBusSessionsTestJobs1>(_nameResolver, true)) { await host.StartAsync(); _waitHandle1 = new ManualResetEvent(initialState: false); _waitHandle2 = new ManualResetEvent(initialState: false); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message1", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message1", "test-session2"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message2", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message2", "test-session2"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message3", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message3", "test-session2"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message4", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message4", "test-session2"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message5", "test-session1"); await ServiceBusEndToEndTests.WriteTopicMessage(_connectionString, _topicName, "message5", "test-session2"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); Assert.True(_waitHandle2.WaitOne(SBTimeoutMills)); IEnumerable <LogMessage> logMessages1 = host.GetTestLoggerProvider().GetAllLogMessages(); // filter out anything from the custom processor for easier validation. List <LogMessage> consoleOutput1 = logMessages1.Where(m => m.Category == "Function.SBSub1Trigger.User").ToList(); Assert.True(consoleOutput1.Count() == 10, ServiceBusSessionsTestHelper.GetLogsAsString(consoleOutput1)); double seconsds = (consoleOutput1[5].Timestamp - consoleOutput1[4].Timestamp).TotalSeconds; Assert.True(seconsds > 90 && seconsds < 110, seconsds.ToString()); for (int i = 0; i < consoleOutput1.Count(); i++) { if (i < 5) { Assert.Equal(consoleOutput1[i].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1], consoleOutput1[0].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1]); } else { Assert.Equal(consoleOutput1[i].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1], consoleOutput1[5].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1]); } } await host.StopAsync(); } }
public async Task ServiceBusSessionQueue_SessionLocks() { var(jobHost, host) = BuildSessionHost <ServiceBusSessionsTestJobs1>(addCustomProvider: true); using (jobHost) { _waitHandle1 = new ManualResetEvent(initialState: false); _waitHandle2 = new ManualResetEvent(initialState: false); await WriteQueueMessage("message1", "test-session1"); await WriteQueueMessage("message1", "test-session2"); await WriteQueueMessage("message2", "test-session1"); await WriteQueueMessage("message2", "test-session2"); await WriteQueueMessage("message3", "test-session1"); await WriteQueueMessage("message3", "test-session2"); await WriteQueueMessage("message4", "test-session1"); await WriteQueueMessage("message4", "test-session2"); await WriteQueueMessage("message5", "test-session1"); await WriteQueueMessage("message5", "test-session2"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); Assert.True(_waitHandle2.WaitOne(SBTimeoutMills)); IEnumerable <LogMessage> logMessages1 = host.GetTestLoggerProvider().GetAllLogMessages(); // filter out anything from the custom processor for easier validation. List <LogMessage> consoleOutput1 = logMessages1.Where(m => m.Category == "Function.SBQueue1Trigger.User").ToList(); Assert.True(consoleOutput1.Count() == 10, ServiceBusSessionsTestHelper.GetLogsAsString(consoleOutput1)); double seconds = (consoleOutput1[5].Timestamp - consoleOutput1[4].Timestamp).TotalSeconds; Assert.True(seconds > 90 && seconds < 110, seconds.ToString()); for (int i = 0; i < consoleOutput1.Count(); i++) { if (i < 5) { Assert.AreEqual(consoleOutput1[i].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1], consoleOutput1[0].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1]); } else { Assert.AreEqual(consoleOutput1[i].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1], consoleOutput1[5].FormattedMessage[consoleOutput1[0].FormattedMessage.Length - 1]); } } } }
public async Task ServiceBusSessionSub_SessionLocks() { var host = BuildSessionHost <ServiceBusSessionsTestJobs1>(addCustomProvider: true); using (host) { await WriteTopicMessage("message1", "test-session1"); await WriteTopicMessage("message1", "test-session2"); await WriteTopicMessage("message2", "test-session1"); await WriteTopicMessage("message2", "test-session2"); await WriteTopicMessage("message3", "test-session1"); await WriteTopicMessage("message3", "test-session2"); await WriteTopicMessage("message4", "test-session1"); await WriteTopicMessage("message4", "test-session2"); await WriteTopicMessage("message5", "test-session1"); await WriteTopicMessage("message5", "test-session2"); Assert.True(_waitHandle1.WaitOne(SBTimeoutMills)); Assert.True(_waitHandle2.WaitOne(SBTimeoutMills)); var logMessages = GetLogMessages(host) .Where(m => m.Category == "Function.SBSub1Trigger.User").ToList();; Assert.True(logMessages.Count() == 10, ServiceBusSessionsTestHelper.GetLogsAsString(logMessages)); double seconds = (logMessages[5].Timestamp - logMessages[4].Timestamp).TotalSeconds; Assert.True(seconds > 90 && seconds < 110, seconds.ToString()); for (int i = 0; i < logMessages.Count(); i++) { if (i < 5) { Assert.AreEqual(logMessages[i].FormattedMessage[logMessages[0].FormattedMessage.Length - 1], logMessages[0].FormattedMessage[logMessages[0].FormattedMessage.Length - 1]); } else { Assert.AreEqual(logMessages[i].FormattedMessage[logMessages[0].FormattedMessage.Length - 1], logMessages[5].FormattedMessage[logMessages[0].FormattedMessage.Length - 1]); } } await host.StopAsync(); } }