Skip to content

Commit

Permalink
Use manual acknowledgment to order logging
Browse files Browse the repository at this point in the history
Fix system tests flaky behavior on native execution
  • Loading branch information
LukasBrand committed Sep 21, 2023
1 parent 8fdc906 commit a9905db
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/hivemq/cli/mqtt/MqttClientExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void mqtt5Subscribe(
Logger.debug("{} sending SUBSCRIBE\n {}", clientLogPrefix, subscribeMessage);

client.toAsync()
.subscribe(subscribeMessage, new SubscribeMqtt5PublishCallback(subscribeOptions, client))
.subscribe(subscribeMessage, new SubscribeMqtt5PublishCallback(subscribeOptions, client), true)
.whenComplete((subAck, throwable) -> {
if (throwable != null) {
if (throwable instanceof Mqtt5SubAckException) {
Expand Down Expand Up @@ -147,7 +147,7 @@ void mqtt3Subscribe(
Logger.debug("{} sending SUBSCRIBE\n {}", clientLogPrefix, subscribeMessage);

client.toAsync()
.subscribe(subscribeMessage, new SubscribeMqtt3PublishCallback(subscribeOptions, client))
.subscribe(subscribeMessage, new SubscribeMqtt3PublishCallback(subscribeOptions, client), true)
.whenComplete((subAck, throwable) -> {
if (throwable != null) {
if (throwable instanceof Mqtt3SubAckException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ public void accept(final @NotNull Mqtt3Publish mqtt3Publish) {
}
System.out.println(message);
}
mqtt3Publish.acknowledge();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ public void accept(final @NotNull Mqtt5Publish mqtt5Publish) {
}
System.out.println(message);
}
mqtt5Publish.acknowledge();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void test_shell_publish_mqtt5_qos1_logging_not_authorized() throws IOException {
mqttCliShell.connectClient(hivemq, '5');
final List<String> publishCommand = List.of("pub", "-t", "test", "-m", "test", "-q", "1");
mqttCliShell.executeAsync(publishCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending PUBLISH")
.awaitLog("MqttPublish")
.awaitLog("received PUBACK")
Expand Down Expand Up @@ -123,7 +123,7 @@ void test_shell_publish_mqtt5_qos2_logging_not_authorized() throws IOException {
mqttCliShell.connectClient(hivemq, '5');
final List<String> publishCommand = List.of("pub", "-t", "test", "-m", "test", "-q", "2");
mqttCliShell.executeAsync(publishCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending PUBLISH")
.awaitLog("MqttPublish")
.awaitLog("received PUBREC")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void test_shell_subscribe_mqtt3_qos0_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '3');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "0");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down Expand Up @@ -122,7 +122,7 @@ void test_shell_subscribe_mqtt5_qos0_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '5');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "0");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down Expand Up @@ -168,7 +168,7 @@ void test_shell_subscribe_mqtt3_qos1_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '3');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "1");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down Expand Up @@ -216,7 +216,7 @@ void test_shell_subscribe_mqtt5_qos1_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '5');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "1");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down Expand Up @@ -262,7 +262,7 @@ void test_shell_subscribe_mqtt3_qos2_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '3');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "2");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down Expand Up @@ -314,7 +314,7 @@ void test_shell_subscribe_mqtt5_qos2_logging_not_authorized() throws IOException
mqttCliShell.connectClient(hivemq, '5');
final List<String> subscribeCommand = List.of("sub", "-t", "test", "-q", "2");
mqttCliShell.executeAsync(subscribeCommand)
.awaitStdOut(String.format("cliTest@%s>", hivemq.getHost()))
.awaitStdErr(String.format("cliTest@%s", hivemq.getHost()))
.awaitLog("sending SUBSCRIBE")
.awaitLog("MqttSubscribe")
.awaitLog("received SUBACK")
Expand Down

0 comments on commit a9905db

Please sign in to comment.