[ 
https://issues.apache.org/jira/browse/ARTEMIS-5148?focusedWorklogId=943335&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-943335
 ]

ASF GitHub Bot logged work on ARTEMIS-5148:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 12/Nov/24 14:22
            Start Date: 12/Nov/24 14:22
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on code in PR #5338:
URL: https://github.com/apache/activemq-artemis/pull/5338#discussion_r1838191661


##########
tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/interruptlm/ClusteredLargeMessageInterruptTest.java:
##########
@@ -289,57 +268,51 @@ private void testInterrupt(String protocol, boolean tx, 
boolean useKill) throws
       ExecutorService executorService = 
Executors.newFixedThreadPool(SENDING_THREADS + CONSUMING_THREADS);
       runAfter(executorService::shutdownNow);
 
-      CountDownLatch sendDone = startSendingThreads(executorService, protocol, 
0, SENDING_THREADS, tx, queueName);
-      CountDownLatch receiverDone = startConsumingThreads(executorService, 
protocol, 0, CONSUMING_THREADS, tx, queueName);
-
-      Thread.sleep(2000);
-
-      killProcess(serverProcess, useKill);
-      runningSend = false;
-      runningConsumer = false;
-      assertTrue(serverProcess.waitFor(10, TimeUnit.SECONDS));
-      assertTrue(receiverDone.await(10, TimeUnit.SECONDS));
-      assertTrue(sendDone.await(10, TimeUnit.SECONDS));
-
-      logger.info("All receivers and senders are done!!!");
-
-      serverProcess = startServer0();
-
-      Thread.sleep(2000);
-
-      sendDone = startSendingThreads(executorService, protocol, 1, 
SENDING_THREADS, tx, queueName);
-      receiverDone = startConsumingThreads(executorService, protocol, 1, 
CONSUMING_THREADS, tx, queueName);
-
-      killProcess(serverProcess2, useKill);
-      assertTrue(serverProcess2.waitFor(10, TimeUnit.SECONDS));
-      runningSend = false;
-      runningConsumer = false;
-      assertTrue(sendDone.await(1, TimeUnit.MINUTES));
-      assertTrue(receiverDone.await(10, TimeUnit.SECONDS));
-
-      serverProcess2 = startServer1();
-
-      sendDone = startSendingThreads(executorService, protocol, 1, 
SENDING_THREADS, tx, queueName);
-      receiverDone = startConsumingThreads(executorService, protocol, 1, 
CONSUMING_THREADS, tx, queueName);
-
-      Thread.sleep(2000);
-      runningSend = false;
-      assertTrue(sendDone.await(10, TimeUnit.SECONDS));
-
-      QueueControl queueControl1 = getQueueControl(server1URI, builderServer1, 
queueName, queueName, RoutingType.ANYCAST, 5000);
-      QueueControl queueControl2 = getQueueControl(server2URI, builderServer2, 
queueName, queueName, RoutingType.ANYCAST, 5000);
-
       File lmFolder = new File(getServerLocation(SERVER_NAME_0) + 
"/data/large-messages");
       File lmFolder2 = new File(getServerLocation(SERVER_NAME_1) + 
"/data/large-messages");
 
-      Wait.waitFor(() -> queueControl1.getMessageCount() == 0 && 
queueControl2.getMessageCount() == 0 && lmFolder.listFiles().length == 0 && 
lmFolder2.listFiles().length == 0);
+      {
+         CountDownLatch sendDone = startSendingThreads(executorService, 
protocol, 0, SENDING_THREADS, tx, queueName);
+         CountDownLatch receiverDone = startConsumingThreads(executorService, 
protocol, 1, CONSUMING_THREADS, tx, queueName);
+
+         // let it producing for a while
+         Thread.sleep(2000);
+
+         runningSend = false;
+         assertTrue(sendDone.await(10, TimeUnit.SECONDS));
+
+         killProcess(serverProcess);
+         assertTrue(serverProcess.waitFor(1, TimeUnit.MINUTES));
+         serverProcess = startServer0();
+         runningConsumer = false;
+         assertTrue(receiverDone.await(10, TimeUnit.SECONDS));
+
+         SimpleManagement simpleManagement1 = new 
SimpleManagement("tcp://localhost:61716", null, null);
+         runAfter(simpleManagement1::close);
+
+         long timeout = System.currentTimeMillis() + 60_000;
+
+         ConnectionFactory factory = createConnectionFactory(1, protocol);
+         try (Connection connection = factory.createConnection()) {
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = 
session.createConsumer(session.createQueue(queueName));
+            connection.start();
+            while (System.currentTimeMillis() < timeout) {
+               if (consumer.receive(1_000) == null) {
+                  if (lmFolder.listFiles().length == 0 && 
lmFolder2.listFiles().length == 0) {
+                     break;
+                  }
+               }
+            }
+         }
 
-      runningConsumer = false;
-      assertTrue(receiverDone.await(10, TimeUnit.SECONDS));
+      }
+
+      logger.info("All receivers and senders are done!!!");
 
       // no need to use wait here, the previous check should have checked that 
already
-      assertEquals(0, lmFolder.listFiles().length);
-      assertEquals(0, lmFolder2.listFiles().length);
+      Wait.assertEquals(0, () -> lmFolder.listFiles().length, 5000);
+      Wait.assertEquals(0, () -> lmFolder2.listFiles().length, 5000);

Review Comment:
   I removed the Wait.. but I also removed the comment... which I think it goes 
without saying.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 943335)
    Time Spent: 1h 10m  (was: 1h)

> Simpllify and make ClusteredLargeMessageInterruptTest more reliable
> -------------------------------------------------------------------
>
>                 Key: ARTEMIS-5148
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5148
>             Project: ActiveMQ Artemis
>          Issue Type: Test
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 2.39.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> As I was writing the test ClusteredLargeMessageInterruptTest I was trying 
> many permutations, tinkering / hacking to reproduce an issue it was reported 
> to me in production. once I found it I created 
> AmqpLargeMessageTest::testDeleteUnreferencedMessage,
> and I ended up leaving the test in its last permutation thinking it would be 
> a good thing.. however the test is failing for test issues in itself 
> (consumers not being closed.. and test races). The main purpose of the test 
> is to accumulate messages in the SNF and kill the servers.
> So as part of this task I'm simplifying the test making it more reliable.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to