Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/ml-datafe…
Browse files Browse the repository at this point in the history
…ed-add-indices_options
  • Loading branch information
benwtrent committed Feb 26, 2020
2 parents 70caa0d + f6d89ae commit 9f0ef5a
Show file tree
Hide file tree
Showing 331 changed files with 4,276 additions and 2,773 deletions.
6 changes: 4 additions & 2 deletions .ci/dockerOnLinuxExclusions
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
debian-8
opensuse-15-1
ol-7.7
sles-12
sles-12.3 # older version used in Vagrant image
sles-12.4
sles-15.1

# These OSes are deprecated and filtered starting with 8.0.0, but need to be excluded
# These OSes are deprecated and filtered starting with 8.0.0, but need to be excluded
# for PR checks
centos-6
ol-6.10
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ public class AvailableIndexFoldersBenchmark {
@Setup
public void setup() throws IOException {
Path path = Files.createTempDirectory("test");
String[] paths = new String[] {path.toString()};
String[] paths = new String[] { path.toString() };
nodePath = new NodeEnvironment.NodePath(path);

LogConfigurator.setNodeName("test");
Settings settings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), path)
.putList(Environment.PATH_DATA_SETTING.getKey(), paths).build();
.putList(Environment.PATH_DATA_SETTING.getKey(), paths)
.build();
nodeEnv = new NodeEnvironment(settings, new Environment(settings, null));

Files.createDirectories(nodePath.indicesPath);
Expand All @@ -80,7 +81,6 @@ public void setup() throws IOException {
}
}


@Benchmark
public Set<String> availableIndexFolderNaive() throws IOException {
return nodeEnv.availableIndexFoldersForPath(nodePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Benchmark)
@SuppressWarnings("unused") //invoked by benchmarking framework
@SuppressWarnings("unused") // invoked by benchmarking framework
public class MemoryStatsBenchmark {
private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean();

@Param({"0", "16", "256", "4096"})
@Param({ "0", "16", "256", "4096" })
private int tokens;

@Benchmark
Expand Down Expand Up @@ -102,4 +102,3 @@ public long getMemoryStats_64() {
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
@SuppressWarnings("unused") //invoked by benchmarking framework
@SuppressWarnings("unused") // invoked by benchmarking framework
public class AllocationBenchmark {
// Do NOT make any field final (even if it is not annotated with @Param)! See also
// http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java
Expand Down Expand Up @@ -106,8 +106,7 @@ public class AllocationBenchmark {
" 10| 10| 2| 50",
" 100| 1| 2| 50",
" 100| 3| 2| 50",
" 100| 10| 2| 50"
})
" 100| 10| 2| 50" })
public String indicesShardsReplicasNodes = "10|1|0|1";

public int numTags = 2;
Expand All @@ -124,13 +123,14 @@ public void setUp() throws Exception {
int numReplicas = toInt(params[2]);
int numNodes = toInt(params[3]);

strategy = Allocators.createAllocationService(Settings.builder()
.put("cluster.routing.allocation.awareness.attributes", "tag")
.build());
strategy = Allocators.createAllocationService(
Settings.builder().put("cluster.routing.allocation.awareness.attributes", "tag").build()
);

MetaData.Builder mb = MetaData.builder();
for (int i = 1; i <= numIndices; i++) {
mb.put(IndexMetaData.builder("test_" + i)
mb.put(
IndexMetaData.builder("test_" + i)
.settings(Settings.builder().put("index.version.created", Version.CURRENT))
.numberOfShards(numShards)
.numberOfReplicas(numReplicas)
Expand All @@ -147,8 +147,10 @@ public void setUp() throws Exception {
nb.add(Allocators.newNode("node" + i, Collections.singletonMap("tag", "tag_" + (i % numTags))));
}
initialClusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData).routingTable(routingTable).nodes
(nb).build();
.metaData(metaData)
.routingTable(routingTable)
.nodes(nb)
.build();
}

private int toInt(String v) {
Expand All @@ -159,8 +161,10 @@ private int toInt(String v) {
public ClusterState measureAllocation() {
ClusterState clusterState = initialClusterState;
while (clusterState.getRoutingNodes().hasUnassignedShards()) {
clusterState = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes()
.shardsWithState(ShardRoutingState.INITIALIZING));
clusterState = strategy.applyStartedShards(
clusterState,
clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.INITIALIZING)
);
clusterState = strategy.reroute(clusterState, "reroute");
}
return clusterState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.gateway.GatewayAllocator;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -67,33 +66,34 @@ private Allocators() {
throw new AssertionError("Do not instantiate");
}


public static AllocationService createAllocationService(Settings settings) throws NoSuchMethodException, InstantiationException,
IllegalAccessException, InvocationTargetException {
return createAllocationService(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings
.BUILT_IN_CLUSTER_SETTINGS));
public static AllocationService createAllocationService(Settings settings) {
return createAllocationService(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
}

public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) throws
InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) {
return new AllocationService(
defaultAllocationDeciders(settings, clusterSettings),
NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(settings), EmptyClusterInfoService.INSTANCE);
NoopGatewayAllocator.INSTANCE,
new BalancedShardsAllocator(settings),
EmptyClusterInfoService.INSTANCE
);
}

public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) throws
IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
Collection<AllocationDecider> deciders =
ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) {
Collection<AllocationDecider> deciders = ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
return new AllocationDeciders(deciders);

}

private static final AtomicInteger portGenerator = new AtomicInteger();

