diff --git a/thoth/src/test/java/com/salesforce/apollo/thoth/BootstrappingTest.java b/thoth/src/test/java/com/salesforce/apollo/thoth/BootstrappingTest.java index d36c6707d..ee0479a04 100644 --- a/thoth/src/test/java/com/salesforce/apollo/thoth/BootstrappingTest.java +++ b/thoth/src/test/java/com/salesforce/apollo/thoth/BootstrappingTest.java @@ -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; @@ -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; @@ -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()); @@ -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( diff --git a/thoth/src/test/java/com/salesforce/apollo/thoth/ThothServerTest.java b/thoth/src/test/java/com/salesforce/apollo/thoth/ThothServerTest.java index 0498289be..06642ec51 100644 --- a/thoth/src/test/java/com/salesforce/apollo/thoth/ThothServerTest.java +++ b/thoth/src/test/java/com/salesforce/apollo/thoth/ThothServerTest.java @@ -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; @@ -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; @@ -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 controller = stereotomy.newIdentifier(); // delegated inception @@ -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); }