Skip to content

Commit

Permalink
test comms cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Dec 23, 2023
1 parent f7b3614 commit 2fdceac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
package com.salesforce.apollo.thoth;

import com.google.protobuf.Any;
import com.salesforce.apollo.gorgoneion.proto.SignedNonce;
import com.salesforce.apollo.stereotomy.event.proto.Validations;
import com.salesforce.apollo.archipelago.LocalServer;
import com.salesforce.apollo.archipelago.Router;
import com.salesforce.apollo.archipelago.ServerConnectionCache;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.gorgoneion.Gorgoneion;
Expand All @@ -19,14 +18,17 @@
import com.salesforce.apollo.gorgoneion.client.client.comm.AdmissionsClient;
import com.salesforce.apollo.gorgoneion.comm.admissions.AdmissionsServer;
import com.salesforce.apollo.gorgoneion.comm.admissions.AdmissionsService;
import com.salesforce.apollo.gorgoneion.proto.SignedNonce;
import com.salesforce.apollo.membership.stereotomy.ControlledIdentifierMember;
import com.salesforce.apollo.stereotomy.KERL;
import com.salesforce.apollo.stereotomy.KeyState;
import com.salesforce.apollo.stereotomy.StereotomyImpl;
import com.salesforce.apollo.stereotomy.event.proto.Validations;
import com.salesforce.apollo.stereotomy.mem.MemKERL;
import com.salesforce.apollo.stereotomy.mem.MemKeyStore;
import com.salesforce.apollo.stereotomy.services.proto.ProtoKERLAdapter;
import com.salesforce.apollo.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

import java.security.SecureRandom;
Expand All @@ -44,6 +46,15 @@
*/
public class BootstrappingTest extends AbstractDhtTest {

private Router clientRouter;

@AfterEach
public void closeClient() throws Exception {
if (clientRouter != null) {
clientRouter.close(Duration.ofSeconds(3));
}
}

@Test
public void smokin() throws Exception {
routers.values().forEach(r -> r.start());
Expand Down Expand Up @@ -71,7 +82,7 @@ context, new DirectPublisher(new ProtoKERLAdapter(k)), r,
var client = new ControlledIdentifierMember(clientStereotomy.newIdentifier());

// Registering client comms
var clientRouter = new LocalServer(prefix, client).router(ServerConnectionCache.newBuilder().setTarget(2));
clientRouter = new LocalServer(prefix, client).router(ServerConnectionCache.newBuilder().setTarget(2));
AdmissionsService admissions = mock(AdmissionsService.class);
var clientComminications = clientRouter.create(client, context.getId(), admissions, ":admissions-client",
r -> new AdmissionsServer(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.salesforce.apollo.thoth;

import com.google.protobuf.Empty;
import com.salesforce.apollo.thoth.proto.Thoth_Grpc;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.membership.stereotomy.ControlledIdentifierMember;
import com.salesforce.apollo.stereotomy.ControlledIdentifier;
Expand All @@ -18,6 +17,7 @@
import com.salesforce.apollo.stereotomy.mem.MemKERL;
import com.salesforce.apollo.stereotomy.mem.MemKeyStore;
import com.salesforce.apollo.thoth.grpc.ThothServer;
import com.salesforce.apollo.thoth.proto.Thoth_Grpc;
import io.grpc.Channel;
import io.grpc.ServerBuilder;
import io.grpc.inprocess.InProcessChannelBuilder;
Expand Down Expand Up @@ -56,10 +56,9 @@ public void smokin() throws Exception {
.addService(new ThothServer(new Thoth(stereotomy)));
var server = serverBuilder.build();
server.start();
var channel = InProcessChannelBuilder.forName(localId).usePlaintext().build();
try {
var channel = InProcessChannelBuilder.forName(localId).usePlaintext().build();
var thoth = new ThothClient(channel);

ControlledIdentifier<SelfAddressingIdentifier> controller = stereotomy.newIdentifier();

// delegated inception
Expand Down Expand Up @@ -90,6 +89,7 @@ public void smokin() throws Exception {
coords = controller.seal(builder);
thoth.commit(coords);
} finally {
channel.shutdown();
server.shutdown();
server.awaitTermination(3, TimeUnit.SECONDS);
}
Expand Down

0 comments on commit 2fdceac

Please sign in to comment.