noblepaul commented on a change in pull request #560:
URL: https://github.com/apache/solr/pull/560#discussion_r793301928



##########
File path: solr/core/src/test/org/apache/solr/pkg/TestLocalPackages.java
##########
@@ -0,0 +1,101 @@
+package org.apache.solr.pkg;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.lang.invoke.MethodHandles;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.cloud.MiniSolrCloudCluster;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.util.Utils;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestLocalPackages extends SolrCloudTestCase {
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  public static String localPackagesDir = 
getFile("runtimecode").getAbsolutePath();
+  public static String PKG_NAME = "mypkg";
+  public static String jarName = "mypkg1.jar";
+  public static String COLLECTION_NAME = "testLocalPkgsColl";
+
+  @BeforeClass
+  public static void setup() {
+    System.setProperty("solr.packages.local.whitelist", PKG_NAME);
+    System.setProperty("solr.packages.local.dir", localPackagesDir);
+  }
+
+  @AfterClass
+  public static void shutdown() {
+    System.clearProperty("solr.packages.local.whitelist");
+    System.clearProperty("solr.packages.local.dir");
+  }
+
+  public void testLocalPackages() throws Exception {
+
+    PackageAPI.Packages p = new PackageAPI.Packages();
+    PackageAPI.PkgVersion pkgVersion =  new PackageAPI.PkgVersion();
+    pkgVersion.files = Collections.singletonList(jarName);
+    pkgVersion.version = "0.1";
+    pkgVersion.pkg = PKG_NAME;
+    p.packages.put(PKG_NAME, Collections.singletonList(pkgVersion));
+
+    log.info("local_packages.json: " + Utils.toJSONString(p));
+    log.info("Local packages dir: " + localPackagesDir);
+
+    MiniSolrCloudCluster cluster =
+            configureCluster(4)
+                    .withJettyConfig(builder -> builder.enableV2(true))
+                    .withJettyConfig(it -> it.withPreStartupHook(jsr -> {

Review comment:
       > I'm curious; why is this needed vs simply calling this code before 
cluster is instantiated?
   
   We need this code to be executed after the `JettySolrRunner` is created but 
before the jetty is started because the paths are only available at that point.
   
   > I think it's better style to put all this code into a method and simply 
call it rather than have a long lambda.
   
   👍
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to