Skip to content

Apache Lucene open-source search software

tests: allow custom schema in ZK and copy to canonical schema name

Yonik Seeley2111cfecd843
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
index 1ad7568dd1a..7f62c9aad7f 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractDistribZkTestBase.java
@@ -64,8 +64,9 @@ public abstract class AbstractDistribZkTestBase extends BaseDistributedSearchTes
System.setProperty("enable.update.log", "true");
System.setProperty("remove.version.field", "true");
-
- AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer.getZkAddress(), "solrconfig.xml", "schema.xml");
+ String schema = getSchemaFile();
+ if (schema == null) schema = "schema.xml";
+ AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer.getZkAddress(), "solrconfig.xml", schema);
// set some system properties for use by tests
System.setProperty("solr.test.sys.prop1", "propone");
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
index 44b1b2aa233..9a3f00a4e95 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
@@ -102,9 +102,10 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {
zkClient.makePath("/collections/control_collection", ZkStateReader.toJSON(zkProps), CreateMode.PERSISTENT, true);
zkClient.makePath("/collections/control_collection/shards", CreateMode.PERSISTENT, true);
- putConfig(zkClient, solrhome, config);
- putConfig(zkClient, solrhome, schema);
- putConfig(zkClient, solrhome, "solrconfig.xml");
+ // for now, always upload the config and schema to the canonical names
+ putConfig(zkClient, solrhome, config, "solrconfig.xml");
+ putConfig(zkClient, solrhome, schema, "schema.xml");
+
putConfig(zkClient, solrhome, "stopwords.txt");
putConfig(zkClient, solrhome, "protwords.txt");
putConfig(zkClient, solrhome, "currency.xml");
@@ -118,16 +119,21 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {
private static void putConfig(SolrZkClient zkClient, File solrhome, final String name)
throws Exception {
- String path = "/configs/conf1/" + name;
+ putConfig(zkClient, solrhome, name, name);
+ }
+
+ private static void putConfig(SolrZkClient zkClient, File solrhome, final String srcName, String destName)
+ throws Exception {
File file = new File(solrhome, "collection1"
- + File.separator + "conf" + File.separator + name);
+ + File.separator + "conf" + File.separator + srcName);
if (!file.exists()) {
log.info("skipping " + file.getAbsolutePath() + " because it doesn't exist");
return;
}
-
- log.info("put " + file.getAbsolutePath() + " to " + path);
- zkClient.makePath(path, file, false, true);
+
+ String destPath = "/configs/conf1/" + destName;
+ log.info("put " + file.getAbsolutePath() + " to " + destPath);
+ zkClient.makePath(destPath, file, false, true);
}
@Override