Skip to content

Commit

Permalink
Merge branch 'master' into security_authz_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymode committed Jan 25, 2019
2 parents 7846ee8 + 899dfc3 commit 74f2e99
Show file tree
Hide file tree
Showing 358 changed files with 5,599 additions and 4,980 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.bat]
indent_size = 2
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ task verifyVersions {
* the enabled state of every bwc task. It should be set back to true
* after the backport of the backcompat code is complete.
*/
final boolean bwc_tests_enabled = false
final String bwc_tests_disabled_issue = "backporting https://github.com/elastic/elasticsearch/pull/37639" /* place a PR link here when committing bwc changes */
final boolean bwc_tests_enabled = true
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
if (bwc_tests_enabled == false) {
if (bwc_tests_disabled_issue.isEmpty()) {
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
Expand Down Expand Up @@ -212,6 +212,7 @@ allprojects {
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
Expand Down
5 changes: 0 additions & 5 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ if (project != rootProject) {
exclude '**/ForbiddenPatternsTask.java'
}

namingConventions {
testClass = 'org.elasticsearch.gradle.test.GradleUnitTestCase'
integTestClass = 'org.elasticsearch.gradle.test.GradleIntegrationTestCase'
}

testingConventions {
naming.clear()
naming {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ class BuildPlugin implements Plugin<Project> {
project.tasks.withType(RandomizedTestingTask) {task ->
jvm "${project.runtimeJavaHome}/bin/java"
parallelism System.getProperty('tests.jvms', project.rootProject.ext.defaultParallel)
ifNoTests 'fail'
onNonEmptyWorkDirectory 'wipe'
leaveTemporary true
project.sourceSets.matching { it.name == "test" }.all { test ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class DocsTestPlugin extends RestTestPlugin {
'\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(),
'\\{version_qualified\\}': VersionProperties.elasticsearch,
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
'\\{build_flavor\\}' :
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
'\\{build_flavor\\}' : project.integTestCluster.distribution,
]
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
listSnippets.group 'Docs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public class PluginBuildPlugin extends BuildPlugin {
if (isModule == false || isXPackModule) {
addNoticeGeneration(project)
}

project.namingConventions {
// Plugins declare integration tests as "Tests" instead of IT.
skipIntegTestInDisguise = true
}
}
project.testingConventions {
naming.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class PrecommitTasks {
List<Task> precommitTasks = [
configureCheckstyle(project),
configureForbiddenApisCli(project),
configureNamingConventions(project),
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
project.tasks.create('filepermissions', FilePermissionsTask.class),
Expand Down Expand Up @@ -230,15 +229,6 @@ class PrecommitTasks {
return checkstyleTask
}

private static Task configureNamingConventions(Project project) {
if (project.sourceSets.findByName("test")) {
Task namingConventionsTask = project.tasks.create('namingConventions', NamingConventionsTask)
namingConventionsTask.javaHome = project.compilerJavaHome
return namingConventionsTask
}
return null
}

private static Task configureLoggerUsage(Project project) {
project.configurations.create('loggerUsagePlugin')
project.dependencies.add('loggerUsagePlugin',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.gradle.api.file.FileTree;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.testing.Test;
import org.gradle.api.tasks.util.PatternFilterable;
Expand Down Expand Up @@ -122,6 +124,23 @@ public void naming(Closure<TestingConventionRule> action) {
naming.configure(action);
}

@Input
public Set<String> getMainClassNamedLikeTests() {
SourceSetContainer javaSourceSets = Boilerplate.getJavaSourceSets(getProject());
if (javaSourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) == null) {
// some test projects don't have a main source set
return Collections.emptySet();
}
return javaSourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
.getOutput().getClassesDirs().getAsFileTree()
.getFiles().stream()
.filter(file -> file.getName().endsWith(".class"))
.map(File::getName)
.map(name -> name.substring(0, name.length() - 6))
.filter(this::implementsNamingConvention)
.collect(Collectors.toSet());
}

@TaskAction
public void doCheck() throws IOException {
final String problems;
Expand Down Expand Up @@ -235,10 +254,12 @@ public void doCheck() throws IOException {
);
}).sorted()
.collect(Collectors.joining("\n"))
)
),
// TODO: check that the testing tasks are included in the right task based on the name ( from the rule )
// TODO: check to make sure that the main source set doesn't have classes that match
// the naming convention (just the names, don't load classes)
checkNoneExists(
"Classes matching the test naming convention should be in test not main",
getMainClassNamedLikeTests()
)
);
}

Expand Down Expand Up @@ -296,6 +317,18 @@ private String checkNoneExists(String message, Stream<? extends Class<?>> stream
}
}

private String checkNoneExists(String message, Set<? extends String> candidates) {
String problem = candidates.stream()
.map(each -> " * " + each)
.sorted()
.collect(Collectors.joining("\n"));
if (problem.isEmpty() == false) {
return message + ":\n" + problem;
} else {
return "";
}
}

private String checkAtLeastOneExists(String message, Stream<? extends Class<?>> stream) {
if (stream.findAny().isPresent()) {
return "";
Expand Down Expand Up @@ -337,10 +370,14 @@ private boolean seemsLikeATest(Class<?> clazz) {
}

private boolean implementsNamingConvention(Class<?> clazz) {
return implementsNamingConvention(clazz.getName());
}

private boolean implementsNamingConvention(String className) {
if (naming.stream()
.map(TestingConventionRule::getSuffix)
.anyMatch(suffix -> clazz.getName().endsWith(suffix))) {
getLogger().debug("{} is a test because it matches the naming convention", clazz.getName());
.anyMatch(suffix -> className.endsWith(suffix))) {
getLogger().debug("{} is a test because it matches the naming convention", className);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputDirectory;
import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.SkipWhenEmpty;
import org.gradle.api.tasks.TaskAction;
import org.gradle.process.ExecResult;
Expand Down Expand Up @@ -86,11 +88,13 @@ public void setTargetCompatibility(JavaVersion targetCompatibility) {
}

@InputFiles
@PathSensitive(PathSensitivity.NAME_ONLY)
public Configuration getForbiddenAPIsConfiguration() {
return getProject().getConfigurations().getByName("forbiddenApisCliJar");
}

@InputFile
@PathSensitive(PathSensitivity.NONE)
public File getSignatureFile() {
return signatureFile;
}
Expand Down Expand Up @@ -154,6 +158,7 @@ public Set<String> getMissingClassExcludes() {
}

@InputFiles
@PathSensitive(PathSensitivity.NAME_ONLY)
@SkipWhenEmpty
public Set<File> getJarsToScan() {
// These are SelfResolvingDependency, and some of them backed by file collections, like the Gradle API files,
Expand Down
Loading

0 comments on commit 74f2e99

Please sign in to comment.