"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "solr/core/src/test/org/apache/solr/pkg/TestPackages.java" between
solr-8.4.0-src.tgz and solr-8.4.1-src.tgz

About: Solr is the search platform from the Apache Lucene project. Its major features include full-text search, hit highlighting, faceted search, caching, replication, and a web admin interface.

TestPackages.java  (solr-8.4.0-src.tgz):TestPackages.java  (solr-8.4.1-src.tgz)
skipping to change at line 53 skipping to change at line 53
import org.apache.solr.cloud.ConfigRequest; import org.apache.solr.cloud.ConfigRequest;
import org.apache.solr.cloud.MiniSolrCloudCluster; import org.apache.solr.cloud.MiniSolrCloudCluster;
import org.apache.solr.cloud.SolrCloudTestCase; import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.common.MapWriterMap; import org.apache.solr.common.MapWriterMap;
import org.apache.solr.common.NavigableObject; import org.apache.solr.common.NavigableObject;
import org.apache.solr.common.SolrInputDocument; import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.Utils; import org.apache.solr.common.util.Utils;
import org.apache.solr.filestore.PackageStoreAPI;
import org.apache.solr.filestore.TestDistribPackageStore; import org.apache.solr.filestore.TestDistribPackageStore;
import org.apache.solr.util.LogLevel; import org.apache.solr.util.LogLevel;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.data.Stat; import org.apache.zookeeper.data.Stat;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.apache.solr.common.cloud.ZkStateReader.SOLR_PKGS_PATH; import static org.apache.solr.common.cloud.ZkStateReader.SOLR_PKGS_PATH;
import static org.apache.solr.common.params.CommonParams.JAVABIN; import static org.apache.solr.common.params.CommonParams.JAVABIN;
import static org.apache.solr.common.params.CommonParams.WT; import static org.apache.solr.common.params.CommonParams.WT;
import static org.apache.solr.core.TestDynamicLoading.getFileContent; import static org.apache.solr.core.TestDynamicLoading.getFileContent;
import static org.apache.solr.filestore.TestDistribPackageStore.readFile; import static org.apache.solr.filestore.TestDistribPackageStore.readFile;
import static org.apache.solr.filestore.TestDistribPackageStore.uploadKey;
import static org.apache.solr.filestore.TestDistribPackageStore.waitForAllNodesH aveFile; import static org.apache.solr.filestore.TestDistribPackageStore.waitForAllNodesH aveFile;
@LogLevel("org.apache.solr.pkg.PackageLoader=DEBUG;org.apache.solr.pkg.PackageAP I=DEBUG") @LogLevel("org.apache.solr.pkg.PackageLoader=DEBUG;org.apache.solr.pkg.PackageAP I=DEBUG")
//@org.apache.lucene.util.LuceneTestCase.AwaitsFix(bugUrl="https://issues.apache .org/jira/browse/SOLR-13822") // leaks files //@org.apache.lucene.util.LuceneTestCase.AwaitsFix(bugUrl="https://issues.apache .org/jira/browse/SOLR-13822") // leaks files
public class TestPackages extends SolrCloudTestCase { public class TestPackages extends SolrCloudTestCase {
@Before @Before
public void setup() { public void setup() {
System.setProperty("enable.packages", "true"); System.setProperty("enable.packages", "true");
} }
skipping to change at line 97 skipping to change at line 98
.addConfig("conf", configset("cloud-minimal")) .addConfig("conf", configset("cloud-minimal"))
.configure(); .configure();
try { try {
String FILE1 = "/mypkg/runtimelibs.jar"; String FILE1 = "/mypkg/runtimelibs.jar";
String FILE2 = "/mypkg/runtimelibs_v2.jar"; String FILE2 = "/mypkg/runtimelibs_v2.jar";
String FILE3 = "/mypkg/runtimelibs_v3.jar"; String FILE3 = "/mypkg/runtimelibs_v3.jar";
String URP1 = "/mypkg/testurpv1.jar"; String URP1 = "/mypkg/testurpv1.jar";
String URP2 = "/mypkg/testurpv2.jar"; String URP2 = "/mypkg/testurpv2.jar";
String COLLECTION_NAME = "testPluginLoadingColl"; String COLLECTION_NAME = "testPluginLoadingColl";
byte[] derFile = readFile("cryptokeys/pub_key512.der"); byte[] derFile = readFile("cryptokeys/pub_key512.der");
cluster.getZkClient().makePath("/keys/exe", true); uploadKey(derFile, PackageStoreAPI.KEYS_DIR+"/pub_key512.der", cluster);
cluster.getZkClient().create("/keys/exe/pub_key512.der", derFile, CreateMo // cluster.getZkClient().makePath("/keys/exe", true);
de.PERSISTENT, true); // cluster.getZkClient().create("/keys/exe/pub_key512.der", derFile, Create
Mode.PERSISTENT, true);
postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE1, postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE1,
"L3q/qIGs4NaF6JiO0ZkMUFa88j0OmYc+I6O7BOdNuMct/xoZ4h73aZHZGc0+nmI1f/U3b OlMPINlSOM6LK3JpQ=="); "L3q/qIGs4NaF6JiO0ZkMUFa88j0OmYc+I6O7BOdNuMct/xoZ4h73aZHZGc0+nmI1f/U3b OlMPINlSOM6LK3JpQ==");
postFileAndWait(cluster, "runtimecode/testurp_v1.jar.bin", URP1, postFileAndWait(cluster, "runtimecode/testurp_v1.jar.bin", URP1,
"h6UmMzuPqu4hQFGLBMJh/6kDSEXpJlgLsQDXx0KuxXWkV5giilRP57K3towiJRh2J+rqi hqIghNCi3YgzgUnWQ=="); "h6UmMzuPqu4hQFGLBMJh/6kDSEXpJlgLsQDXx0KuxXWkV5giilRP57K3towiJRh2J+rqi hqIghNCi3YgzgUnWQ==");
Package.AddVersion add = new Package.AddVersion(); Package.AddVersion add = new Package.AddVersion();
add.version = "1.0"; add.version = "1.0";
add.pkg = "mypkg"; add.pkg = "mypkg";
add.files = Arrays.asList(new String[]{FILE1, URP1}); add.files = Arrays.asList(new String[]{FILE1, URP1});
skipping to change at line 423 skipping to change at line 425
add.version = "0.12"; add.version = "0.12";
add.pkg = "test_pkg"; add.pkg = "test_pkg";
add.files = Arrays.asList(new String[]{FILE1, FILE2}); add.files = Arrays.asList(new String[]{FILE1, FILE2});
V2Request req = new V2Request.Builder("/cluster/package") V2Request req = new V2Request.Builder("/cluster/package")
.forceV2(true) .forceV2(true)
.withMethod(SolrRequest.METHOD.POST) .withMethod(SolrRequest.METHOD.POST)
.withPayload(Collections.singletonMap("add", add)) .withPayload(Collections.singletonMap("add", add))
.build(); .build();
//the files is not yet there. The command should fail with error saying "N o such file" //the files is not yet there. The command should fail with error saying "N o such file"
expectError(req, cluster.getSolrClient(), errPath, "No such file :"); expectError(req, cluster.getSolrClient(), errPath, "No such file:");
//post the jar file. No signature is sent //post the jar file. No signature is sent
postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE1, null); postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE1, null);
add.files = Arrays.asList(new String[]{FILE1}); add.files = Arrays.asList(new String[]{FILE1});
expectError(req, cluster.getSolrClient(), errPath, expectError(req, cluster.getSolrClient(), errPath,
FILE1 + " has no signature"); FILE1 + " has no signature");
//now we upload the keys //now we upload the keys
byte[] derFile = readFile("cryptokeys/pub_key512.der"); byte[] derFile = readFile("cryptokeys/pub_key512.der");
cluster.getZkClient().makePath("/keys/exe", true); uploadKey(derFile, PackageStoreAPI.KEYS_DIR+"/pub_key512.der", cluster);
cluster.getZkClient().create("/keys/exe/pub_key512.der", derFile, CreateMo
de.PERSISTENT, true);
//and upload the same file with a different name but it has proper signatu re //and upload the same file with a different name but it has proper signatu re
postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE2, postFileAndWait(cluster, "runtimecode/runtimelibs.jar.bin", FILE2,
"L3q/qIGs4NaF6JiO0ZkMUFa88j0OmYc+I6O7BOdNuMct/xoZ4h73aZHZGc0+nmI1f/U3b OlMPINlSOM6LK3JpQ=="); "L3q/qIGs4NaF6JiO0ZkMUFa88j0OmYc+I6O7BOdNuMct/xoZ4h73aZHZGc0+nmI1f/U3b OlMPINlSOM6LK3JpQ==");
// with correct signature // with correct signature
//after uploading the file, let's delete the keys to see if we get proper error message //after uploading the file, let's delete the keys to see if we get proper error message
cluster.getZkClient().delete("/keys/exe/pub_key512.der", -1, true); // cluster.getZkClient().delete("/keys/exe/pub_key512.der", -1, true);
add.files = Arrays.asList(new String[]{FILE2}); add.files = Arrays.asList(new String[]{FILE2});
expectError(req, cluster.getSolrClient(), errPath, /*expectError(req, cluster.getSolrClient(), errPath,
"ZooKeeper does not have any public keys"); "ZooKeeper does not have any public keys");*/
//Now lets' put the keys back //Now lets' put the keys back
cluster.getZkClient().create("/keys/exe/pub_key512.der", derFile, CreateMo de.PERSISTENT, true); // cluster.getZkClient().create("/keys/exe/pub_key512.der", derFile, Create Mode.PERSISTENT, true);
//this time we have a file with proper signature, public keys are in ZK //this time we have a file with proper signature, public keys are in ZK
// so the add {} command should succeed // so the add {} command should succeed
req.process(cluster.getSolrClient()); req.process(cluster.getSolrClient());
//Now verify the data in ZK //Now verify the data in ZK
TestDistribPackageStore.assertResponseValues(1, TestDistribPackageStore.assertResponseValues(1,
() -> new MapWriterMap((Map) Utils.fromJSON(cluster.getZkClient().getD ata(SOLR_PKGS_PATH, () -> new MapWriterMap((Map) Utils.fromJSON(cluster.getZkClient().getD ata(SOLR_PKGS_PATH,
null, new Stat(), true))), null, new Stat(), true))),
Utils.makeMap( Utils.makeMap(
 End of changes. 9 change blocks. 
12 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)