Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15299, SOLR-15224: Remove inaccessible test sources hack.

Dawid Weiss44986496213c
diff --git a/build.gradle b/build.gradle
index 86938da7d17..2d848878e5b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -182,8 +182,6 @@ apply from: file('gradle/hacks/gradle.gradle')
apply from: file('gradle/hacks/hashmapAssertions.gradle')
apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')
-apply from: file('gradle/solr-tlp-migration/inaccessible-test-sources.gradle')
-
apply from: file('gradle/solr/packaging.gradle')
apply from: file('gradle/solr/solr-forbidden-apis.gradle')
diff --git a/gradle/solr-tlp-migration/inaccessible-test-sources.gradle b/gradle/solr-tlp-migration/inaccessible-test-sources.gradle
deleted file mode 100644
index 02aad3bfa1f..00000000000
--- a/gradle/solr-tlp-migration/inaccessible-test-sources.gradle
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-// Source test classes from Lucene won't be accessible anymore after the split.
-
-configure(project(":solr:core")) {
- afterEvaluate {
- sourceSets {
- test {
- java {
- exclude '**/TestLuceneIndexBackCompat.java'
- exclude '**/TestXmlQParser.java'
- exclude '**/TestCodecSupport.java'
- }
- }
- }
- }
-
- // disable for now because individual file excludes cannot be applied to ecj.
- tasks.matching { it.name == "ecjLintTest" }.all { task ->
- task.enabled = false
- }
-}
diff --git a/solr/core/src/test/org/apache/solr/backcompat/TestLuceneIndexBackCompat.java.ignored b/solr/core/src/test/org/apache/solr/backcompat/TestLuceneIndexBackCompat.java.ignored
new file mode 100644
index 00000000000..9ef5113896f
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/backcompat/TestLuceneIndexBackCompat.java.ignored
@@ -0,0 +1,128 @@
+/*
+ * 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.solr.backcompat;
+
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.lucene.backward_index.TestBackwardsCompatibility;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.util.TestHarness;
+import org.junit.Test;
+
+/** Verify we can read/write previous versions' Lucene indexes. */
[email protected](bugUrl = "SOLR-15224: Missing Lucene back-compat index files")
+public class TestLuceneIndexBackCompat extends SolrTestCaseJ4 {
+ private static final String[] oldNames = {
+ "8.0.0-cfs",
+ "8.0.0-nocfs",
+ "8.1.0-cfs",
+ "8.1.0-nocfs",
+ "8.1.1-cfs",
+ "8.1.1-nocfs",
+ "8.2.0-cfs",
+ "8.2.0-nocfs",
+ "8.3.0-cfs",
+ "8.3.0-nocfs",
+ "8.3.1-cfs",
+ "8.3.1-nocfs",
+ "8.4.0-cfs",
+ "8.4.0-nocfs",
+ "8.4.1-cfs",
+ "8.4.1-nocfs",
+ "8.5.0-cfs",
+ "8.5.0-nocfs",
+ "8.5.1-cfs",
+ "8.5.1-nocfs",
+ "8.5.2-cfs",
+ "8.5.2-nocfs",
+ "8.6.0-cfs",
+ "8.6.0-nocfs",
+ "8.6.1-cfs",
+ "8.6.1-nocfs",
+ "8.6.2-cfs",
+ "8.6.2-nocfs",
+ "8.6.3-cfs",
+ "8.6.3-nocfs",
+ "8.7.0-cfs",
+ "8.7.0-nocfs",
+ "8.8.0-cfs",
+ "8.8.0-nocfs",
+ "8.8.1-cfs",
+ "8.8.1-nocfs"
+ };
+
+ @Test
+ public void testOldIndexes() throws Exception {
+ for (String name : oldNames) {
+ setupCore(name);
+
+ assertQ(req("q", "*:*", "rows", "0"), "//result[@numFound='35']");
+
+ assertU(adoc("id", "id_123456789"));
+ assertU(commit());
+
+ deleteCore();
+ }
+ }
+
+ private void setupCore(String coreName) throws Exception {
+ if (h != null) {
+ h.close();
+ }
+ Path solrHome = createTempDir(coreName).toAbsolutePath();
+ Files.createDirectories(solrHome);
+ Path coreDir = solrHome.resolve(coreName);
+ Path confDir = coreDir.resolve("conf");
+ Files.createDirectories(confDir);
+ Path dataDir = coreDir.resolve("data");
+ Path indexDir = dataDir.resolve("index");
+ Files.createDirectories(indexDir);
+
+ Files.copy(getFile("solr/solr.xml").toPath(), solrHome.resolve("solr.xml"));
+ FileUtils.copyDirectory(configset("backcompat").toFile(), confDir.toFile());
+
+ try (Writer writer = new OutputStreamWriter(Files.newOutputStream(coreDir.resolve("core.properties")), StandardCharsets.UTF_8)) {
+ Properties coreProps = new Properties();
+ coreProps.put("name", coreName);
+ coreProps.store(writer, null);
+ }
+
+ InputStream resource = TestBackwardsCompatibility.class.getResourceAsStream("index." + coreName + ".zip");
+ assertNotNull("Index name " + coreName + " not found", resource);
+ TestUtil.unzip(resource, indexDir);
+
+ configString = "solrconfig.xml";
+ schemaString = "schema.xml";
+ testSolrHome = solrHome;
+ System.setProperty("solr.solr.home", solrHome.toString());
+ ignoreException("ignore_exception");
+ solrConfig = TestHarness.createConfig(testSolrHome, coreName, getSolrConfigFile());
+ h = new TestHarness(coreName, dataDir.toString(), solrConfig, getSchemaFile());
+ lrf = h.getRequestFactory("",0,20, CommonParams.VERSION,"2.2");
+ }
+}