public static DiscoveryNode newNode(String nodeId, Map<String, String> attributes) {
return new DiscoveryNode("", nodeId, new TransportAddress(TransportAddress.META_ADDRESS,
portGenerator.incrementAndGet()), attributes, Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE,
DiscoveryNodeRole.DATA_ROLE), Version.CURRENT);
return new DiscoveryNode(
"",
nodeId,
new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()),
attributes,
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE),
Version.CURRENT
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@SuppressWarnings("unused") //invoked by benchmarking framework
@SuppressWarnings("unused") // invoked by benchmarking framework
public class DateFormatterBenchmark {

private final DateFormatter javaFormatter = DateFormatter.forPattern("8year_month_day||ordinal_date||epoch_millis");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
@SuppressWarnings("unused") //invoked by benchmarking framework
@SuppressWarnings("unused") // invoked by benchmarking framework
public class DateFormatterFromBenchmark {

private final TemporalAccessor accessor = DateFormatter.forPattern("epoch_millis").parse("1234567890");
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ subprojects {
// is greater than the number of unformatted projects, this can be
// switched to an exclude list, and eventualy removed completely.
def projectPathsToFormat = [
':benchmarks',
':build-tools',
':distribution:tools:java-version-checker',
':distribution:tools:keystore-cli',
':distribution:tools:launchers',
':distribution:tools:plugin-cli',
':qa:os',
':x-pack:plugin:autoscaling',
':x-pack:plugin:enrich'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.elasticsearch.gradle.NoticeTask
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.RunTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
Expand Down Expand Up @@ -51,6 +52,7 @@ class PluginBuildPlugin implements Plugin<Project> {
void apply(Project project) {
project.pluginManager.apply(BuildPlugin)
project.pluginManager.apply(TestClustersPlugin)
project.pluginManager.apply(RestResourcesPlugin)

PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
configureDependencies(project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,19 @@
*/
package org.elasticsearch.gradle.test

import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask
import org.elasticsearch.gradle.tool.Boilerplate
import org.gradle.api.DefaultTask
import org.gradle.api.Task
import org.gradle.api.file.FileCopyDetails
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.testing.Test
import org.gradle.plugins.ide.idea.IdeaPlugin

/**
* A wrapper task around setting up a cluster and running rest tests.
*/
class RestIntegTestTask extends DefaultTask {

protected Test runner

/** Flag indicating whether the rest tests in the rest spec should be run. */
@Input
Boolean includePackaged = false

RestIntegTestTask() {
runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class)
super.dependsOn(runner)
Expand Down Expand Up @@ -69,10 +59,6 @@ class RestIntegTestTask extends DefaultTask {
runner.systemProperty('test.clustername', System.getProperty("tests.clustername"))
}

// copy the rest spec/tests onto the test classpath
Copy copyRestSpec = createCopyRestSpecTask()
project.sourceSets.test.output.builtBy(copyRestSpec)

// this must run after all projects have been configured, so we know any project
// references can be accessed as a fully configured
project.gradle.projectsEvaluated {
Expand All @@ -83,12 +69,6 @@ class RestIntegTestTask extends DefaultTask {
}
}

/** Sets the includePackaged property */
public void includePackaged(boolean include) {
includePackaged = include
}


@Override
public Task dependsOn(Object... dependencies) {
runner.dependsOn(dependencies)
Expand All @@ -114,37 +94,4 @@ class RestIntegTestTask extends DefaultTask {
project.tasks.getByName("${name}Runner").configure(configure)
}

Copy createCopyRestSpecTask() {
Boilerplate.maybeCreate(project.configurations, 'restSpec') {
project.dependencies.add(
'restSpec',
BuildParams.internal ? project.project(':rest-api-spec') :
"org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}"
)
}

return Boilerplate.maybeCreate(project.tasks, 'copyRestSpec', Copy) { Copy copy ->
copy.dependsOn project.configurations.restSpec
copy.into(project.sourceSets.test.output.resourcesDir)
copy.from({ project.zipTree(project.configurations.restSpec.singleFile) }) {
includeEmptyDirs = false
include 'rest-api-spec/**'
filesMatching('rest-api-spec/test/**') { FileCopyDetails details ->
if (includePackaged == false) {
details.exclude()
}
}
}

if (project.plugins.hasPlugin(IdeaPlugin)) {
project.idea {
module {
if (scopes.TEST != null) {
scopes.TEST.plus.add(project.configurations.restSpec)
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.elasticsearch.gradle.info.BuildParams
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.gradle.api.InvalidUserDataException
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
Expand All @@ -42,6 +42,7 @@ import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.plugins.ide.eclipse.model.EclipseModel
import org.gradle.plugins.ide.idea.model.IdeaModel

/**
* Configures the build to compile tests against Elasticsearch's test framework
* and run REST tests. Use BuildPlugin if you want to build main code as well
Expand Down Expand Up @@ -74,6 +75,8 @@ class StandaloneRestTestPlugin implements Plugin<Project> {
// only setup tests to build
SourceSetContainer sourceSets = project.extensions.getByType(SourceSetContainer)
SourceSet testSourceSet = sourceSets.create('test')
// need to apply plugin after test source sets are created
project.pluginManager.apply(RestResourcesPlugin)

project.tasks.withType(Test) { Test test ->
test.testClassesDirs = testSourceSet.output.classesDirs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static Map<String, String> parseOsRelease(final List<String> osReleaseLines) {
// remove optional leading and trailing quotes and whitespace
final String value = parts[1].replaceAll("^['\"]?\\s*", "").replaceAll("\\s*['\"]?$", "");

values.put(key, value);
values.put(key, value.toLowerCase());
});

return values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void doCheck() throws IOException {
Files.write(getSuccessMarker().toPath(), new byte[] {}, StandardOpenOption.CREATE);
} else {
getLogger().error(problems);
throw new IllegalStateException("Testing conventions are not honored");
throw new IllegalStateException(String.format("Testing conventions [%s] are not honored", problems));
}
}

Expand Down
Loading

0 comments on commit 9f0ef5a

Please sign in to comment.