Make sure to close Vert.x instances that are opened for testing (#280)

Signed-off-by: Antoine Toulme <antoine@lunar-ocean.com>
pull/282/head
Antoine Toulme 5 years ago committed by Danno Ferrin
parent 0fdd09991d
commit 376ec111a3
  1. 18
      besu/src/test/java/org/hyperledger/besu/RunnerTest.java
  2. 6
      enclave/src/integration-test/java/org/hyperledger/besu/enclave/EnclaveTest.java
  3. 1
      ethereum/retesteth/src/main/java/org/hyperledger/besu/ethereum/retesteth/RetestethService.java
  4. 1
      metrics/core/src/test/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpServiceTest.java

@ -82,6 +82,8 @@ import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import org.apache.tuweni.units.bigints.UInt256; import org.apache.tuweni.units.bigints.UInt256;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
@ -94,6 +96,18 @@ public final class RunnerTest {
private static final int MAX_BACKGROUND_COMPACTIONS = 4; private static final int MAX_BACKGROUND_COMPACTIONS = 4;
private static final int BACKGROUND_THREAD_COUNT = 4; private static final int BACKGROUND_THREAD_COUNT = 4;
private Vertx vertx;
@Before
public void initVertx() {
vertx = Vertx.vertx();
}
@After
public void stopVertx() {
vertx.close();
}
@Rule public final TemporaryFolder temp = new TemporaryFolder(); @Rule public final TemporaryFolder temp = new TemporaryFolder();
@Test @Test
@ -179,7 +193,7 @@ public final class RunnerTest {
final MetricsConfiguration aheadMetricsConfiguration = metricsConfiguration(); final MetricsConfiguration aheadMetricsConfiguration = metricsConfiguration();
final RunnerBuilder runnerBuilder = final RunnerBuilder runnerBuilder =
new RunnerBuilder() new RunnerBuilder()
.vertx(Vertx.vertx()) .vertx(vertx)
.discovery(true) .discovery(true)
.p2pAdvertisedHost(listenHost) .p2pAdvertisedHost(listenHost)
.p2pListenPort(0) .p2pListenPort(0)
@ -313,7 +327,7 @@ public final class RunnerTest {
}); });
final Future<Void> future = Future.future(); final Future<Void> future = Future.future();
final HttpClient httpClient = Vertx.vertx().createHttpClient(); final HttpClient httpClient = vertx.createHttpClient();
httpClient.websocket( httpClient.websocket(
runnerBehind.getWebsocketPort().get(), runnerBehind.getWebsocketPort().get(),
WebSocketConfiguration.DEFAULT_WEBSOCKET_HOST, WebSocketConfiguration.DEFAULT_WEBSOCKET_HOST,

@ -44,13 +44,15 @@ public class EnclaveTest {
private static final String PAYLOAD = "a wonderful transaction"; private static final String PAYLOAD = "a wonderful transaction";
private static final String MOCK_KEY = "iOCzoGo5kwtZU0J41Z9xnGXHN6ZNukIa9MspvHtu3Jk="; private static final String MOCK_KEY = "iOCzoGo5kwtZU0J41Z9xnGXHN6ZNukIa9MspvHtu3Jk=";
private static Enclave enclave; private static Enclave enclave;
private Vertx vertx = Vertx.vertx(); private Vertx vertx;
private EnclaveFactory factory = new EnclaveFactory(vertx); private EnclaveFactory factory;
private static OrionTestHarness testHarness; private static OrionTestHarness testHarness;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
vertx = Vertx.vertx();
factory = new EnclaveFactory(vertx);
folder.create(); folder.create();
testHarness = testHarness =

@ -103,6 +103,7 @@ public class RetestethService {
public void stop() { public void stop() {
jsonRpcHttpService.stop(); jsonRpcHttpService.stop();
vertx.close();
} }
private static Map<String, JsonRpcMethod> mapOf(final JsonRpcMethod... rpcMethods) { private static Map<String, JsonRpcMethod> mapOf(final JsonRpcMethod... rpcMethods) {

@ -73,6 +73,7 @@ public class MetricsHttpServiceTest {
@AfterClass @AfterClass
public static void shutdownServer() { public static void shutdownServer() {
service.stop().join(); service.stop().join();
vertx.close();
} }
@Test @Test

Loading…
Cancel
Save