add some logging to diagnose ci failure

This commit is contained in:
gtully 2017-05-04 10:23:13 +01:00
parent 18d05ba5e0
commit 2b3f0e5958
1 changed files with 21 additions and 16 deletions

View File

@ -1671,24 +1671,29 @@ public class MQTTTest extends MQTTTestSupport {
} }
connectionSub.disconnect(); connectionSub.disconnect();
for (int j = 0; j < numberOfRuns; j++) { try {
for (int j = 0; j < numberOfRuns; j++) {
for (int i = 0; i < messagesPerRun; ++i) { for (int i = 0; i < messagesPerRun; ++i) {
connectionPub.publish(topics[0].name().toString(), payload, QoS.AT_LEAST_ONCE, false); connectionPub.publish(topics[0].name().toString(), payload, QoS.AT_LEAST_ONCE, false);
}
connectionSub = mqttSub.blockingConnection();
connectionSub.connect();
connectionSub.subscribe(topics);
for (int i = 0; i < messagesPerRun; ++i) {
Message message = connectionSub.receive(5, TimeUnit.SECONDS);
assertNotNull(message);
received++;
assertTrue(Arrays.equals(payload, message.getPayload()));
message.ack();
}
connectionSub.disconnect();
} }
} catch (Exception exception) {
connectionSub = mqttSub.blockingConnection(); LOG.error("unexpected exception", exception);
connectionSub.connect(); exception.printStackTrace();
connectionSub.subscribe(topics);
for (int i = 0; i < messagesPerRun; ++i) {
Message message = connectionSub.receive(5, TimeUnit.SECONDS);
assertNotNull(message);
received++;
assertTrue(Arrays.equals(payload, message.getPayload()));
message.ack();
}
connectionSub.disconnect();
} }
assertEquals("Should have received " + (messagesPerRun * (numberOfRuns + 1)) + " messages", (messagesPerRun * (numberOfRuns + 1)), received); assertEquals("Should have received " + (messagesPerRun * (numberOfRuns + 1)) + " messages", (messagesPerRun * (numberOfRuns + 1)), received);
} }