diff --git a/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/IndexerBoltTest.java b/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/IndexerBoltTest.java index fc1a6243a..d359e3f3f 100644 --- a/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/IndexerBoltTest.java +++ b/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/IndexerBoltTest.java @@ -36,22 +36,17 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.Timeout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; -public class IndexerBoltTest { - - @Rule public Timeout globalTimeout = Timeout.seconds(120); +public class IndexerBoltTest extends AbstractOpenSearchTest { private IndexerBolt bolt; protected TestOutputCollector output; private static final Logger LOG = LoggerFactory.getLogger(IndexerBoltTest.class); + private static ExecutorService executorService; @BeforeClass @@ -65,14 +60,6 @@ public static void afterClass() { executorService = null; } - @Rule - public GenericContainer opensearchContainer = - new GenericContainer(DockerImageName.parse("opensearchproject/opensearch:latest")) - .withExposedPorts(9200) - .withEnv("plugins.security.disabled", "true") - .withEnv("discovery.type", "single-node") - .withEnv("OPENSEARCH_JAVA_OPTS", "-Xms512m -Xmx512m"); - @Before public void setupIndexerBolt() { @@ -96,6 +83,7 @@ public void setupIndexerBolt() { @After public void close() { LOG.info("Closing indexer bolt and Opensearch container"); + super.close(); bolt.cleanup(); output = null; } diff --git a/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/StatusBoltTest.java b/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/StatusBoltTest.java index 2f19b09a2..42417444e 100644 --- a/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/StatusBoltTest.java +++ b/external/opensearch/src/test/java/com/digitalpebble/stormcrawler/opensearch/bolt/StatusBoltTest.java @@ -40,9 +40,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.Timeout; import org.opensearch.action.get.GetRequest; import org.opensearch.action.get.GetResponse; import org.opensearch.client.RequestOptions; @@ -51,10 +49,8 @@ import org.opensearch.client.RestHighLevelClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.utility.DockerImageName; -public class StatusBoltTest { +public class StatusBoltTest extends AbstractOpenSearchTest { private StatusUpdaterBolt bolt; protected TestOutputCollector output; @@ -64,16 +60,6 @@ public class StatusBoltTest { private static final Logger LOG = LoggerFactory.getLogger(StatusBoltTest.class); private static ExecutorService executorService; - @Rule public Timeout globalTimeout = Timeout.seconds(60); - - @Rule - public final GenericContainer container = - new GenericContainer(DockerImageName.parse("opensearchproject/opensearch:latest")) - .withExposedPorts(9200) - .withEnv("plugins.security.disabled", "true") - .withEnv("discovery.type", "single-node") - .withEnv("OPENSEARCH_JAVA_OPTS", "-Xms512m -Xmx512m"); - @BeforeClass public static void beforeClass() { executorService = Executors.newFixedThreadPool(2); @@ -92,7 +78,9 @@ public void setupStatusBolt() throws IOException { RestClientBuilder builder = RestClient.builder( - new HttpHost(container.getHost(), container.getMappedPort(9200))); + new HttpHost( + opensearchContainer.getHost(), + opensearchContainer.getMappedPort(9200))); client = new RestHighLevelClient(builder); @@ -103,7 +91,7 @@ public void setupStatusBolt() throws IOException { conf.put( "opensearch.status.addresses", - container.getHost() + ":" + container.getFirstMappedPort()); + opensearchContainer.getHost() + ":" + opensearchContainer.getFirstMappedPort()); conf.put("scheduler.class", "com.digitalpebble.stormcrawler.persistence.DefaultScheduler"); @@ -119,8 +107,8 @@ public void setupStatusBolt() throws IOException { @After public void close() { LOG.info("Closing updater bolt and Opensearch container"); + super.close(); bolt.cleanup(); - container.close(); output = null; try { client.close();