Skip to content

Commit

Permalink
Cleanup and extend SwarmTest timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Dec 30, 2023
1 parent d0a54a9 commit 64ee543
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import com.github.benmanes.caffeine.cache.RemovalCause;
import com.google.common.collect.HashMultiset;
import com.salesforce.apollo.archipelago.RouterImpl;
import com.salesforce.apollo.cryptography.JohnHancock;
import com.salesforce.apollo.cryptography.SigningThreshold;
import com.salesforce.apollo.cryptography.Verifier;
import com.salesforce.apollo.fireflies.comm.entrance.Entrance;
import com.salesforce.apollo.fireflies.proto.Validation;
Expand All @@ -25,7 +23,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -96,18 +93,6 @@ public <S extends SigningMember, M extends Member> Bootstrapper(S member, Durati

public EventValidation getValidator() {
return new EventValidation() {
@Override
public Verifier.Filtered filtered(EventCoordinates coordinates, SigningThreshold threshold,
JohnHancock signature, InputStream message) {
log.trace("Filtering for: {} on: {}", coordinates, member.getId());
var keyState = getKeyState(coordinates);
if (keyState.isEmpty()) {
return new Verifier.Filtered(false, 0, null);
}
KeyState ks = keyState.get();
var v = new Verifier.DefaultVerifier(ks.getKeys());
return v.filtered(threshold, signature, message);
}

@Override
public Optional<KeyState> getKeyState(EventCoordinates coordinates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void swarm() throws Exception {
.start(() -> countdown.get().countDown(), gossipDuration, Collections.emptyList(),
Executors.newScheduledThreadPool(2, Thread.ofVirtual().factory()));

assertTrue(countdown.get().await(30, TimeUnit.SECONDS), "Kernel did not bootstrap");
assertTrue(countdown.get().await(60, TimeUnit.SECONDS), "Kernel did not bootstrap");

var bootstrappers = views.subList(0, seeds.size());
countdown.set(new CountDownLatch(seeds.size() - 1));
Expand All @@ -125,7 +125,7 @@ public void swarm() throws Exception {
Executors.newScheduledThreadPool(2, Thread.ofVirtual().factory())));

// Test that all bootstrappers up
var success = countdown.get().await(largeTests ? 2400 : 30, TimeUnit.SECONDS);
var success = countdown.get().await(largeTests ? 2400 : 60, TimeUnit.SECONDS);
var failed = bootstrappers.stream()
.filter(e -> e.getContext().activeCount() != bootstrappers.size())
.map(
Expand All @@ -138,7 +138,7 @@ public void swarm() throws Exception {
views.forEach(v -> v.start(() -> countdown.get().countDown(), gossipDuration, seeds,
Executors.newScheduledThreadPool(2, Thread.ofVirtual().factory())));

success = countdown.get().await(largeTests ? 2400 : 60, TimeUnit.SECONDS);
success = countdown.get().await(largeTests ? 2400 : 120, TimeUnit.SECONDS);

// Test that all views are up
failed = views.stream()
Expand All @@ -149,7 +149,7 @@ public void swarm() throws Exception {
assertTrue(success, "Views did not start, expected: " + views.size() + " failed: " + failed.size() + " views: "
+ failed);

success = Utils.waitForCondition(largeTests ? 2400_000 : 30_000, 1_000, () -> {
success = Utils.waitForCondition(largeTests ? 2400_000 : 120_000, 1_000, () -> {
return views.stream().filter(view -> view.getContext().activeCount() != CARDINALITY).count() == 0;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
*/
package com.salesforce.apollo.stereotomy;

import com.salesforce.apollo.cryptography.JohnHancock;
import com.salesforce.apollo.cryptography.SigningThreshold;
import com.salesforce.apollo.cryptography.Verifier.Filtered;
import com.salesforce.apollo.stereotomy.event.EstablishmentEvent;
import com.salesforce.apollo.stereotomy.identifier.Identifier;
import org.joou.ULong;

import java.io.InputStream;
import java.util.Optional;

/**
Expand All @@ -24,11 +20,6 @@
public interface EventValidation {

EventValidation NONE = new EventValidation() {
@Override
public Filtered filtered(EventCoordinates coordinates, SigningThreshold threshold, JohnHancock signature,
InputStream message) {
return null;
}

@Override
public Optional<KeyState> getKeyState(EventCoordinates coordinates) {
Expand All @@ -52,11 +43,6 @@ public boolean validate(EventCoordinates coordinates) {
};

EventValidation NO_VALIDATION = new EventValidation() {
@Override
public Filtered filtered(EventCoordinates coordinates, SigningThreshold threshold, JohnHancock signature,
InputStream message) {
return null;
}

@Override
public Optional<KeyState> getKeyState(EventCoordinates coordinates) {
Expand All @@ -79,9 +65,6 @@ public boolean validate(EventCoordinates coordinates) {
}
};

Filtered filtered(EventCoordinates coordinates, SigningThreshold threshold, JohnHancock signature,
InputStream message);

Optional<KeyState> getKeyState(EventCoordinates coordinates);

Optional<KeyState> getKeyState(Identifier identifier, ULong seqNum);
Expand Down
15 changes: 4 additions & 11 deletions thoth/src/main/java/com/salesforce/apollo/thoth/Ani.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

package com.salesforce.apollo.thoth;

import com.salesforce.apollo.cryptography.*;
import com.salesforce.apollo.cryptography.Verifier.Filtered;
import com.salesforce.apollo.cryptography.Digest;
import com.salesforce.apollo.cryptography.JohnHancock;
import com.salesforce.apollo.cryptography.SignatureAlgorithm;
import com.salesforce.apollo.cryptography.Verifier;
import com.salesforce.apollo.cryptography.ssl.CertificateValidator;
import com.salesforce.apollo.stereotomy.*;
import com.salesforce.apollo.stereotomy.KEL.KeyStateWithAttachments;
Expand All @@ -20,7 +22,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.security.PublicKey;
import java.time.Duration;
import java.util.HashMap;
Expand Down Expand Up @@ -49,14 +50,6 @@ public CertificateValidator certificateValidator(Duration timeout) {

public EventValidation eventValidation(Duration timeout) {
return new EventValidation() {
@Override
public Filtered filtered(EventCoordinates coordinates, SigningThreshold threshold, JohnHancock signature,
InputStream message) {
log.trace("Filtering for: {} on: {}", coordinates, member);
KeyState ks = kerl.getKeyState(coordinates);
var v = new Verifier.DefaultVerifier(ks.getKeys());
return v.filtered(threshold, signature, message);
}

@Override
public Optional<KeyState> getKeyState(EventCoordinates coordinates) {
Expand Down

0 comments on commit 64ee543

Please sign in to comment.