mirror of https://github.com/apache/lucene.git
SOLR-14108: Handle missing verify commands or missing default params in Package Manager
This commit is contained in:
parent
7490bfd828
commit
cbfa781fe3
|
@ -289,27 +289,29 @@ public class PackageManager implements Closeable {
|
|||
public boolean verify(SolrPackageInstance pkg, List<String> collections) {
|
||||
boolean success = true;
|
||||
for (Plugin plugin: pkg.plugins) {
|
||||
for (String collection: collections) {
|
||||
Map<String, String> collectionParameterOverrides = getPackageParams(pkg.name, collection);
|
||||
Command cmd = plugin.verifyCommand;
|
||||
Command cmd = plugin.verifyCommand;
|
||||
if (plugin.verifyCommand != null && !Strings.isNullOrEmpty(cmd.path)) {
|
||||
for (String collection: collections) {
|
||||
Map<String, String> collectionParameterOverrides = getPackageParams(pkg.name, collection);
|
||||
|
||||
Map<String, String> systemParams = Map.of("collection", collection, "package-name", pkg.name, "package-version", pkg.version);
|
||||
String url = solrBaseUrl + PackageUtils.resolve(cmd.path, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
|
||||
PackageUtils.printGreen("Executing " + url + " for collection:" + collection);
|
||||
Map<String, String> systemParams = Map.of("collection", collection, "package-name", pkg.name, "package-version", pkg.version);
|
||||
String url = solrBaseUrl + PackageUtils.resolve(cmd.path, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
|
||||
PackageUtils.printGreen("Executing " + url + " for collection:" + collection);
|
||||
|
||||
if ("GET".equalsIgnoreCase(cmd.method)) {
|
||||
String response = PackageUtils.getJsonStringFromUrl(solrClient.getHttpClient(), url);
|
||||
PackageUtils.printGreen(response);
|
||||
String actualValue = JsonPath.parse(response, PackageUtils.jsonPathConfiguration())
|
||||
.read(PackageUtils.resolve(cmd.condition, pkg.parameterDefaults, collectionParameterOverrides, systemParams));
|
||||
String expectedValue = PackageUtils.resolve(cmd.expected, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
|
||||
PackageUtils.printGreen("Actual: "+actualValue+", expected: "+expectedValue);
|
||||
if (!expectedValue.equals(actualValue)) {
|
||||
PackageUtils.printRed("Failed to deploy plugin: " + plugin.name);
|
||||
success = false;
|
||||
if ("GET".equalsIgnoreCase(cmd.method)) {
|
||||
String response = PackageUtils.getJsonStringFromUrl(solrClient.getHttpClient(), url);
|
||||
PackageUtils.printGreen(response);
|
||||
String actualValue = JsonPath.parse(response, PackageUtils.jsonPathConfiguration())
|
||||
.read(PackageUtils.resolve(cmd.condition, pkg.parameterDefaults, collectionParameterOverrides, systemParams));
|
||||
String expectedValue = PackageUtils.resolve(cmd.expected, pkg.parameterDefaults, collectionParameterOverrides, systemParams);
|
||||
PackageUtils.printGreen("Actual: "+actualValue+", expected: "+expectedValue);
|
||||
if (!expectedValue.equals(actualValue)) {
|
||||
PackageUtils.printRed("Failed to deploy plugin: " + plugin.name);
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Non-GET method not supported for setup commands");
|
||||
}
|
||||
} else {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Non-GET method not supported for setup commands");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,8 +171,10 @@ public class PackageUtils {
|
|||
// TODO: Should perhaps use Matchers etc. instead of this clumsy replaceAll().
|
||||
|
||||
if (str == null) return null;
|
||||
for (String param: defaults.keySet()) {
|
||||
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.containsKey(param)? overrides.get(param): defaults.get(param));
|
||||
if (defaults != null) {
|
||||
for (String param: defaults.keySet()) {
|
||||
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.containsKey(param)? overrides.get(param): defaults.get(param));
|
||||
}
|
||||
}
|
||||
for (String param: overrides.keySet()) {
|
||||
str = str.replaceAll("\\$\\{"+param+"\\}", overrides.get(param));
|
||||
|
|
Loading…
Reference in New Issue