[
https://issues.apache.org/jira/browse/ARTEMIS-2919?focusedWorklogId=520271&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-520271
]
ASF GitHub Bot logged work on ARTEMIS-2919:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 04/Dec/20 17:42
Start Date: 04/Dec/20 17:42
Worklog Time Spent: 10m
Work Description: gemmellr commented on a change in pull request #3279:
URL: https://github.com/apache/activemq-artemis/pull/3279#discussion_r536267878
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpIngressTimeTest.java
##########
@@ -0,0 +1,98 @@
+/**
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.protocol.amqp.converter.AMQPMessageSupport;
+import org.apache.activemq.transport.amqp.client.AmqpClient;
+import org.apache.activemq.transport.amqp.client.AmqpConnection;
+import org.apache.activemq.transport.amqp.client.AmqpMessage;
+import org.apache.activemq.transport.amqp.client.AmqpReceiver;
+import org.apache.activemq.transport.amqp.client.AmqpSession;
+import org.junit.Test;
+
+public class AmqpIngressTimeTest extends AmqpClientTestSupport {
+
+ @Test(timeout = 60000)
+ public void testIngressTimestampSendCore() throws Exception {
+ internalTestIngressTimestamp(Protocol.CORE);
+ }
+
+ @Test(timeout = 60000)
+ public void testIngressTimestampSendAMQP() throws Exception {
+ internalTestIngressTimestamp(Protocol.AMQP);
+ }
+
+ @Test(timeout = 60000)
+ public void testIngressTimestampSendOpenWire() throws Exception {
+ internalTestIngressTimestamp(Protocol.OPENWIRE);
+ }
+
+ private void internalTestIngressTimestamp(Protocol protocol) throws
Exception {
+ server.getAddressSettingsRepository().addMatch(getQueueName(), new
AddressSettings().setEnableIngressTime(true));
+ long beforeSend = System.currentTimeMillis();
+ if (protocol == Protocol.CORE) {
+ sendMessagesCore(getQueueName(), 1, true);
+ } else if (protocol == Protocol.OPENWIRE) {
+ sendMessagesOpenWire(getQueueName(), 1, true);
+ } else {
+ sendMessages(getQueueName(), 1, true);
+ }
+ long afterSend = System.currentTimeMillis();
+
+ server.stop();
+ server.start();
+ assertTrue(server.waitForActivation(3, TimeUnit.SECONDS));
+
+ AmqpClient client = createAmqpClient();
+ AmqpConnection connection = addConnection(client.connect());
+ AmqpSession session = connection.createSession();
+
+ AmqpReceiver receiver = session.createReceiver(getQueueName());
+
+ Queue queueView = getProxyToQueue(getQueueName());
+ assertEquals(1, queueView.getMessageCount());
+
+ receiver.flow(1);
+ AmqpMessage receive = receiver.receive(5, TimeUnit.SECONDS);
+ assertNotNull(receive);
+ instanceLog.info(receive);
+ Object ingressTimestamp =
receive.getMessageAnnotation(AMQPMessageSupport.HDR_INGRESS_TIME);
+ assertNotNull(ingressTimestamp);
+ assertTrue(ingressTimestamp instanceof Long);
+ long ingressTs = (Long) ingressTimestamp;
+ assertTrue("Ingress time should be set in expected range",beforeSend <=
ingressTs && afterSend >= ingressTs);
Review comment:
Im not sure why GitHub is showing 4 lines as I only selected one at the
time I commented, but its the last assertTrue with the message I mean, i.e
"assertTrue("Ingress time should be set in expected range",beforeSend <=
ingressTs && afterSend >= ingressTs);"
The above will basically give 'it failed here, good luck on your quest',
basically requiring you run it again to try and figure out what happened (which
could be racey and hard to reproduce, might cause us to modify the test to help
figure the reason, etc), whereas a more useful failure would show what the
value was and what it should have been [between]. That might even allow
figuring out the issue without needing to run the test again (or if we cant get
it to fail again) as the failure message was far more useful and potential
causes potentially could be reasoned from it...e.g 'oh it was 0, weve stopped
setting it, oops \<checks recent changes\>' or 'it was 1ms outside expectation,
possibly we introduced some unexpected async behaviour'
E.g one option from one of the earlier comments:
https://github.com/apache/activemq-artemis/pull/3279#discussion_r533325701
```
Matcher<Long> inRange =
both(greaterThanOrEqualTo(beforeSend)).and(lessThanOrEqualTo(afterSend));
MatcherAssert.assertThat("Ingress time should be set in expected range",
ingressTs, inRange);
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 520271)
Time Spent: 6h 10m (was: 6h)
> Support timestamping incoming messages
> --------------------------------------
>
> Key: ARTEMIS-2919
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2919
> Project: ActiveMQ Artemis
> Issue Type: New Feature
> Reporter: Justin Bertram
> Assignee: Justin Bertram
> Priority: Major
> Time Spent: 6h 10m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)