This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 67bb1c649fd Tests: Add test for using non-default filesystem with 
EmbeddedSolrServer (#3146)
67bb1c649fd is described below

commit 67bb1c649fd3ff633784cbba0c1ad89fa75e98dd
Author: Andrey Bozhko <[email protected]>
AuthorDate: Fri Jun 13 13:16:53 2025 -0500

    Tests: Add test for using non-default filesystem with EmbeddedSolrServer 
(#3146)
    
    
    
    Co-authored-by: Andrey Bozhko <[email protected]>
---
 .../solr/configsets/zipfs/conf/schema.xml          | 32 ++++++++++++
 .../solr/configsets/zipfs/conf/solrconfig.xml      | 54 ++++++++++++++++++++
 .../TestEmbeddedSolrServerConstructors.java        | 58 ++++++++++++++++++++++
 3 files changed, 144 insertions(+)

diff --git a/solr/core/src/test-files/solr/configsets/zipfs/conf/schema.xml 
b/solr/core/src/test-files/solr/configsets/zipfs/conf/schema.xml
new file mode 100644
index 00000000000..61c720ee612
--- /dev/null
+++ b/solr/core/src/test-files/solr/configsets/zipfs/conf/schema.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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
+
+     https://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.
+-->
+
+<schema name="default-config" version="1.7">
+    <uniqueKey>id</uniqueKey>
+
+    <field name="id" type="string" indexed="true" stored="true" 
required="true" multiValued="false" />
+    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
+
+    <field name="_version_" type="plong" indexed="false" stored="false"/>
+    <fieldType name="plong" class="solr.LongPointField"/>
+
+    <fieldType name="booleans" class="solr.BoolField" sortMissingLast="true" 
multiValued="true"/>
+    <dynamicField name="*_bs" type="booleans" indexed="true" stored="true"/>
+
+    <fieldType name="text_general" class="solr.TextField" 
positionIncrementGap="100" multiValued="true" />
+</schema>
diff --git a/solr/core/src/test-files/solr/configsets/zipfs/conf/solrconfig.xml 
b/solr/core/src/test-files/solr/configsets/zipfs/conf/solrconfig.xml
new file mode 100644
index 00000000000..1beded14516
--- /dev/null
+++ b/solr/core/src/test-files/solr/configsets/zipfs/conf/solrconfig.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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
+
+     https://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.
+-->
+
+<config>
+  <luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
+
+  <dataDir>${solr.data.dir:}</dataDir>
+
+  <directoryFactory class="solr.RAMDirectoryFactory"/>
+  <indexConfig>
+    <lockType>single</lockType>
+  </indexConfig>
+
+  <schemaFactory class="ClassicIndexSchemaFactory"/>
+
+  <codecFactory class="solr.SchemaCodecFactory"/>
+
+  <!-- The default high-performance update handler -->
+  <updateHandler class="solr.DirectUpdateHandler2">
+    <updateLog enable="false"/>
+  </updateHandler>
+
+  <!-- Primary search handler, expected by most clients, examples and UI 
frameworks -->
+  <requestHandler name="/select" class="solr.SearchHandler">
+    <lst name="defaults">
+      <str name="echoParams">explicit</str>
+      <int name="rows">10</int>
+    </lst>
+  </requestHandler>
+
+  <restManager>
+    <!--
+    IMPORTANT: Due to the Lucene SecurityManager, tests can only write to 
their runtime directory or below.
+    But it's easier to just keep everything in memory for testing so no 
remnants are left behind.
+    -->
+    <str 
name="storageIO">org.apache.solr.rest.ManagedResourceStorage$InMemoryStorageIO</str>
+  </restManager>
+
+</config>
diff --git 
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
 
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
index ec6d688fe17..e6a87783a7f 100644
--- 
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
+++ 
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
@@ -17,7 +17,12 @@
 package org.apache.solr.client.solrj.embedded;
 
 import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.file.PathUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -58,4 +63,57 @@ public class TestEmbeddedSolrServerConstructors extends 
SolrTestCaseJ4 {
       assertEquals(1, server.query("newcore", new 
SolrQuery("*:*")).getResults().getNumFound());
     }
   }
+
+  @Test
+  public void testPathConstructorZipFS() throws Exception {
+    Path archive = createTempFile("configset", ".zip");
+    Files.delete(archive);
+
+    // When :
+    // Prepare a zip archive which contains
+    // the configset files as shown below:
+    //
+    // configset.zip
+    // └── 1
+    //     └── 2
+    //         └── 3
+    //             └── 4
+    //                 ├── data
+    //                 │   └── core1
+    //                 │       ├── conf
+    //                 │       │   ├── schema.xml
+    //                 │       │   └── solrconfig.xml
+    //                 │       └── core.properties
+    //                 └── solr.xml
+    //
+    // Note :
+    // We don't want Solr to attempt to modify
+    // the archive when we point solrHome to
+    // the archive content. That's why we:
+    // - use RAMDirectoryFactory,
+    // - disable the update log.
+
+    var zipFs = FileSystems.newFileSystem(archive, Map.of("create", "true"));
+    try (zipFs) {
+      var destDir = zipFs.getPath("1", "2", "3", "4");
+      var confDir = destDir.resolve("data/core1/conf");
+      Files.createDirectories(confDir);
+
+      Files.createFile(confDir.resolveSibling("core.properties"));
+      Files.copy(TEST_PATH().resolve("solr.xml"), destDir.resolve("solr.xml"));
+
+      PathUtils.copyDirectory(configset("zipfs"), confDir);
+    }
+
+    // Then :
+    // EmbeddedSolrServer successfully loads the core
+    // using the configset directly from the archive
+    var configSetFs = FileSystems.newFileSystem(archive);
+    try (configSetFs) {
+      var server = new EmbeddedSolrServer(configSetFs.getPath("/1/2/3/4"), 
null);
+      try (server) {
+        assertEquals(List.of("core1"), 
server.getCoreContainer().getAllCoreNames());
+      }
+    }
+  }
 }

Reply via email to