Skip to content

Commit 922d69f

Browse files
committed
Merge remote-tracking branch 'elastic/master' into sync-retention-leases
* elastic/master: (68 commits) Fix potential IllegalCapacityException in LLRC when selecting nodes (elastic#37821) Mute CcrRepositoryIT#testFollowerMappingIsUpdated Fix S3 Repository ITs When Docker is not Available (elastic#37878) Pass distribution type through to docs tests (elastic#37885) Mute SharedClusterSnapshotRestoreIT#testSnapshotCanceledOnRemovedShard SQL: Fix casting from date to numeric type to use millis (elastic#37869) Migrate o.e.i.r.RecoveryState to Writeable (elastic#37380) ML: removing unnecessary upgrade code (elastic#37879) Relax cluster metadata version check (elastic#37834) Mute TransformIntegrationTests#testSearchTransform Refactored GeoHashGrid unit tests (elastic#37832) Fixes for a few randomized agg tests that fail hasValue() checks Geo: replace intermediate geo objects with libs/geo (elastic#37721) Remove NOREPLACE for /etc/elasticsearch in rpm and deb (elastic#37839) Remove "reinstall" packaging tests (elastic#37851) Add unit tests for ShardStateAction's ShardStartedClusterStateTaskExecutor (elastic#37756) Exit batch files explictly using ERRORLEVEL (elastic#29583) TransportUnfollowAction should increase settings version (elastic#37859) AsyncTwoPhaseIndexerTests race condition fixed (elastic#37830) Do not allow negative variances (elastic#37384) ...
2 parents 09fcc7c + a35701e commit 922d69f

File tree

363 files changed

+5630
-4998
lines changed

Some content is hidden

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

363 files changed

+5630
-4998
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ indent_style = space
88
indent_size = 4
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11+
12+
[*.bat]
13+
indent_size = 2

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ task verifyVersions {
159159
* the enabled state of every bwc task. It should be set back to true
160160
* after the backport of the backcompat code is complete.
161161
*/
162-
final boolean bwc_tests_enabled = false
163-
final String bwc_tests_disabled_issue = "backporting https://github.com/elastic/elasticsearch/pull/37639" /* place a PR link here when committing bwc changes */
162+
final boolean bwc_tests_enabled = true
163+
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
164164
if (bwc_tests_enabled == false) {
165165
if (bwc_tests_disabled_issue.isEmpty()) {
166166
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
@@ -212,6 +212,7 @@ allprojects {
212212
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
213213
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
214214
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
215+
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
215216
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
216217
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
217218
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',

buildSrc/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ if (project != rootProject) {
235235
exclude '**/ForbiddenPatternsTask.java'
236236
}
237237

238-
namingConventions {
239-
testClass = 'org.elasticsearch.gradle.test.GradleUnitTestCase'
240-
integTestClass = 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
241-
}
242-
243238
testingConventions {
244239
naming.clear()
245240
naming {

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ class BuildPlugin implements Plugin<Project> {
904904
project.tasks.withType(RandomizedTestingTask) {task ->
905905
jvm "${project.runtimeJavaHome}/bin/java"
906906
parallelism System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel)
907+
ifNoTests 'fail'
907908
onNonEmptyWorkDirectory 'wipe'
908909
leaveTemporary true
909910
project.sourceSets.matching { it.name == "test" }.all { test ->

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public class DocsTestPlugin extends RestTestPlugin {
4545
'\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(),
4646
'\\{version_qualified\\}': VersionProperties.elasticsearch,
4747
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
48-
'\\{build_flavor\\}' :
49-
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
48+
'\\{build_flavor\\}' : project.integTestCluster.distribution,
5049
]
5150
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
5251
listSnippets.group 'Docs'

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ public class PluginBuildPlugin extends BuildPlugin {
7272
if (isModule == false || isXPackModule) {
7373
addNoticeGeneration(project)
7474
}
75-
76-
project.namingConventions {
77-
// Plugins declare integration tests as "Tests" instead of IT.
78-
skipIntegTestInDisguise = true
79-
}
8075
}
8176
project.testingConventions {
8277
naming.clear()

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class PrecommitTasks {
4343
List<Task> precommitTasks = [
4444
configureCheckstyle(project),
4545
configureForbiddenApisCli(project),
46-
configureNamingConventions(project),
4746
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
4847
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
4948
project.tasks.create('filepermissions', FilePermissionsTask.class),
@@ -230,15 +229,6 @@ class PrecommitTasks {
230229
return checkstyleTask
231230
}
232231

233-
private static Task configureNamingConventions(Project project) {
234-
if (project.sourceSets.findByName("test")) {
235-
Task namingConventionsTask = project.tasks.create('namingConventions', NamingConventionsTask)
236-
namingConventionsTask.javaHome = project.compilerJavaHome
237-
return namingConventionsTask
238-
}
239-
return null
240-
}
241-
242232
private static Task configureLoggerUsage(Project project) {
243233
project.configurations.create('loggerUsagePlugin')
244234
project.dependencies.add('loggerUsagePlugin',

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/NamingConventionsTask.java

Lines changed: 0 additions & 167 deletions
This file was deleted.

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/TestingConventionsTasks.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.gradle.api.file.FileTree;
2828
import org.gradle.api.tasks.Input;
2929
import org.gradle.api.tasks.OutputFile;
30+
import org.gradle.api.tasks.SourceSet;
31+
import org.gradle.api.tasks.SourceSetContainer;
3032
import org.gradle.api.tasks.TaskAction;
3133
import org.gradle.api.tasks.testing.Test;
3234
import org.gradle.api.tasks.util.PatternFilterable;
@@ -122,6 +124,23 @@ public void naming(Closure<TestingConventionRule> action) {
122124
naming.configure(action);
123125
}
124126

127+
@Input
128+
public Set<String> getMainClassNamedLikeTests() {
129+
SourceSetContainer javaSourceSets = Boilerplate.getJavaSourceSets(getProject());
130+
if (javaSourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) == null) {
131+
// some test projects don't have a main source set
132+
return Collections.emptySet();
133+
}
134+
return javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
135+
.getOutput().getClassesDirs().getAsFileTree()
136+
.getFiles().stream()
137+
.filter(file -> file.getName().endsWith(".class"))
138+
.map(File::getName)
139+
.map(name -> name.substring(0, name.length() - 6))
140+
.filter(this::implementsNamingConvention)
141+
.collect(Collectors.toSet());
142+
}
143+
125144
@TaskAction
126145
public void doCheck() throws IOException {
127146
final String problems;
@@ -235,10 +254,12 @@ public void doCheck() throws IOException {
235254
);
236255
}).sorted()
237256
.collect(Collectors.joining("\n"))
238-
)
257+
),
239258
// TODO: check that the testing tasks are included in the right task based on the name ( from the rule )
240-
// TODO: check to make sure that the main source set doesn't have classes that match
241-
// the naming convention (just the names, don't load classes)
259+
checkNoneExists(
260+
"Classes matching the test naming convention should be in test not main",
261+
getMainClassNamedLikeTests()
262+
)
242263
);
243264
}
244265

@@ -296,6 +317,18 @@ private String checkNoneExists(String message, Stream<? extends Class<?>> stream
296317
}
297318
}
298319

320+
private String checkNoneExists(String message, Set<? extends String> candidates) {
321+
String problem = candidates.stream()
322+
.map(each -> " * " + each)
323+
.sorted()
324+
.collect(Collectors.joining("\n"));
325+
if (problem.isEmpty() == false) {
326+
return message + ":\n" + problem;
327+
} else {
328+
return "";
329+
}
330+
}
331+
299332
private String checkAtLeastOneExists(String message, Stream<? extends Class<?>> stream) {
300333
if (stream.findAny().isPresent()) {
301334
return "";
@@ -337,10 +370,14 @@ private boolean seemsLikeATest(Class<?> clazz) {
337370
}
338371

339372
private boolean implementsNamingConvention(Class<?> clazz) {
373+
return implementsNamingConvention(clazz.getName());
374+
}
375+
376+
private boolean implementsNamingConvention(String className) {
340377
if (naming.stream()
341378
.map(TestingConventionRule::getSuffix)
342-
.anyMatch(suffix -> clazz.getName().endsWith(suffix))) {
343-
getLogger().debug("{} is a test because it matches the naming convention", clazz.getName());
379+
.anyMatch(suffix -> className.endsWith(suffix))) {
380+
getLogger().debug("{} is a test because it matches the naming convention", className);
344381
return true;
345382
}
346383
return false;

buildSrc/src/main/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTask.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.gradle.api.tasks.InputFiles;
3434
import org.gradle.api.tasks.Optional;
3535
import org.gradle.api.tasks.OutputDirectory;
36+
import org.gradle.api.tasks.PathSensitive;
37+
import org.gradle.api.tasks.PathSensitivity;
3638
import org.gradle.api.tasks.SkipWhenEmpty;
3739
import org.gradle.api.tasks.TaskAction;
3840
import org.gradle.process.ExecResult;
@@ -86,11 +88,13 @@ public void setTargetCompatibility(JavaVersion targetCompatibility) {
8688
}
8789

8890
@InputFiles
91+
@PathSensitive(PathSensitivity.NAME_ONLY)
8992
public Configuration getForbiddenAPIsConfiguration() {
9093
return getProject().getConfigurations().getByName("forbiddenApisCliJar");
9194
}
9295

9396
@InputFile
97+
@PathSensitive(PathSensitivity.NONE)
9498
public File getSignatureFile() {
9599
return signatureFile;
96100
}
@@ -154,6 +158,7 @@ public Set<String> getMissingClassExcludes() {
154158
}
155159

156160
@InputFiles
161+
@PathSensitive(PathSensitivity.NAME_ONLY)
157162
@SkipWhenEmpty
158163
public Set<File> getJarsToScan() {
159164
// These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files,

0 commit comments

Comments
 (0)