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

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

                Author: ASF GitHub Bot
            Created on: 13/Sep/21 08:54
            Start Date: 13/Sep/21 08:54
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3728:
URL: https://github.com/apache/activemq-artemis/pull/3728#discussion_r707134913



##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/PagedMirrorTest.java
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <br>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <br>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.amqp.connect;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import java.io.File;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectConfiguration;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPMirrorBrokerConnectionElement;
+import 
org.apache.activemq.artemis.core.persistence.impl.journal.JournalRecordIds;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.tests.util.Wait;
+import org.jboss.logging.Logger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PagedMirrorTest extends ActiveMQTestBase {
+
+   private static final Logger logger = 
Logger.getLogger(PagedMirrorTest.class);
+   ActiveMQServer server1;
+
+   ActiveMQServer server2;
+
+   @Before
+   @Override
+   public void setUp() throws Exception {
+      super.setUp();
+
+      server1 = createServer(true, createDefaultConfig(0, true), 1024, 10 * 
1024);
+      server1.getConfiguration().getAcceptorConfigurations().clear();
+      server1.getConfiguration().addAcceptorConfiguration("server", 
"tcp://localhost:61616");
+      AMQPBrokerConnectConfiguration brokerConnectConfiguration = new 
AMQPBrokerConnectConfiguration("other", 
"tcp://localhost:61617").setReconnectAttempts(-1).setRetryInterval(1000);
+      brokerConnectConfiguration.addElement(new 
AMQPMirrorBrokerConnectionElement());
+      server1.getConfiguration().addAMQPConnection(brokerConnectConfiguration);
+
+      server2 = createServer(true, createDefaultConfig(1, true), 1024, 10 * 
1024);
+      server2.getConfiguration().getAcceptorConfigurations().clear();
+      server2.getConfiguration().addAcceptorConfiguration("server", 
"tcp://localhost:61617");
+      brokerConnectConfiguration = new AMQPBrokerConnectConfiguration("other", 
"tcp://localhost:61616").setReconnectAttempts(-1).setRetryInterval(1000);
+      brokerConnectConfiguration.addElement(new 
AMQPMirrorBrokerConnectionElement());
+      server2.getConfiguration().addAMQPConnection(brokerConnectConfiguration);
+
+      server1.start();
+      server2.start();
+   }
+
+   @Test
+   public void testPaged() throws Throwable {
+      String sendURI = "tcp://localhost:61616";
+      String consumeURI = "tcp://localhost:61616";
+      String secondConsumeURI = "tcp://localhost:61617";
+
+      Wait.waitFor(() -> server1.locateQueue("$ACTIVEMQ_ARTEMIS_MIRROR_other") 
!= null);
+
+      org.apache.activemq.artemis.core.server.Queue snf1 = 
server2.locateQueue("$ACTIVEMQ_ARTEMIS_MIRROR_other");
+      Assert.assertNotNull(snf1);
+
+      org.apache.activemq.artemis.core.server.Queue snf2 = 
server1.locateQueue("$ACTIVEMQ_ARTEMIS_MIRROR_other");
+      Assert.assertNotNull(snf2);
+
+      File countJournalLocation = 
server1.getConfiguration().getJournalLocation();
+      Assert.assertTrue(countJournalLocation.exists() && 
countJournalLocation.isDirectory());
+      String protocol = "amqp";
+
+      ConnectionFactory sendCF = CFUtil.createConnectionFactory(protocol, 
sendURI);
+      ConnectionFactory consumeCF = CFUtil.createConnectionFactory(protocol, 
consumeURI);
+      ConnectionFactory secondConsumeCF = 
CFUtil.createConnectionFactory(protocol, secondConsumeURI);
+
+      String bodyBuffer;
+      {
+         StringBuffer buffer = new StringBuffer();
+         for (int i = 0; i < 1024; i++) {
+            buffer.append("*");
+         }
+         bodyBuffer = buffer.toString();
+      }
+
+      int NUMBER_OF_MESSAGES = 200;
+      int ACK_I = 77;
+
+      try (Connection sendConnecton = sendCF.createConnection()) {
+         Session sendSession = sendConnecton.createSession(true, 
Session.SESSION_TRANSACTED);
+         Queue jmsQueue = sendSession.createQueue("someQueue");
+         MessageProducer producer = sendSession.createProducer(jmsQueue);
+
+         for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
+            TextMessage message = sendSession.createTextMessage(bodyBuffer);
+            message.setIntProperty("i", i);
+            producer.send(message);
+         }
+         sendSession.commit();
+      }
+
+      Wait.assertEquals(0, snf1::getMessageCount);
+      Wait.assertEquals(0, snf2::getMessageCount);
+
+      try (Connection consumeConnection = consumeCF.createConnection()) {
+         Session consumeSession = consumeConnection.createSession(false, 101); 
// individual ack
+         Queue jmsQueue = consumeSession.createQueue("someQueue");
+         MessageConsumer consumer = consumeSession.createConsumer(jmsQueue);
+         consumeConnection.start();
+         for (int i = 0; i < NUMBER_OF_MESSAGES; i++) {
+            TextMessage message = (TextMessage) consumer.receive(6000);
+            if (message.getIntProperty("i") == ACK_I) {
+               message.acknowledge();
+            }
+         }
+         Assert.assertNull(consumer.receiveNoWait());
+      }
+      Wait.assertEquals(0, snf1::getMessageCount);
+      Wait.assertEquals(0, snf2::getMessageCount);
+      Wait.assertEquals(1, () -> acksCount(countJournalLocation), 5000, 1000);
+
+      try (Connection consumeConnection = secondConsumeCF.createConnection()) {
+         Session consumeSession = consumeConnection.createSession(true, 
Session.SESSION_TRANSACTED);
+         Queue jmsQueue = consumeSession.createQueue("someQueue");
+         MessageConsumer consumer = consumeSession.createConsumer(jmsQueue);
+         consumeConnection.start();
+
+         for (int i = 0; i < NUMBER_OF_MESSAGES - 1; i++) {
+            TextMessage message = (TextMessage) consumer.receive(6000);
+            Assert.assertNotNull(message);
+            Assert.assertNotEquals(ACK_I, message.getIntProperty("i"));

Review comment:
       I disagree as the other tests dont appear to ack an individual message 
in the middle of the queue, and if thats the case then no other test actually 
can be verifying what I suggested to (essentially that behaviour for the rest 
of the queued messages is as expected ad not in some way broken).
   
   All this checks is that the 199 messages then received arent the one it 
acked. It would still pass if the broker had sent completely the wrong 
messages, even the same message over and over, etc...its just not as robust a 
test as it could trivialy be.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 649875)
    Time Spent: 2h 50m  (was: 2h 40m)

> Mirror could Miss Acks with Paging
> ----------------------------------
>
>                 Key: ARTEMIS-3464
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3464
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 2.18.0
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>             Fix For: 2.19.0
>
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> The Mirror target could miss acks in some cases with Paging.
> We should add a scan for when the message couldn't be reached within depaged 
> messages.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to