This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4406140b84479dadd4e0359bf59ba314227b1bb8 Author: Benoit TELLIER <btell...@linagora.com> AuthorDate: Sun Nov 10 01:04:04 2024 +0100 [FIX] Add a test for concurrent execution and linearization + throttling --- .../james/imapserver/netty/IMAPServerTest.java | 26 ++++++++++++++++++++-- .../src/test/resources/imapServer.xml | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java index 8e9cb2245e..300b19acc5 100644 --- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java +++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java @@ -222,7 +222,6 @@ class IMAPServerTest { class ConnectionCheckTest { IMAPServer imapServer; - private final IpConnectionCheck ipConnectionCheck = new IpConnectionCheck(); private int port; @BeforeEach @@ -2687,11 +2686,12 @@ class IMAPServerTest { private MailboxSession mailboxSession; private MessageManager inbox; private SocketChannel clientConnection; + private int port; @BeforeEach void beforeEach() throws Exception { imapServer = createImapServer("imapServer.xml"); - int port = imapServer.getListenAddresses().get(0).getPort(); + port = imapServer.getListenAddresses().get(0).getPort(); mailboxSession = memoryIntegrationResources.getMailboxManager().createSystemSession(USER); memoryIntegrationResources.getMailboxManager() .createMailbox(MailboxPath.inbox(USER), mailboxSession); @@ -2724,6 +2724,28 @@ class IMAPServerTest { assertThat(reply).contains("AAAB BAD COMPRESS failed. Unknown command."); } + @Test + void linearizerShouldBeUsableConcurrently() throws Exception { + ConcurrentTestRunner.builder() + .operation((a, b) -> { + SocketChannel clientConnection = SocketChannel.open(); + clientConnection.connect(new InetSocketAddress(LOCALHOST_IP, port)); + readBytes(clientConnection); + + clientConnection.write(ByteBuffer.wrap(String.format("a0 LOGIN %s %s\r\n", USER.asString(), USER_PASS).getBytes(StandardCharsets.UTF_8))); + readBytes(clientConnection); + + for (int i = 0; i < 100; i++) { + clientConnection.write(ByteBuffer.wrap("a0 SELECT INBOX\r\na0 UNSELECT\r\n".getBytes())); + } + clientConnection.write(ByteBuffer.wrap("a1 NOOP\r\n".getBytes())); + + readStringUntil(clientConnection, s -> s.contains("a1 OK")); + }).threadCount(32) + .operationCount(1) + .runSuccessfullyWithin(Duration.ofMinutes(10)); + } + @Test void ensureSequentialExecutionOfImapRequests() throws Exception { IntStream.range(0, 100) diff --git a/server/protocols/protocols-imap4/src/test/resources/imapServer.xml b/server/protocols/protocols-imap4/src/test/resources/imapServer.xml index 6851c8c75e..134d869e66 100644 --- a/server/protocols/protocols-imap4/src/test/resources/imapServer.xml +++ b/server/protocols/protocols-imap4/src/test/resources/imapServer.xml @@ -12,4 +12,5 @@ <literalSizeLimit>128K</literalSizeLimit> <plainAuthDisallowed>false</plainAuthDisallowed> <gracefulShutdown>false</gracefulShutdown> + <concurrentRequests>20</concurrentRequests> </imapserver> \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org