-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODINV-944 OOM issue in mod-inventory (#668)
* close kafka producer to fix memory leaks * increase test coverage * increase test coverage, add wrapper for SimpleKafkaProducerManager * remove unneccesary tests * correct spaces * correct spaces * remove code smell * close producers * add shutdown method in marc bib update kafka * add shutdown method in qucik marc kafka * add shutdown hooks to close producers * increase test coverage * add test ConsortiumInstanceSharingConsumerVerticleTest
- Loading branch information
1 parent
4c8ca59
commit e0c3f01
Showing
10 changed files
with
174 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...g/folio/inventory/consortium/consumers/ConsortiumInstanceSharingConsumerVerticleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.folio.inventory.consortium.consumers; | ||
|
||
import static net.mguenther.kafka.junit.EmbeddedKafkaCluster.provisionWith; | ||
import static net.mguenther.kafka.junit.EmbeddedKafkaClusterConfig.defaultClusterConfig; | ||
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_ENV; | ||
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_HOST; | ||
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_MAX_REQUEST_SIZE; | ||
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_PORT; | ||
import static org.folio.inventory.dataimport.util.KafkaConfigConstants.KAFKA_REPLICATION_FACTOR; | ||
|
||
import io.vertx.core.DeploymentOptions; | ||
import io.vertx.core.Promise; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.json.JsonObject; | ||
import io.vertx.ext.unit.Async; | ||
import io.vertx.ext.unit.TestContext; | ||
import io.vertx.ext.unit.junit.VertxUnitRunner; | ||
import net.mguenther.kafka.junit.EmbeddedKafkaCluster; | ||
import org.folio.inventory.ConsortiumInstanceSharingConsumerVerticle; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
@RunWith(VertxUnitRunner.class) | ||
public class ConsortiumInstanceSharingConsumerVerticleTest { | ||
|
||
private static final String KAFKA_ENV_NAME = "test-env"; | ||
private static Vertx vertx = Vertx.vertx(); | ||
public static EmbeddedKafkaCluster cluster; | ||
|
||
@Mock | ||
private static ConsortiumInstanceSharingHandler consortiumInstanceSharingHandler; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
public void shouldDeployVerticle(TestContext context) { | ||
Async async = context.async(); | ||
cluster = provisionWith(defaultClusterConfig()); | ||
cluster.start(); | ||
String[] hostAndPort = cluster.getBrokerList().split(":"); | ||
DeploymentOptions options = new DeploymentOptions() | ||
.setConfig(new JsonObject() | ||
.put(KAFKA_HOST, hostAndPort[0]) | ||
.put(KAFKA_PORT, hostAndPort[1]) | ||
.put(KAFKA_REPLICATION_FACTOR, "1") | ||
.put(KAFKA_ENV, KAFKA_ENV_NAME) | ||
.put(KAFKA_MAX_REQUEST_SIZE, "1048576")) | ||
.setWorker(true); | ||
|
||
Promise<String> promise = Promise.promise(); | ||
vertx.deployVerticle(ConsortiumInstanceSharingConsumerVerticle.class.getName(), options, promise); | ||
|
||
promise.future().onComplete(ar -> { | ||
context.assertTrue(ar.succeeded()); | ||
async.complete(); | ||
}); | ||
|
||
} | ||
|
||
@AfterClass | ||
public static void tearDownClass(TestContext context) { | ||
Async async = context.async(); | ||
vertx.close(ar -> { | ||
cluster.stop(); | ||
consortiumInstanceSharingHandler.shutdown(); | ||
async.complete(); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.