Skip to content

Commit

Permalink
Issue #878: stabilize MQTT client actor tests; remove unused metric.
Browse files Browse the repository at this point in the history
Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
  • Loading branch information
yufei-cai committed Dec 6, 2020
1 parent ccf29a1 commit 1ba48d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;

import org.eclipse.ditto.model.base.common.ByteBufferUtils;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void testSubscribeFails() {
final ActorRef mqttClientActor = actorSystem.actorOf(props, "mqttClientActor-testSubscribeFails");

mqttClientActor.tell(OpenConnection.of(connectionId, DittoHeaders.empty()), getRef());
expectMsgClass(Status.Failure.class);
expectMsgClass(Duration.ofSeconds(10L), Status.Failure.class);

mqttClientActor.tell(CloseConnection.of(connectionId, DittoHeaders.empty()), getRef());
expectMsg(DISCONNECTED_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;

import org.eclipse.ditto.model.base.common.ByteBufferUtils;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void testSubscribeFails() {
final ActorRef mqttClientActor = actorSystem.actorOf(props, "mqttClientActor-testSubscribeFails");

mqttClientActor.tell(OpenConnection.of(connectionId, DittoHeaders.empty()), getRef());
expectMsgClass(Status.Failure.class);
expectMsgClass(Duration.ofSeconds(10L), Status.Failure.class);

mqttClientActor.tell(CloseConnection.of(connectionId, DittoHeaders.empty()), getRef());
expectMsg(DISCONNECTED_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import org.eclipse.ditto.services.utils.ddata.DistributedData;
import org.eclipse.ditto.services.utils.ddata.DistributedDataConfig;
import org.eclipse.ditto.services.utils.metrics.DittoMetrics;
import org.eclipse.ditto.services.utils.metrics.instruments.gauge.Gauge;

import akka.actor.ActorRef;
import akka.actor.ActorRefFactory;
Expand All @@ -43,7 +41,6 @@ public abstract class AbstractDDataHandler<K, S, T extends DDataUpdate<S>>
protected final SelfUniqueAddress selfUniqueAddress;

private final String topicType;
private final Gauge ddataMetrics;

protected AbstractDDataHandler(final DistributedDataConfig config,
final ActorRefFactory actorRefFactory,
Expand All @@ -53,7 +50,6 @@ protected AbstractDDataHandler(final DistributedDataConfig config,
super(config, actorRefFactory, ddataExecutor);
this.topicType = topicType;
this.selfUniqueAddress = SelfUniqueAddress.apply(Cluster.get(actorSystem).selfUniqueAddress());
ddataMetrics = DittoMetrics.gauge("pubsub-ddata-entries").tag("topic", topicType);
}

@Override
Expand All @@ -63,10 +59,8 @@ public CompletionStage<Map<K, scala.collection.immutable.Set<S>>> read(
return get(readConsistency).thenApply(optional -> {
if (optional.isPresent()) {
final ORMultiMap<K, S> mmap = optional.get();
ddataMetrics.set((long) mmap.size());
return CollectionConverters.asJava(mmap.entries());
} else {
ddataMetrics.set(0L);
return Map.of();
}
});
Expand Down

0 comments on commit 1ba48d1

Please sign in to comment.