Skip to content

Commit

Permalink
cleaner testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Nov 3, 2023
1 parent d9ec92f commit 54232db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void deliver(List<Msg> newMsgs) {
if (newMsgs.isEmpty()) {
return;
}
log.debug("delivering: {} on: {}", newMsgs.size(), member.getId());
log.trace("delivering: {} on: {}", newMsgs.size(), member.getId());
channelHandlers.values().forEach(handler -> {
try {
handler.message(context.getId(), newMsgs);
Expand Down Expand Up @@ -229,14 +229,11 @@ private Reconcile gossipRound(ReliableBroadcast link, int ring) {
private void handle(Optional<Reconcile> result,
RingCommunications.Destination<Member, ReliableBroadcast> destination, Duration duration,
ScheduledExecutorService scheduler, Timer.Context timer) {
if (result.isEmpty()) {
return;
}
try {
Reconcile gossip;
try {
gossip = result.get();
} catch (NoSuchElementException e) {
log.debug("null gossiping with {} on: {}", destination.member().getId(), member.getId(), e.getCause());
return;
}
Reconcile gossip = result.get();
buffer.receive(gossip.getUpdatesList());
destination.link()
.update(ReconcileContext.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@ public void broadcast() throws Exception {
}
int rounds = Boolean.getBoolean("large_tests") ? 100 : 10;
for (int r = 0; r < rounds; r++) {
CountDownLatch round = new CountDownLatch(messengers.size());
for (Receiver receiver : receivers.values()) {
receiver.setRound(round);
}
CountDownLatch latch = new CountDownLatch(messengers.size());
round.set(latch);
var rnd = r;
messengers.stream().forEach(view -> {
byte[] rand = new byte[32];
Expand All @@ -122,8 +120,8 @@ public void broadcast() throws Exception {
buf.flip();
view.publish(ByteMessage.newBuilder().setContents(ByteString.copyFrom(buf)).build(), true);
});
boolean success = round.await(60, TimeUnit.SECONDS);
assertTrue(success, "Did not complete round: " + r + " waiting for: " + round.getCount());
boolean success = latch.await(60, TimeUnit.SECONDS);
assertTrue(success, "Did not complete round: " + r + " waiting for: " + latch.getCount());

current.incrementAndGet();
for (Receiver receiver : receivers.values()) {
Expand All @@ -140,12 +138,12 @@ public void broadcast() throws Exception {
.build()
.report();
}
final AtomicReference<CountDownLatch> round = new AtomicReference<>();

class Receiver implements MessageHandler {
final Set<Digest> counted = Collections.newSetFromMap(new ConcurrentHashMap<>());
final AtomicInteger current;
final Digest memberId;
final AtomicReference<CountDownLatch> round = new AtomicReference<>();

Receiver(Digest memberId, int cardinality, AtomicInteger current) {
this.current = current;
Expand Down Expand Up @@ -181,10 +179,6 @@ public void message(Digest context, List<Msg> messages) {
});
}

public void setRound(CountDownLatch round) {
this.round.set(round);
}

void reset() {
counted.clear();
}
Expand Down
2 changes: 1 addition & 1 deletion memberships/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<logger name="com.salesforce.apollo.stereotomy" level="warn" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="com.salesforce.apollo.membership.messaging.rbc" level="trace" additivity="false">
<logger name="com.salesforce.apollo.membership.messaging.rbc" level="warn" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="com.salesforce.apollo.membership.messaging.rbc.comms" level="warn" additivity="false">
Expand Down

0 comments on commit 54232db

Please sign in to comment.