Skip to content

Commit 311f660

Browse files
committed
Merge branch 'feature/runtime_fields' into runtime_fields_fetch_fields
2 parents 6409abe + 4540211 commit 311f660

File tree

516 files changed

+9412
-7448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

516 files changed

+9412
-7448
lines changed

benchmarks/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,29 @@ To get realistic results, you should exercise care when running benchmarks. Here
6363
* Blindly believe the numbers that your microbenchmark produces but verify them by measuring e.g. with `-prof perfasm`.
6464
* Run more threads than your number of CPU cores (in case you run multi-threaded microbenchmarks).
6565
* Look only at the `Score` column and ignore `Error`. Instead take countermeasures to keep `Error` low / variance explainable.
66+
67+
## Disassembling
68+
69+
Disassembling is fun! Maybe not always useful, but always fun! Generally, you'll want to install `perf` and FCML's `hsdis`.
70+
`perf` is generally available via `apg-get install perf` or `pacman -S perf`. FCML is a little more involved. This worked
71+
on 2020-08-01:
72+
73+
```
74+
wget https://github.com/swojtasiak/fcml-lib/releases/download/v1.2.2/fcml-1.2.2.tar.gz
75+
tar xf fcml*
76+
cd fcml*
77+
./configure
78+
make
79+
cd example/hsdis
80+
make
81+
cp .libs/libhsdis.so.0.0.0
82+
sudo cp .libs/libhsdis.so.0.0.0 /usr/lib/jvm/java-14-adoptopenjdk/lib/hsdis-amd64.so
83+
```
84+
85+
If you want to disassemble a single method do something like this:
86+
87+
```
88+
gradlew -p benchmarks run --args ' MemoryStatsBenchmark -jvmArgs "-XX:+UnlockDiagnosticVMOptions -XX:CompileCommand=print,*.yourMethodName -XX:PrintAssemblyOptions=intel"
89+
```
90+
91+
If you want `perf` to find the hot methods for you then do add `-prof:perfasm`.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.gradle
21+
22+
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
23+
import org.gradle.testkit.runner.TaskOutcome
24+
25+
class ElasticsearchTestBasePluginFuncTest extends AbstractGradleFuncTest {
26+
27+
def "can configure nonInputProperties for test tasks"() {
28+
given:
29+
file("src/test/java/acme/SomeTests.java").text = """
30+
31+
public class SomeTests {
32+
@org.junit.Test
33+
public void testSysInput() {
34+
org.junit.Assert.assertEquals("bar", System.getProperty("foo"));
35+
}
36+
}
37+
38+
"""
39+
buildFile.text = """
40+
plugins {
41+
id 'java'
42+
id 'elasticsearch.test-base'
43+
}
44+
45+
repositories {
46+
jcenter()
47+
}
48+
49+
dependencies {
50+
testImplementation 'junit:junit:4.12'
51+
}
52+
53+
tasks.named('test').configure {
54+
nonInputProperties.systemProperty("foo", project.getProperty('foo'))
55+
}
56+
"""
57+
58+
when:
59+
def result = gradleRunner("test", '-Dtests.seed=default', '-Pfoo=bar').build()
60+
61+
then:
62+
result.task(':test').outcome == TaskOutcome.SUCCESS
63+
64+
when:
65+
result = gradleRunner("test", '-i', '-Dtests.seed=default', '-Pfoo=baz').build()
66+
67+
then:
68+
result.task(':test').outcome == TaskOutcome.UP_TO_DATE
69+
}
70+
}

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ abstract class AbstractGradleFuncTest extends Specification{
5858
return input.readLines().join("\n")
5959
}
6060

61+
File file(String path) {
62+
File newFile = new File(testProjectDir.root, path)
63+
newFile.getParentFile().mkdirs()
64+
newFile
65+
}
66+
6167
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class RestTestsFromSnippetsTask extends SnippetsTask {
266266
case 'basic':
267267
case 'gold':
268268
case 'platinum':
269+
case 'enterprise':
269270
current.println(" - xpack")
270271
break;
271272
default:

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.dependencies.CompileOnlyResolvePlugin
2727
import org.elasticsearch.gradle.info.BuildParams
2828
import org.elasticsearch.gradle.test.RestIntegTestTask
29+
import org.elasticsearch.gradle.test.RestTestBasePlugin
2930
import org.elasticsearch.gradle.testclusters.RunTask
3031
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
3132
import org.elasticsearch.gradle.util.Util
@@ -54,7 +55,7 @@ class PluginBuildPlugin implements Plugin<Project> {
5455
@Override
5556
void apply(Project project) {
5657
project.pluginManager.apply(BuildPlugin)
57-
project.pluginManager.apply(TestClustersPlugin)
58+
project.pluginManager.apply(RestTestBasePlugin)
5859
project.pluginManager.apply(CompileOnlyResolvePlugin.class);
5960

6061
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class RestTestPlugin implements Plugin<Project> {
4545
+ 'requires either elasticsearch.build or '
4646
+ 'elasticsearch.standalone-rest-test')
4747
}
48-
48+
project.getPlugins().apply(RestTestBasePlugin.class);
4949
project.pluginManager.apply(TestClustersPlugin)
5050
RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class)
5151
integTest.description = 'Runs rest tests against an elasticsearch cluster.'

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ class StandaloneRestTestPlugin implements Plugin<Project> {
6161
project.pluginManager.apply(JavaBasePlugin)
6262
project.pluginManager.apply(TestClustersPlugin)
6363
project.pluginManager.apply(RepositoriesSetupPlugin)
64+
project.pluginManager.apply(RestTestBasePlugin)
6465

6566
project.getTasks().register("buildResources", ExportElasticsearchBuildResourcesTask)
66-
ElasticsearchJavaPlugin.configureTestTasks(project)
6767
ElasticsearchJavaPlugin.configureInputNormalization(project)
6868
ElasticsearchJavaPlugin.configureCompile(project)
6969

70+
7071
project.extensions.getByType(JavaPluginExtension).sourceCompatibility = BuildParams.minimumRuntimeVersion
7172
project.extensions.getByType(JavaPluginExtension).targetCompatibility = BuildParams.minimumRuntimeVersion
7273

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/TestWithSslPlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask;
2323
import org.elasticsearch.gradle.precommit.ForbiddenPatternsTask;
2424
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
25-
import org.elasticsearch.gradle.testclusters.RestTestRunnerTask;
2625
import org.elasticsearch.gradle.testclusters.TestClustersAware;
2726
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
2827
import org.elasticsearch.gradle.util.Util;
@@ -57,7 +56,7 @@ public void apply(Project project) {
5756

5857
// Tell the tests we're running with ssl enabled
5958
project.getTasks()
60-
.withType(RestTestRunnerTask.class)
59+
.withType(RestIntegTestTask.class)
6160
.configureEach(runner -> runner.systemProperty("tests.ssl.enabled", "true"));
6261
});
6362

buildSrc/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ public Iterator<File> iterator() {
244244
return configuration.iterator();
245245
}
246246

247-
// TODO: remove this when distro tests are per distribution
248-
public Configuration getConfiguration() {
249-
return configuration;
250-
}
251-
252247
// internal, make this distribution's configuration unmodifiable
253248
void finalizeValues() {
254249

0 commit comments

Comments
 (0)