Skip to content

Commit

Permalink
[backport 2.x] Gradle update (#479) (#480)
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
Co-authored-by: Petar Dzepina <petar.dzepina@gmail.com>
  • Loading branch information
opensearch-trigger-bot[bot] and petardz authored Jul 11, 2023
1 parent 95c1b6e commit ed85e72
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 67 deletions.
4 changes: 2 additions & 2 deletions build-tools/opensearchplugin-coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jacocoTestReport {
getSourceDirectories().from(sourceSets.main.allSource)
getClassDirectories().from(sourceSets.main.output)
reports {
html.enabled = true // human readable
xml.enabled = true // for coverlay
html.required = true // human readable
xml.required = true // for coverlay
}
}

Expand Down
21 changes: 8 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ buildscript {
}

plugins {
id 'nebula.ospackage' version "8.3.0"
id "com.netflix.nebula.ospackage" version "11.3.0"
id 'java-library'
}

Expand Down Expand Up @@ -159,7 +159,7 @@ dependencies {
}

// RPM & Debian build
apply plugin: 'nebula.ospackage'
apply plugin: 'com.netflix.nebula.ospackage'

def es_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile
es_tmp_dir.mkdirs()
Expand Down Expand Up @@ -321,7 +321,7 @@ afterEvaluate {
ospackage {
packageName = "${name}"
release = isSnapshot ? "0.1" : '1'
version = "${project.version}"
version = "${project.version}" - "-SNAPSHOT"

into '/usr/share/opensearch/plugins'
from(zipTree(bundlePlugin.archivePath)) {
Expand Down Expand Up @@ -354,23 +354,18 @@ afterEvaluate {
finalizedBy 'renameRpm'
task renameRpm(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.rpm"
doLast { delete file("$buildDir/distributions/$archiveName") }
rename "$archiveFileName", "${packageName}-${archiveVersion}.rpm"
doLast { delete file("$buildDir/distributions/$archiveFileName") }
}
}

buildDeb {
arch = 'all'
dependsOn 'assemble'
finalizedBy 'renameDeb'
task renameDeb(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.deb"
doLast { delete file("$buildDir/distributions/$archiveName") }
rename "$archiveFileName", "${packageName}-${archiveVersion}.deb"
doLast { delete file("$buildDir/distributions/$archiveFileName") }
}
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 6 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -144,15 +141,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -135,7 +135,7 @@ public static CreateIndexMappingsRequest parse(XContentParser xcp) throws IOExce
aliasMap.put(alias, Map.of("type", "alias", "path", path));
}
}
aliasMappings = Strings.toString(XContentFactory.jsonBuilder().map(Map.of("properties", aliasMap)));
aliasMappings = org.opensearch.common.Strings.toString(XContentFactory.jsonBuilder().map(Map.of("properties", aliasMap)));
break;
case PARTIAL_FIELD:
partial = xcp.booleanValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import org.opensearch.Version;
import org.opensearch.action.ActionResponse;
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.ParseField;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.mapper.MapperService;
Expand Down Expand Up @@ -106,12 +104,7 @@ public Map<String, MappingMetadata> getMappings() {

@Override
public String toString() {
try {
return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS));
} catch (IOException e) {
logger.error(e.getMessage());
return "";
}
return org.opensearch.common.Strings.toString(XContentType.JSON, this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.securityanalytics.mapper.MapperUtils;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;

Expand All @@ -21,6 +18,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.opensearch.common.xcontent.XContentType;

public class GetMappingsViewResponse extends ActionResponse implements ToXContentObject {

Expand Down Expand Up @@ -131,12 +129,7 @@ public List<String> getUnmappedIndexFields() {

@Override
public String toString() {
try {
return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS));
} catch (IOException e) {
logger.error(e.getMessage());
return "";
}
return org.opensearch.common.Strings.toString(XContentType.JSON, this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionResponse;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;

Expand Down Expand Up @@ -71,12 +69,7 @@ public List<String> getNonapplicableFields() {

@Override
public String toString() {
try {
return Strings.toString(this.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS));
} catch (IOException e) {
logger.error(e.getMessage());
return "";
}
return org.opensearch.common.Strings.toString(XContentType.JSON, this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.lucene.search.Query;
import org.opensearch.common.ParsingException;
import org.opensearch.core.common.Strings;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.ParseField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ private void doCreateMapping(
indicesClient.putMapping(request, new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse acknowledgedResponse) {
//((Map<String, Object>)mappingsRoot.get(PROPERTIES)).putAll(presentPathsMappings);
CreateMappingResult result = new CreateMappingResult(
acknowledgedResponse,
indexName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchException;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.common.Strings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.rest.RestStatus;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.opensearch.client.WarningsHandler;
import org.opensearch.cluster.ClusterModule;
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.UUIDs;

import org.opensearch.common.io.PathUtils;
Expand Down Expand Up @@ -202,7 +202,7 @@ protected String createTestIndex(String index, String mapping, Settings settings

protected String createTestIndex(RestClient client, String index, String mapping, Settings settings) throws IOException {
Request request = new Request("PUT", "/" + index);
String entity = "{\"settings\": " + settings.toString();
String entity = "{\"settings\": " + org.opensearch.common.Strings.toString(XContentType.JSON, settings);
if (mapping != null) {
entity = entity + ",\"mappings\" : {" + mapping + "}";
}
Expand Down Expand Up @@ -251,7 +251,7 @@ protected Settings getCorrelationDefaultIndexSettings() {

protected String createTestIndexWithMappingJson(RestClient client, String index, String mapping, Settings settings) throws IOException {
Request request = new Request("PUT", "/" + index);
String entity = "{\"settings\": " + Strings.toString(XContentType.JSON, settings);
String entity = "{\"settings\": " + org.opensearch.common.Strings.toString(XContentType.JSON, settings);
if (mapping != null) {
entity = entity + ",\"mappings\" : " + mapping;
}
Expand All @@ -275,7 +275,7 @@ protected void addCorrelationDoc(String index, String docId, List<String> fieldN
}
builder.endObject();

request.setJsonEntity(Strings.toString(builder));
request.setJsonEntity(org.opensearch.common.Strings.toString(builder));
Response response = client().performRequest(request);
assertEquals(request.getEndpoint() + ": failed", RestStatus.CREATED, RestStatus.fromCode(response.getStatusLine().getStatusCode()));
}
Expand All @@ -296,7 +296,7 @@ protected Response searchCorrelationIndex(String index, CorrelationQueryBuilder
request.addParameter("size", Integer.toString(resultSize));
request.addParameter("explain", Boolean.toString(true));
request.addParameter("search_type", "query_then_fetch");
request.setJsonEntity(Strings.toString(builder));
request.setJsonEntity(org.opensearch.common.Strings.toString(builder));

Response response = client().performRequest(request);
Assert.assertEquals("Search failed", RestStatus.OK, restStatus(response));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.apache.lucene.index.VectorSimilarityFunction;
import org.junit.Assert;
import org.opensearch.client.Response;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.securityanalytics.SecurityAnalyticsRestTestCase;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testQuery() throws IOException {
.endObject()
.endObject();

String mapping = Strings.toString(builder);
String mapping = org.opensearch.common.Strings.toString(builder);
createTestIndexWithMappingJson(client(), INDEX_NAME, mapping, getCorrelationDefaultIndexSettings());

for (int idx = 0; idx < TEST_VECTORS.length; ++idx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testGetFindings_success() {
"test_index1",
List.of(new DocLevelQuery("1","myQuery","fieldA:valABC", List.of())),
Instant.now(),
null
"1234"
);
FindingDocument findingDocument1 = new FindingDocument("test_index1", "doc1", true, "document 1 payload");
FindingDocument findingDocument2 = new FindingDocument("test_index1", "doc2", true, "document 2 payload");
Expand All @@ -101,7 +101,7 @@ public void testGetFindings_success() {
"test_index2",
List.of(new DocLevelQuery("1","myQuery","fieldA:valABC", List.of())),
Instant.now(),
null
"1234"
);
FindingDocument findingDocument21 = new FindingDocument("test_index2", "doc21", true, "document 21 payload");
FindingDocument findingDocument22 = new FindingDocument("test_index2", "doc22", true, "document 22 payload");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.json.JsonXContent;
Expand Down Expand Up @@ -1415,7 +1415,7 @@ public void testCreateDNSMapping() throws IOException{
String path = ((Map<String, Object>) entry.getValue()).get("path").toString();
try {
Request updateRequest = new Request("PUT", SecurityAnalyticsPlugin.MAPPER_BASE_URI);
updateRequest.setJsonEntity(Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
updateRequest.setJsonEntity(org.opensearch.common.Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
"index_name", INDEX_NAME,
"field", path,
"alias", key))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.opensearch.action.search.SearchResponse;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.common.Strings;
import org.opensearch.core.common.Strings;
import org.opensearch.common.settings.Settings;
import org.opensearch.client.ResponseException;
import org.opensearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -872,7 +872,7 @@ public void testCreatingADetectorWithTimestampFieldAliasMapping() throws IOExcep
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());

Request updateRequest = new Request("PUT", SecurityAnalyticsPlugin.MAPPER_BASE_URI);
updateRequest.setJsonEntity(Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
updateRequest.setJsonEntity(org.opensearch.common.Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
"index_name", index,
"field", "time",
"alias", "timestamp"))));
Expand Down Expand Up @@ -975,7 +975,7 @@ public void testCreatingADetectorWithTimestampFieldAliasMapping_verifyTimeRangeI
assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());

Request updateRequest = new Request("PUT", SecurityAnalyticsPlugin.MAPPER_BASE_URI);
updateRequest.setJsonEntity(Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
updateRequest.setJsonEntity(org.opensearch.common.Strings.toString(XContentFactory.jsonBuilder().map(Map.of(
"index_name", index,
"field", "time",
"alias", "timestamp"))));
Expand Down

0 comments on commit ed85e72

Please sign in to comment.