Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased timeout to fix build failure on slow GitHub build systems #843

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions broker/src/test/java/io/moquette/testclient/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
*
* You may elect to redistribute this code under either of these licenses.
*/

package io.moquette.testclient;

import io.moquette.BrokerConstants;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
Expand Down Expand Up @@ -52,6 +50,9 @@ public interface ICallback {
}

private static final Logger LOG = LoggerFactory.getLogger(Client.class);

private static final Duration TIMEOUT_DURATION = Duration.ofMillis(300);

final ClientNettyMQTTHandler handler = new ClientNettyMQTTHandler();
EventLoopGroup workerGroup;
Channel m_channel;
Expand Down Expand Up @@ -195,7 +196,7 @@ public MqttSubAckMessage subscribe(String topic1, MqttQoS qos1, String topic2, M
.addSubscription(qos2, topic2)
.build();

return doSubscribeWithAckCasting(subscribeMessage, 200, TimeUnit.MILLISECONDS);
return doSubscribeWithAckCasting(subscribeMessage, TIMEOUT_DURATION.toMillis(), TimeUnit.MILLISECONDS);
}

public MqttSubAckMessage subscribe(String topic, MqttQoS qos) {
Expand All @@ -204,16 +205,16 @@ public MqttSubAckMessage subscribe(String topic, MqttQoS qos) {
.addSubscription(qos, topic)
.build();

return doSubscribeWithAckCasting(subscribeMessage, 200, TimeUnit.MILLISECONDS);
return doSubscribeWithAckCasting(subscribeMessage, TIMEOUT_DURATION.toMillis(), TimeUnit.MILLISECONDS);
}

public MqttSubAckMessage subscribeWithIdentifier(String topic, MqttQoS qos, int subscriptionIdentifier) {
return subscribeWithIdentifier(topic, qos, subscriptionIdentifier, 200, TimeUnit.MILLISECONDS);
return subscribeWithIdentifier(topic, qos, subscriptionIdentifier, TIMEOUT_DURATION.toMillis(), TimeUnit.MILLISECONDS);
}

@NotNull
public MqttSubAckMessage subscribeWithIdentifier(String topic, MqttQoS qos, int subscriptionIdentifier,
int timeout, TimeUnit timeUnit) {
long timeout, TimeUnit timeUnit) {
MqttProperties subProps = new MqttProperties();
subProps.add(new MqttProperties.IntegerProperty(
MqttProperties.MqttPropertyType.SUBSCRIPTION_IDENTIFIER.value(),
Expand All @@ -229,7 +230,7 @@ public MqttSubAckMessage subscribeWithIdentifier(String topic, MqttQoS qos, int
}

@NotNull
private MqttSubAckMessage doSubscribeWithAckCasting(MqttSubscribeMessage subscribeMessage, int timeout, TimeUnit timeUnit) {
private MqttSubAckMessage doSubscribeWithAckCasting(MqttSubscribeMessage subscribeMessage, long timeout, TimeUnit timeUnit) {
doSubscribe(subscribeMessage, timeout, timeUnit);

final MqttMessage subAckMessage = this.receivedMsg.get();
Expand All @@ -240,7 +241,7 @@ private MqttSubAckMessage doSubscribeWithAckCasting(MqttSubscribeMessage subscri
return (MqttSubAckMessage) subAckMessage;
}

private void doSubscribe(MqttSubscribeMessage subscribeMessage, int timeout, TimeUnit timeUnit) {
private void doSubscribe(MqttSubscribeMessage subscribeMessage, long timeout, TimeUnit timeUnit) {
final CountDownLatch subscribeAckLatch = new CountDownLatch(1);
this.setCallback(msg -> {
receivedMsg.getAndSet(msg);
Expand Down Expand Up @@ -300,7 +301,7 @@ public MqttMessage subscribeWithError(String topic, MqttQoS qos) {
.addSubscription(qos, topic)
.build();

doSubscribe(subscribeMessage, 200, TimeUnit.MILLISECONDS);
doSubscribe(subscribeMessage, TIMEOUT_DURATION.toMillis(), TimeUnit.MILLISECONDS);
return this.receivedMsg.get();
}

Expand Down
Loading