You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stormcrawler.apache.org by rz...@apache.org on 2025/07/23 07:16:07 UTC
(stormcrawler) branch main updated: #1560 - Test coverage for Solr cloud (#1608)
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/stormcrawler.git
The following commit(s) were added to refs/heads/main by this push:
new 54c3f3e5 #1560 - Test coverage for Solr cloud (#1608)
54c3f3e5 is described below
commit 54c3f3e5e887bbda3cc23600655b54a928c7e08c
Author: Markos Volikas <11...@users.noreply.github.com>
AuthorDate: Wed Jul 23 10:16:03 2025 +0300
#1560 - Test coverage for Solr cloud (#1608)
* #1560 add simple consistency test for solr cloud
* #1560 add licenses
* #1560 migrate to junit 5
* #1560 fix formatting
* #1560 fix assertions import, use shared container when possible
---
external/solr/configsets/docs/conf/solrconfig.xml | 3 +
.../solr/configsets/metrics/conf/solrconfig.xml | 3 +
.../solr/configsets/status/conf/solrconfig.xml | 3 +
external/solr/pom.xml | 2 +-
.../apache/stormcrawler/solr/SolrConnection.java | 19 +--
.../stormcrawler/solr/CloudConnectionTest.java | 142 +++++++++++++++++++++
.../stormcrawler/solr/SolrCloudContainerTest.java | 91 +++++++++++++
.../solr/{persistence => }/SolrContainerTest.java | 34 ++---
.../{persistence => bolt}/IndexerBoltTest.java | 26 ++--
.../stormcrawler/solr/persistence/SpoutTest.java | 28 ++--
.../solr/persistence/StatusBoltTest.java | 25 ++--
.../solr/src/test/resources/docker-compose.yml | 47 +++++++
12 files changed, 358 insertions(+), 65 deletions(-)
diff --git a/external/solr/configsets/docs/conf/solrconfig.xml b/external/solr/configsets/docs/conf/solrconfig.xml
index 13c04046..759110ee 100755
--- a/external/solr/configsets/docs/conf/solrconfig.xml
+++ b/external/solr/configsets/docs/conf/solrconfig.xml
@@ -23,6 +23,9 @@ under the License.
<httpCaching never304="true" />
</requestDispatcher>
<updateHandler class="solr.DirectUpdateHandler2">
+ <updateLog>
+ <str name="dir">${solr.ulog.dir:}</str>
+ </updateLog>
<autoCommit>
<maxDocs>10000</maxDocs>
<maxTime>10000</maxTime>
diff --git a/external/solr/configsets/metrics/conf/solrconfig.xml b/external/solr/configsets/metrics/conf/solrconfig.xml
index 07bff00a..1eb52da4 100755
--- a/external/solr/configsets/metrics/conf/solrconfig.xml
+++ b/external/solr/configsets/metrics/conf/solrconfig.xml
@@ -24,6 +24,9 @@ under the License.
</requestDispatcher>
<updateHandler class="solr.DirectUpdateHandler2">
+ <updateLog>
+ <str name="dir">${solr.ulog.dir:}</str>
+ </updateLog>
<autoCommit>
<maxDocs>10000</maxDocs>
<maxTime>10000</maxTime>
diff --git a/external/solr/configsets/status/conf/solrconfig.xml b/external/solr/configsets/status/conf/solrconfig.xml
index acfa317d..9984b47f 100755
--- a/external/solr/configsets/status/conf/solrconfig.xml
+++ b/external/solr/configsets/status/conf/solrconfig.xml
@@ -23,6 +23,9 @@ under the License.
<httpCaching never304="true" />
</requestDispatcher>
<updateHandler class="solr.DirectUpdateHandler2">
+ <updateLog>
+ <str name="dir">${solr.ulog.dir:}</str>
+ </updateLog>
<autoCommit>
<maxDocs>10000</maxDocs>
<maxTime>10000</maxTime>
diff --git a/external/solr/pom.xml b/external/solr/pom.xml
index e90a8dbe..54f97430 100644
--- a/external/solr/pom.xml
+++ b/external/solr/pom.xml
@@ -50,7 +50,7 @@ under the License.
<dependency>
<groupId>org.testcontainers</groupId>
- <artifactId>solr</artifactId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
diff --git a/external/solr/src/main/java/org/apache/stormcrawler/solr/SolrConnection.java b/external/solr/src/main/java/org/apache/stormcrawler/solr/SolrConnection.java
index ba0758ee..1cf317eb 100644
--- a/external/solr/src/main/java/org/apache/stormcrawler/solr/SolrConnection.java
+++ b/external/solr/src/main/java/org/apache/stormcrawler/solr/SolrConnection.java
@@ -353,18 +353,21 @@ public class SolrConnection {
}
}
+ public void commit() throws IOException, SolrServerException {
+ updateClient.commit();
+ }
+
public void close() throws IOException, SolrServerException {
executor.shutdown();
- if (updateClient != null) {
- if (cloud) {
- flushAllUpdates(true);
- }
-
- client.commit();
- updateClient.commit();
- updateClient.close();
+ if (cloud) {
+ flushAllUpdates(true);
}
+
+ commit();
+
+ client.close();
+ updateClient.close();
}
// Helper classes to hold pending updates
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/CloudConnectionTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/CloudConnectionTest.java
new file mode 100644
index 00000000..a2037b16
--- /dev/null
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/CloudConnectionTest.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stormcrawler.solr;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class CloudConnectionTest extends SolrCloudContainerTest {
+ private static final Logger LOG = LoggerFactory.getLogger(CloudConnectionTest.class);
+
+ private static SolrConnection connection;
+ private static CloudHttp2SolrClient client;
+
+ @BeforeAll
+ static void setup() {
+ createCollection("docs", 1, 2);
+
+ Map<String, Object> conf = new HashMap<>();
+ conf.put("solr.indexer.zkhost", "localhost:2181");
+ conf.put("solr.indexer.collection", "docs");
+ conf.put("solr.indexer.batchUpdateSize", 1);
+ conf.put("solr.indexer.flushAfterNoUpdatesMillis", 5_000);
+
+ connection = SolrConnection.getConnection(conf, "indexer");
+ client =
+ new CloudHttp2SolrClient.Builder(
+ Collections.singletonList("localhost:2181"), Optional.empty())
+ .withDefaultCollection("docs")
+ .build();
+ }
+
+ @Test
+ @Timeout(value = 120, unit = TimeUnit.SECONDS)
+ void consistencyTest() throws InterruptedException {
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("url", "test");
+ doc.addField("content", "test");
+ connection.addAsync(doc);
+
+ int leader = getLiveLeader().getNodeName().contains("8983") ? 8983 : 8984;
+
+ // Kill the leader node
+ stopNode(leader);
+
+ // Wait for recovery
+ while (getLiveLeader() == null) {
+ Thread.sleep(100);
+ }
+
+ assertEquals(1, getNumFound());
+ }
+
+ private Replica getLiveLeader() {
+ DocCollection col = client.getClusterState().getCollection("docs");
+ Replica leader = col.getActiveSlices().stream().findFirst().orElse(null).getLeader();
+
+ if (leader == null) {
+ return null;
+ }
+
+ if (!client.getClusterState().getLiveNodes().contains(leader.getNodeName())) {
+ return null;
+ }
+
+ return leader;
+ }
+
+ private void startNode(int port) {
+ environment
+ .getContainerByServiceName("solr")
+ .ifPresent(
+ container -> {
+ try {
+ container.execInContainer(
+ "/opt/solr/bin/solr",
+ "start",
+ "-c",
+ "-p",
+ Integer.toString(port),
+ "-s",
+ "/var/solr/" + port,
+ "-z",
+ "zookeeper:2181");
+ } catch (Exception e) {
+ LOG.error("Error while starting Solr node {}", port, e);
+ }
+ });
+ }
+
+ private void stopNode(int port) {
+ environment
+ .getContainerByServiceName("solr")
+ .ifPresent(
+ container -> {
+ try {
+ container.execInContainer(
+ "/opt/solr/bin/solr", "stop", "-p", Integer.toString(port));
+ } catch (Exception e) {
+ LOG.error("Error while stopping Solr node {}", port, e);
+ }
+ });
+ }
+
+ private long getNumFound() {
+ SolrQuery query = new SolrQuery();
+ query.setQuery("*:*");
+ QueryRequest queryRequest = new QueryRequest(query);
+ QueryResponse response = connection.requestAsync(queryRequest).join();
+ return response.getResults().getNumFound();
+ }
+}
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/SolrCloudContainerTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/SolrCloudContainerTest.java
new file mode 100644
index 00000000..639f51d1
--- /dev/null
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/SolrCloudContainerTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stormcrawler.solr;
+
+import java.io.File;
+import org.junit.jupiter.api.BeforeAll;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ComposeContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.containers.wait.strategy.WaitStrategy;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.utility.MountableFile;
+
+@Testcontainers
+public abstract class SolrCloudContainerTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SolrCloudContainerTest.class);
+
+ private static final String configsetsPath = new File("configsets").getAbsolutePath();
+ private static final WaitStrategy waitStrategy =
+ Wait.forHttp("/solr/admin/cores?action=STATUS").forStatusCode(200);
+
+ @Container
+ static ComposeContainer environment =
+ new ComposeContainer(new File("src/test/resources/docker-compose.yml"))
+ .withExposedService("solr", 8983, waitStrategy)
+ .withExposedService("zookeeper", 2181);
+
+ @BeforeAll
+ static void before() {
+ environment
+ .getContainerByServiceName("solr")
+ .ifPresent(
+ container -> {
+ container.copyFileToContainer(
+ MountableFile.forHostPath(configsetsPath),
+ "/opt/solr/server/solr/configsets");
+ });
+ }
+
+ protected static void createCollection(String collectionName, int shards, int replicas) {
+ environment
+ .getContainerByServiceName("solr")
+ .ifPresent(
+ container -> {
+ try {
+ // Upload configuration to Zookeeper
+ container.execInContainer(
+ "/opt/solr/bin/solr",
+ "zk",
+ "upconfig",
+ "-n",
+ collectionName,
+ "-d",
+ "/opt/solr/server/solr/configsets/" + collectionName,
+ "-z",
+ "zookeeper:2181");
+
+ // Create the collection
+ container.execInContainer(
+ "/opt/solr/bin/solr",
+ "create",
+ "-c",
+ collectionName,
+ "-n",
+ collectionName,
+ "-sh",
+ String.valueOf(shards),
+ "-rf",
+ String.valueOf(replicas));
+ } catch (Exception e) {
+ LOG.error("Error while creating collection {}", collectionName, e);
+ }
+ });
+ }
+}
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SolrContainerTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/SolrContainerTest.java
similarity index 79%
rename from external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SolrContainerTest.java
rename to external/solr/src/test/java/org/apache/stormcrawler/solr/SolrContainerTest.java
index e7ae8f40..731cd806 100644
--- a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SolrContainerTest.java
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/SolrContainerTest.java
@@ -14,32 +14,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.stormcrawler.solr.persistence;
+package org.apache.stormcrawler.solr;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.testcontainers.containers.Container;
+import java.util.concurrent.TimeUnit;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Timeout;
+import org.testcontainers.containers.Container.ExecResult;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
+@Testcontainers
+@Timeout(value = 120, unit = TimeUnit.SECONDS)
public abstract class SolrContainerTest {
- @Rule public Timeout globalTimeout = Timeout.seconds(120);
-
protected static ExecutorService executorService;
- private final DockerImageName image = DockerImageName.parse("solr:9.8.0");
+ private static final DockerImageName image = DockerImageName.parse("solr:9.8.1");
private static final String configsetsPath = new File("configsets").getAbsolutePath();
- @Rule
- public GenericContainer<?> container =
+ @Container
+ static GenericContainer<?> container =
new GenericContainer<>(image)
.withExposedPorts(8983)
.withCopyFileToContainer(
@@ -48,13 +50,13 @@ public abstract class SolrContainerTest {
.withCommand("solr-foreground -c")
.waitingFor(Wait.forHttp("/solr/admin/cores?action=STATUS").forStatusCode(200));
- @BeforeClass
- public static void beforeClass() {
+ @BeforeAll
+ static void before() {
executorService = Executors.newFixedThreadPool(2);
}
- @AfterClass
- public static void afterClass() {
+ @AfterAll
+ static void after() {
executorService.shutdown();
executorService = null;
}
@@ -63,7 +65,7 @@ public abstract class SolrContainerTest {
return "http://" + container.getHost() + ":" + container.getMappedPort(8983) + "/solr";
}
- protected Container.ExecResult createCollection(String collectionName, int shards)
+ protected ExecResult createCollection(String collectionName, int shards)
throws IOException, InterruptedException {
// Upload configuration to Zookeeper
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/IndexerBoltTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/bolt/IndexerBoltTest.java
similarity index 89%
rename from external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/IndexerBoltTest.java
rename to external/solr/src/test/java/org/apache/stormcrawler/solr/bolt/IndexerBoltTest.java
index 4b5ca490..db3d5415 100644
--- a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/IndexerBoltTest.java
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/bolt/IndexerBoltTest.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.stormcrawler.solr.persistence;
+package org.apache.stormcrawler.solr.bolt;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -38,22 +38,21 @@ import org.apache.stormcrawler.Metadata;
import org.apache.stormcrawler.TestOutputCollector;
import org.apache.stormcrawler.TestUtil;
import org.apache.stormcrawler.indexing.AbstractIndexerBolt;
-import org.apache.stormcrawler.solr.bolt.IndexerBolt;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.stormcrawler.solr.SolrContainerTest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class IndexerBoltTest extends SolrContainerTest {
+class IndexerBoltTest extends SolrContainerTest {
private IndexerBolt bolt;
protected TestOutputCollector output;
private static final Logger LOG = LoggerFactory.getLogger(IndexerBoltTest.class);
- @Before
- public void setup() throws IOException, InterruptedException {
- container.start();
+ @BeforeEach
+ void setup() throws IOException, InterruptedException {
createCollection("docs", 1);
bolt = new IndexerBolt();
@@ -68,10 +67,9 @@ public class IndexerBoltTest extends SolrContainerTest {
bolt.prepare(conf, TestUtil.getMockedTopologyContext(), new OutputCollector(output));
}
- @After
- public void close() {
+ @AfterEach
+ void close() {
LOG.info("Closing Solr container");
- container.close();
output = null;
}
@@ -94,7 +92,7 @@ public class IndexerBoltTest extends SolrContainerTest {
}
@Test
- public void basicTest()
+ void basicTest()
throws SolrServerException,
IOException,
ExecutionException,
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SpoutTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SpoutTest.java
index ce090012..3346e64f 100644
--- a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SpoutTest.java
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/SpoutTest.java
@@ -16,7 +16,8 @@
*/
package org.apache.stormcrawler.solr.persistence;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,16 +36,18 @@ import org.apache.stormcrawler.Metadata;
import org.apache.stormcrawler.TestOutputCollector;
import org.apache.stormcrawler.TestUtil;
import org.apache.stormcrawler.persistence.Status;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.stormcrawler.solr.SolrContainerTest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Verifies that when having 2 Solr shards, documents will be processed by the 2 respective Spouts
*/
-public class SpoutTest extends SolrContainerTest {
+class SpoutTest extends SolrContainerTest {
private StatusUpdaterBolt bolt;
private SolrSpout spoutOne;
@@ -55,9 +58,8 @@ public class SpoutTest extends SolrContainerTest {
private static final Logger LOG = LoggerFactory.getLogger(StatusBoltTest.class);
- @Before
- public void setup() throws IOException, InterruptedException {
- container.start();
+ @BeforeEach
+ void setup() throws IOException, InterruptedException {
createCollection("status", 2);
bolt = new StatusUpdaterBolt();
@@ -83,13 +85,12 @@ public class SpoutTest extends SolrContainerTest {
spoutTwo.open(conf, getContextForTask(1), new SpoutOutputCollector(spoutTwoOutput));
}
- @After
- public void close() {
+ @AfterEach
+ void close() {
LOG.info("Closing updater bolt and SOLR container");
bolt.cleanup();
spoutOne.close();
spoutTwo.close();
- container.close();
boltOutput = null;
spoutOneOutput = null;
spoutTwoOutput = null;
@@ -147,8 +148,9 @@ public class SpoutTest extends SolrContainerTest {
* When using two shards,<br>
* the status documents should be distributed among the two spouts
*/
- @Test(timeout = 120000)
- public void twoShardsTest() throws ExecutionException, InterruptedException, TimeoutException {
+ @Test
+ @Timeout(value = 120, unit = TimeUnit.SECONDS)
+ void twoShardsTest() throws ExecutionException, InterruptedException, TimeoutException {
int expected = 100;
for (int i = 0; i < expected; i++) {
diff --git a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/StatusBoltTest.java b/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/StatusBoltTest.java
index 93148332..f659622b 100644
--- a/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/StatusBoltTest.java
+++ b/external/solr/src/test/java/org/apache/stormcrawler/solr/persistence/StatusBoltTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.stormcrawler.solr.persistence;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -33,21 +33,21 @@ import org.apache.stormcrawler.Metadata;
import org.apache.stormcrawler.TestOutputCollector;
import org.apache.stormcrawler.TestUtil;
import org.apache.stormcrawler.persistence.Status;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.apache.stormcrawler.solr.SolrContainerTest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class StatusBoltTest extends SolrContainerTest {
+class StatusBoltTest extends SolrContainerTest {
private StatusUpdaterBolt bolt;
protected TestOutputCollector output;
private static final Logger LOG = LoggerFactory.getLogger(StatusBoltTest.class);
- @Before
- public void setup() throws IOException, InterruptedException {
- container.start();
+ @BeforeEach
+ void setup() throws IOException, InterruptedException {
createCollection("status", 4);
bolt = new StatusUpdaterBolt();
@@ -61,11 +61,10 @@ public class StatusBoltTest extends SolrContainerTest {
bolt.prepare(conf, TestUtil.getMockedTopologyContext(), new OutputCollector(output));
}
- @After
- public void close() {
+ @AfterEach
+ void close() {
LOG.info("Closing updater bolt and SOLR container");
bolt.cleanup();
- container.close();
output = null;
}
@@ -88,7 +87,7 @@ public class StatusBoltTest extends SolrContainerTest {
}
@Test
- public void basicTest() throws ExecutionException, InterruptedException, TimeoutException {
+ void basicTest() throws ExecutionException, InterruptedException, TimeoutException {
String url = "https://www.url.net/something";
@@ -102,7 +101,7 @@ public class StatusBoltTest extends SolrContainerTest {
}
@Test
- public void errorTest() throws Exception {
+ void errorTest() throws Exception {
String url = "https://www.url.net/something";
diff --git a/external/solr/src/test/resources/docker-compose.yml b/external/solr/src/test/resources/docker-compose.yml
new file mode 100644
index 00000000..ef2e4d9e
--- /dev/null
+++ b/external/solr/src/test/resources/docker-compose.yml
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+version: "3.8"
+
+services:
+ zookeeper:
+ image: zookeeper:3.9
+ hostname: zookeeper
+ ports:
+ - "2181:2181"
+ environment:
+ ZOO_STANDALONE_ENABLED: "true"
+ ZOO_4LW_COMMANDS_WHITELIST: "srvr,mntr,conf,ruok,stat"
+ healthcheck:
+ test: ["CMD", "bash", "-c", "echo ruok | nc localhost 2181 | grep imok"]
+ interval: 10s
+ timeout: 5s
+ retries: 5
+
+ solr:
+ image: solr:9.8.1
+ hostname: solr
+ ports:
+ - "8983:8983"
+ - "8984:8984"
+ depends_on:
+ - zookeeper
+ environment:
+ - SOLR_HOST=localhost
+ command: >
+ bash -c '
+ mkdir -p /var/solr/{8983,8984} &&
+ solr start -c -p 8984 -s /var/solr/8984 -z zookeeper:2181 &&
+ solr start -c -p 8983 -s /var/solr/8983 -z zookeeper:2181 &&
+ tail -f /var/solr/logs/solr.log'