Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public class AllocationBenchmark {
public int clusterConcurrentRecoveries;

private AllocationService initialClusterStrategy;
private AllocationService clusterExcludeStrategy;
private AllocationService clusterZoneAwareExcludeStrategy;
private ClusterState initialClusterState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public void setUp() throws Exception {
final String[] params = indicesNodes.split("\\|");
numIndices = toInt(params[0]);
numNodes = toInt(params[1]);

int totalShardCount = (numReplicas + 1) * numShards * numIndices;
Metadata.Builder mb = Metadata.builder();
for (int i = 1; i <= numIndices; i++) {
mb.put(
Expand Down
55 changes: 39 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,55 +28,78 @@
* under the License.
*/

import java.nio.charset.StandardCharsets;
import java.io.ByteArrayOutputStream;

import com.avast.gradle.dockercompose.tasks.ComposePull
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.opensearch.gradle.BuildPlugin
import org.opensearch.gradle.CheckCompatibilityTask
import org.opensearch.gradle.Version
import org.opensearch.gradle.VersionProperties
import org.opensearch.gradle.info.BuildParams
import org.opensearch.gradle.plugin.PluginBuildPlugin
import org.opensearch.gradle.tar.SymbolicLinkPreservingTar
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.EclipseJdt
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.gradle.api.Project;
import org.gradle.process.ExecResult;
import org.opensearch.gradle.CheckCompatibilityTask

import java.nio.charset.StandardCharsets

import static org.opensearch.gradle.util.GradleUtils.maybeConfigure

plugins {
id "test-report-aggregation"
id 'jacoco-report-aggregation'
id 'lifecycle-base'
id 'opensearch.docker-support'
id 'opensearch.global-build-info'
id "com.diffplug.spotless" version "6.25.0" apply false
id "com.diffplug.spotless" version "7.1.0" apply false
id "org.gradle.test-retry" version "1.6.2" apply false
id "test-report-aggregation"
id 'jacoco-report-aggregation'
id "org.openrewrite.rewrite" version "7.11.0" apply false
}

apply from: 'gradle/build-complete.gradle'
apply from: 'gradle/runtime-jdk-provision.gradle'
apply from: 'gradle/ide.gradle'
apply from: 'gradle/code-convention.gradle'
apply from: 'gradle/code-coverage.gradle'
apply from: 'gradle/forbidden-dependencies.gradle'
apply from: 'gradle/formatting.gradle'
apply from: 'gradle/ide.gradle'
apply from: 'gradle/local-distribution.gradle'
apply from: 'gradle/run.gradle'
apply from: 'gradle/missing-javadoc.gradle'
apply from: 'gradle/code-coverage.gradle'
apply from: 'gradle/run.gradle'
apply from: 'gradle/runtime-jdk-provision.gradle'

// common maven publishing configuration
allprojects {
group = 'org.opensearch'
version = VersionProperties.getOpenSearch()
description = "OpenSearch subproject ${project.path}"
}

allprojects {
configurations.configureEach {
resolutionStrategy {
force(
'org.jetbrains:annotations:26.0.2',
'org.apache.commons:commons-text:1.13.1',
'org.ow2.asm:asm:9.8',
'org.ow2.asm:asm-util:9.8',
)
eachDependency { details ->
if (details.requested.group.startsWith('com.fasterxml.jackson')) {
details.useVersion '2.17.3'
}
if (details.requested.group == 'org.openrewrite.recipe' &&
details.requested.name == 'rewrite-java-dependencies') {
details.useVersion '1.37.0'
}
if (details.requested.group == 'com.google.errorprone' &&
details.requested.name == 'error_prone_annotations') {
details.useVersion '2.36.0'
}
}
}
}
}
configure(allprojects - project(':distribution:archives:integ-test-zip')) {
project.pluginManager.withPlugin('nebula.maven-base-publish') {
if (project.pluginManager.hasPlugin('opensearch.build') == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ public void applyZipPublicationPluginWithConfig() throws IOException, URISyntaxE
// and how these tasks are chained. The problem is that there is a known gradle issue (#20301) that does
// not allow for it ATM. If, however, it is fixed in the future the following is the code that can
// be used...

Project project = ProjectBuilder.builder().build();
project.getPluginManager().apply(Publish.class);
// add publications via API

// evaluate the project
((DefaultProject)project).evaluate();

// - Check that "validatePluginZipPom" and/or "publishPluginZipPublicationToZipStagingRepository"
// tasks have dependencies on "generatePomFileForNebulaPublication".
// - Check that there is the staging repository added.

// However, due to known issue(1): https://github.com/gradle/gradle/issues/20301
// it is impossible to reach to individual tasks and work with them.
// (1): https://docs.gradle.org/7.4/release-notes.html#known-issues

// I.e.: The following code throws exception, basically any access to individual tasks fails.
project.getTasks().getByName("validatePluginZipPom");
------------------------------- */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1941,10 +1941,10 @@ public void testMultiGet() throws Exception {
MultiGetItemResponse missingIndexItem = response.getResponses()[2];
// tag::multi-get-indexnotfound
assertNull(missingIndexItem.getResponse()); // <1>
Exception e = missingIndexItem.getFailure().getFailure(); // <2>
OpenSearchException ee = (OpenSearchException) e; // <3>
Exception e = missingIndexItem.getFailure().getFailure(); // <3>
// TODO status is broken! fix in a followup
// assertEquals(RestStatus.NOT_FOUND, ee.status()); // <4>
// <2>
assertThat(e.getMessage(),
containsString("reason=no such index [missing_index]")); // <5>
// end::multi-get-indexnotfound
Expand Down Expand Up @@ -2033,10 +2033,10 @@ public void onFailure(Exception e) {
MultiGetResponse response = client.mget(request, RequestOptions.DEFAULT);
MultiGetItemResponse item = response.getResponses()[0];
assertNull(item.getResponse()); // <1>
Exception e = item.getFailure().getFailure(); // <2>
OpenSearchException ee = (OpenSearchException) e; // <3>
Exception e = item.getFailure().getFailure(); // <3>
// TODO status is broken! fix in a followup
// assertEquals(RestStatus.CONFLICT, ee.status()); // <4>
// <2>
assertThat(e.getMessage(),
containsString("version conflict, current version [1] is "
+ "different than the one provided [1000]")); // <5>
Expand Down
1 change: 1 addition & 0 deletions client/sniffer/licenses/jackson-core-2.17.3.jar.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1d6eb3e959c737692b720d3492b2f1f34c4c8579
1 change: 0 additions & 1 deletion client/sniffer/licenses/jackson-core-2.18.2.jar.sha1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ private Path unzip(Path zip, Path pluginsDir) throws IOException, UserException
try (ZipFile zipFile = new ZipFile(zip, "UTF8", true, false)) {
final Enumeration<? extends ZipArchiveEntry> entries = zipFile.getEntries();
ZipArchiveEntry entry;
byte[] buffer = new byte[8192];
while (entries.hasMoreElements()) {
entry = entries.nextElement();
if (entry.getName().startsWith("opensearch/")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@ void assertConfigAndBin(String name, Path original, Environment env) throws IOEx
Path binDir = env.binDir().resolve(name);
assertTrue("bin dir exists", Files.exists(binDir));
assertTrue("bin is a dir", Files.isDirectory(binDir));
PosixFileAttributes binAttributes = null;
if (isPosix) {
binAttributes = Files.readAttributes(env.binDir(), PosixFileAttributes.class);
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(binDir)) {
for (Path file : stream) {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
org.gradle.caching=true
org.gradle.warning.mode=none
org.gradle.parallel=true
# https://github.com/openrewrite/rewrite-gradle-plugin/issues/212
org.gradle.workers.max=4
org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Xss2m \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
Expand Down
70 changes: 70 additions & 0 deletions gradle/code-convention.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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
*
* http://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.
*/

import org.opensearch.gradle.BuildPlugin

import static java.lang.System.getenv

allprojects {
plugins.withType(BuildPlugin).whenPluginAdded {
project.apply plugin: "org.openrewrite.rewrite"
rewrite {
activeRecipe("org.opensearch.openrewrite.recipe.CodeCleanup")
configFile = file("$rootDir/gradle/code-convention.yml")
exclusions.add("**OpenSearchTestCaseTests.java")
exclusions.add("**/simple-bulk11.json")
exclusions.add("**/simple-msearch5.json")
exclusions.add("**AbstractBenchmark.java")
exclusions.add("**ScriptClassPathResolutionContext.java")
exclusions.add("**StarTreeMapper.java")
exclusions.add("**SearchAfterIT.java")
failOnDryRunResults = true
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.9.0")
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.12.0")
}
tasks {
if (getenv("dogFoodDev")) {
assemble {
dependsOn(rewriteRun)
}
}
if (!getenv("skipDogFood")) {
check {
dependsOn(rewriteDryRun)
}
}
}
}
}
16 changes: 16 additions & 0 deletions gradle/code-convention.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
type: specs.openrewrite.org/v1beta/recipe
name: org.opensearch.openrewrite.recipe.CodeCleanup
displayName: CodeCleanup
description: Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions.
recipeList:
- org.openrewrite.java.RemoveUnusedImports
- org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
- org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
- org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods
# - org.openrewrite.staticanalysis.EmptyBlock
# - org.openrewrite.java.OrderImports
# - org.openrewrite.java.format.RemoveTrailingWhitespace
# - org.openrewrite.staticanalysis.EmptyBlock
# - org.openrewrite.staticanalysis.RemoveCallsToSystemGc
# - org.openrewrite.staticanalysis.UnnecessaryThrows
# - org.openrewrite.text.EndOfLineAtEndOfFile
Loading