Skip to content

Commit b48807f

Browse files
committed
Merge remote-tracking branch 'origin/ccr' into pr/30123
* origin/ccr: (166 commits) Introduce soft-deletes retention policy based on global checkpoint (elastic#30335) Enable MockHttpTransport in ShardChangsIT Remove old sha files from dated Lucene snapshot Update InternalEngine tests on ccr side for elastic#30121 Set the new lucene version for 6.4.0 [ML][TEST] Clean up jobs in ModelPlotIT Upgrade to 7.4.0-snapshot-1ed95c097b (elastic#30357) Watcher: Ensure trigger service pauses execution (elastic#30363) [DOCS] Added coming qualifiers in changelog [DOCS] Commented out empty sections in the changelog to fix the doc build. (elastic#30372) Security: reduce garbage during index resolution (elastic#30180) Make RepositoriesMetaData contents unmodifiable (elastic#30361) Change quad tree max levels to 29. Closes elastic#21191 (elastic#29663) Test: use trial license in qa tests with security [ML] Add integration test for model plots (elastic#30359) SQL: Fix bug caused by empty composites (elastic#30343) [ML] Account for gaps in data counts after job is reopened (elastic#30294) InternalEngineTests.testConcurrentOutOfOrderDocsOnReplica should use two documents (elastic#30121) Change signature of Get Repositories Response (elastic#30333) Tests: Use different watch ids per test in smoke test (elastic#30331) ...
2 parents cd42a3f + 2c73969 commit b48807f

File tree

807 files changed

+14273
-9794
lines changed

Some content is hidden

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

807 files changed

+14273
-9794
lines changed

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ nbactions.xml
2020
.gradle/
2121
build/
2222

23-
# maven stuff (to be removed when trunk becomes 4.x)
24-
*-execution-hints.log
25-
target/
26-
dependency-reduced-pom.xml
23+
# vscode stuff
24+
.vscode/
2725

2826
# testing stuff
2927
**/.local*
@@ -43,4 +41,3 @@ html_docs
4341
# random old stuff that we should look at the necessity of...
4442
/tmp/
4543
eclipse-build
46-

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ We support development in the Eclipse and IntelliJ IDEs. For Eclipse, the
107107
minimum version that we support is [Eclipse Oxygen][eclipse] (version 4.7). For
108108
IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij].
109109

110+
### Configuring IDEs And Running Tests
111+
110112
Eclipse users can automatically configure their IDE: `./gradlew eclipse`
111113
then `File: Import: Existing Projects into Workspace`. Select the
112114
option `Search for nested projects`. Additionally you will want to
@@ -144,6 +146,9 @@ For IntelliJ, go to
144146
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
145147
`VM Arguments`.
146148

149+
150+
### Java Language Formatting Guidelines
151+
147152
Please follow these formatting guidelines:
148153

149154
* Java indent is 4 spaces
@@ -155,6 +160,33 @@ Please follow these formatting guidelines:
155160
* IntelliJ: `Preferences/Settings->Editor->Code Style->Java->Imports`. There are two configuration options: `Class count to use import with '*'` and `Names count to use static import with '*'`. Set their values to 99999 or some other absurdly high value.
156161
* Don't worry too much about import order. Try not to change it but don't worry about fighting your IDE to stop it from doing so.
157162

163+
### License Headers
164+
165+
We require license headers on all Java files. You will notice that all the Java files in
166+
the top-level `x-pack` directory contain a separate license from the rest of the repository. This
167+
directory contains commercial code that is associated with a separate license. It can be helpful
168+
to have the IDE automatically insert the appropriate license header depending which part of the project
169+
contributions are made to.
170+
171+
#### IntelliJ: Copyright & Scope Profiles
172+
173+
To have IntelliJ insert the correct license, it is necessary to create to copyright profiles.
174+
These may potentially be called `apache2` and `commercial`. These can be created in
175+
`Preferences/Settings->Editor->Copyright->Copyright Profiles`. To associate these profiles to
176+
their respective directories, two "Scopes" will need to be created. These can be created in
177+
`Preferences/Settings->Appearances & Behavior->Scopes`. When creating scopes, be sure to choose
178+
the `shared` scope type. Create a scope, `apache2`, with
179+
the associated pattern of `!file[group:x-pack]:*/`. This pattern will exclude all the files contained in
180+
the `x-pack` directory. The other scope, `commercial`, will have the inverse pattern of `file[group:x-pack]:*/`.
181+
The two scopes, together, should account for all the files in the project. To associate the scopes
182+
with their copyright-profiles, go into `Preferences/Settings->Editor>Copyright` and use the `+` to add
183+
the associations `apache2/apache2` and `commercial/commercial`.
184+
185+
Configuring these options in IntelliJ can be quite buggy, so do not be alarmed if you have to open/close
186+
the settings window and/or restart IntelliJ to see your changes take effect.
187+
188+
### Creating A Distribution
189+
158190
To create a distribution from the source, simply run:
159191

160192
```sh
@@ -169,6 +201,8 @@ The archive distributions (tar and zip) can be found under:
169201
`./distribution/archives/(tar|zip)/build/distributions/`
170202

171203

204+
### Running The Full Test Suite
205+
172206
Before submitting your changes, run the test suite to make sure that nothing is broken, with:
173207

174208
```sh

Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ export BATS=/project/build/bats
337337
export BATS_UTILS=/project/build/packaging/bats/utils
338338
export BATS_TESTS=/project/build/packaging/bats/tests
339339
export PACKAGING_ARCHIVES=/project/build/packaging/archives
340+
export PACKAGING_TESTS=/project/build/packaging/tests
340341
VARS
341342
cat \<\<SUDOERS_VARS > /etc/sudoers.d/elasticsearch_vars
342343
Defaults env_keep += "ZIP"
@@ -347,6 +348,7 @@ Defaults env_keep += "BATS"
347348
Defaults env_keep += "BATS_UTILS"
348349
Defaults env_keep += "BATS_TESTS"
349350
Defaults env_keep += "PACKAGING_ARCHIVES"
351+
Defaults env_keep += "PACKAGING_TESTS"
350352
SUDOERS_VARS
351353
chmod 0440 /etc/sudoers.d/elasticsearch_vars
352354
SHELL

build.gradle

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020

2121
import org.apache.tools.ant.taskdefs.condition.Os
22+
import org.apache.tools.ant.filters.ReplaceTokens
2223
import org.elasticsearch.gradle.BuildPlugin
24+
import org.elasticsearch.gradle.LoggedExec
2325
import org.elasticsearch.gradle.Version
2426
import org.elasticsearch.gradle.VersionCollection
2527
import org.elasticsearch.gradle.VersionProperties
@@ -30,6 +32,7 @@ import org.gradle.api.tasks.wrapper.Wrapper.DistributionType
3032
import org.gradle.util.GradleVersion
3133
import org.gradle.util.DistributionLocator
3234

35+
import java.nio.file.Files
3336
import java.nio.file.Path
3437
import java.security.MessageDigest
3538

@@ -404,10 +407,19 @@ allprojects {
404407
}
405408
}
406409
}
410+
411+
File licenseHeaderFile;
412+
if (eclipse.project.name.startsWith(':x-pack')) {
413+
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/elastic-license-header.txt')
414+
} else {
415+
licenseHeaderFile = new File(project.rootDir, 'buildSrc/src/main/resources/license-headers/oss-license-header.txt')
416+
}
417+
String licenseHeader = licenseHeaderFile.getText('UTF-8').replace('\n', '\\\\n')
407418
task copyEclipseSettings(type: Copy) {
408419
// TODO: "package this up" for external builds
409420
from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings')
410421
into '.settings'
422+
filter{ it.replaceAll('@@LICENSE_HEADER_TEXT@@', licenseHeader)}
411423
}
412424
// otherwise .settings is not nuked entirely
413425
task wipeEclipseSettings(type: Delete) {
@@ -459,6 +471,59 @@ gradle.projectsEvaluated {
459471

460472
}
461473

474+
static void assertLinesInFile(final Path path, final List<String> expectedLines) {
475+
final List<String> actualLines = Files.readAllLines(path)
476+
int line = 0
477+
for (final String expectedLine : expectedLines) {
478+
final String actualLine = actualLines.get(line)
479+
if (expectedLine != actualLine) {
480+
throw new GradleException("expected line [${line + 1}] in [${path}] to be [${expectedLine}] but was [${actualLine}]")
481+
}
482+
line++
483+
}
484+
}
485+
486+
/*
487+
* Check that all generated JARs have our NOTICE.txt and an appropriate
488+
* LICENSE.txt in them. We configurate this in gradle but we'd like to
489+
* be extra paranoid.
490+
*/
491+
subprojects { project ->
492+
project.tasks.withType(Jar).whenTaskAdded { jarTask ->
493+
final Task extract = project.task("extract${jarTask.name.capitalize()}", type: LoggedExec) {
494+
dependsOn jarTask
495+
ext.destination = project.buildDir.toPath().resolve("jar-extracted/${jarTask.name}")
496+
commandLine "${->new File(rootProject.compilerJavaHome, 'bin/jar')}",
497+
'xf', "${-> jarTask.outputs.files.singleFile}", 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'
498+
workingDir destination
499+
doFirst {
500+
project.delete(destination)
501+
Files.createDirectories(destination)
502+
}
503+
}
504+
505+
final Task checkNotice = project.task("verify${jarTask.name.capitalize()}Notice") {
506+
dependsOn extract
507+
doLast {
508+
final List<String> noticeLines = Files.readAllLines(project.noticeFile.toPath())
509+
final Path noticePath = extract.destination.resolve('META-INF/NOTICE.txt')
510+
assertLinesInFile(noticePath, noticeLines)
511+
}
512+
}
513+
project.check.dependsOn checkNotice
514+
515+
final Task checkLicense = project.task("verify${jarTask.name.capitalize()}License") {
516+
dependsOn extract
517+
doLast {
518+
final List<String> licenseLines = Files.readAllLines(project.licenseFile.toPath())
519+
final Path licensePath = extract.destination.resolve('META-INF/LICENSE.txt')
520+
assertLinesInFile(licensePath, licenseLines)
521+
}
522+
}
523+
project.check.dependsOn checkLicense
524+
}
525+
}
526+
462527
/* Remove assemble on all qa projects because we don't need to publish
463528
* artifacts for them. */
464529
gradle.projectsEvaluated {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ClusterConfiguration {
6464
boolean debug = false
6565

6666
/**
67-
* Configuration of the setting <tt>discovery.zen.minimum_master_nodes</tt> on the nodes.
67+
* Configuration of the setting {@code discovery.zen.minimum_master_nodes} on the nodes.
6868
* In case of more than one node, this defaults to the number of nodes
6969
*/
7070
@Input

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,17 @@ class ClusterFormationTasks {
563563

564564
/** Adds a task to execute a command to help setup the cluster */
565565
static Task configureExecTask(String name, Project project, Task setup, NodeInfo node, Object[] execArgs) {
566-
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) {
567-
workingDir node.cwd
566+
return project.tasks.create(name: name, type: LoggedExec, dependsOn: setup) { Exec exec ->
567+
exec.workingDir node.cwd
568+
exec.environment 'JAVA_HOME', node.getJavaHome()
568569
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
569-
executable 'cmd'
570-
args '/C', 'call'
570+
exec.executable 'cmd'
571+
exec.args '/C', 'call'
571572
// On Windows the comma character is considered a parameter separator:
572573
// argument are wrapped in an ExecArgWrapper that escapes commas
573-
args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
574+
exec.args execArgs.collect { a -> new EscapeCommaWrapper(arg: a) }
574575
} else {
575-
commandLine execArgs
576+
exec.commandLine execArgs
576577
}
577578
}
578579
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantPropertiesExtension.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class VagrantPropertiesExtension {
4141
@Input
4242
Boolean inheritTestUtils
4343

44+
@Input
45+
String testClass
46+
4447
VagrantPropertiesExtension(List<String> availableBoxes) {
4548
this.boxes = availableBoxes
4649
this.batsDir = 'src/test/resources/packaging'

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@ class VagrantTestPlugin implements Plugin<Project> {
3737
'ubuntu-1404',
3838
]
3939

40-
/** All onboarded archives by default, available for Bats tests even if not used **/
41-
static List<String> DISTRIBUTION_ARCHIVES = ['tar', 'rpm', 'deb', 'oss-rpm', 'oss-deb']
40+
/** All distributions to bring into test VM, whether or not they are used **/
41+
static List<String> DISTRIBUTIONS = [
42+
'archives:tar',
43+
'archives:oss-tar',
44+
'packages:rpm',
45+
'packages:oss-rpm',
46+
'packages:deb',
47+
'packages:oss-deb'
48+
]
4249

4350
/** Packages onboarded for upgrade tests **/
4451
static List<String> UPGRADE_FROM_ARCHIVES = ['rpm', 'deb']
4552

4653
private static final PACKAGING_CONFIGURATION = 'packaging'
54+
private static final PACKAGING_TEST_CONFIGURATION = 'packagingTest'
4755
private static final BATS = 'bats'
4856
private static final String BATS_TEST_COMMAND ="cd \$PACKAGING_ARCHIVES && sudo bats --tap \$BATS_TESTS/*.$BATS"
4957
private static final String PLATFORM_TEST_COMMAND ="rm -rf ~/elasticsearch && rsync -r /elasticsearch/ ~/elasticsearch && cd ~/elasticsearch && ./gradlew test integTest"
@@ -59,6 +67,7 @@ class VagrantTestPlugin implements Plugin<Project> {
5967

6068
// Creates custom configurations for Bats testing files (and associated scripts and archives)
6169
createPackagingConfiguration(project)
70+
project.configurations.create(PACKAGING_TEST_CONFIGURATION)
6271

6372
// Creates all the main Vagrant tasks
6473
createVagrantTasks(project)
@@ -117,13 +126,8 @@ class VagrantTestPlugin implements Plugin<Project> {
117126
upgradeFromVersion = Version.fromString(upgradeFromVersionRaw)
118127
}
119128

120-
DISTRIBUTION_ARCHIVES.each {
129+
DISTRIBUTIONS.each {
121130
// Adds a dependency for the current version
122-
if (it == 'tar') {
123-
it = 'archives:tar'
124-
} else {
125-
it = "packages:${it}"
126-
}
127131
project.dependencies.add(PACKAGING_CONFIGURATION,
128132
project.dependencies.project(path: ":distribution:${it}", configuration: 'default'))
129133
}
@@ -142,10 +146,12 @@ class VagrantTestPlugin implements Plugin<Project> {
142146
}
143147

144148
private static void createCleanTask(Project project) {
145-
project.tasks.create('clean', Delete.class) {
146-
description 'Clean the project build directory'
147-
group 'Build'
148-
delete project.buildDir
149+
if (project.tasks.findByName('clean') == null) {
150+
project.tasks.create('clean', Delete.class) {
151+
description 'Clean the project build directory'
152+
group 'Build'
153+
delete project.buildDir
154+
}
149155
}
150156
}
151157

@@ -172,6 +178,18 @@ class VagrantTestPlugin implements Plugin<Project> {
172178
from project.configurations[PACKAGING_CONFIGURATION]
173179
}
174180

181+
File testsDir = new File(packagingDir, 'tests')
182+
Copy copyPackagingTests = project.tasks.create('copyPackagingTests', Copy) {
183+
into testsDir
184+
from project.configurations[PACKAGING_TEST_CONFIGURATION]
185+
}
186+
187+
Task createTestRunnerScript = project.tasks.create('createTestRunnerScript', FileContentsTask) {
188+
dependsOn copyPackagingTests
189+
file "${testsDir}/run-tests.sh"
190+
contents "java -cp \"\$PACKAGING_TESTS/*\" org.junit.runner.JUnitCore ${-> project.extensions.esvagrant.testClass}"
191+
}
192+
175193
Task createVersionFile = project.tasks.create('createVersionFile', FileContentsTask) {
176194
dependsOn copyPackagingArchives
177195
file "${archivesDir}/version"
@@ -232,7 +250,8 @@ class VagrantTestPlugin implements Plugin<Project> {
232250

233251
Task vagrantSetUpTask = project.tasks.create('setupPackagingTest')
234252
vagrantSetUpTask.dependsOn 'vagrantCheckVersion'
235-
vagrantSetUpTask.dependsOn copyPackagingArchives, createVersionFile, createUpgradeFromFile, createUpgradeIsOssFile
253+
vagrantSetUpTask.dependsOn copyPackagingArchives, copyPackagingTests, createTestRunnerScript
254+
vagrantSetUpTask.dependsOn createVersionFile, createUpgradeFromFile, createUpgradeIsOssFile
236255
vagrantSetUpTask.dependsOn copyBatsTests, copyBatsUtils
237256
}
238257

@@ -391,20 +410,29 @@ class VagrantTestPlugin implements Plugin<Project> {
391410
packagingTest.dependsOn(batsPackagingTest)
392411
}
393412

394-
// This task doesn't do anything yet. In the future it will execute a jar containing tests on the vm
395-
Task groovyPackagingTest = project.tasks.create("vagrant${boxTask}#groovyPackagingTest")
396-
groovyPackagingTest.dependsOn(up)
397-
groovyPackagingTest.finalizedBy(halt)
413+
Task javaPackagingTest = project.tasks.create("vagrant${boxTask}#javaPackagingTest", VagrantCommandTask) {
414+
command 'ssh'
415+
boxName box
416+
environmentVars vagrantEnvVars
417+
dependsOn up, setupPackagingTest
418+
finalizedBy halt
419+
args '--command', "bash \"\$PACKAGING_TESTS/run-tests.sh\""
420+
}
421+
422+
// todo remove this onlyIf after all packaging tests are consolidated
423+
javaPackagingTest.onlyIf {
424+
project.extensions.esvagrant.testClass != null
425+
}
398426

399-
TaskExecutionAdapter groovyPackagingReproListener = createReproListener(project, groovyPackagingTest.path)
400-
groovyPackagingTest.doFirst {
401-
project.gradle.addListener(groovyPackagingReproListener)
427+
TaskExecutionAdapter javaPackagingReproListener = createReproListener(project, javaPackagingTest.path)
428+
javaPackagingTest.doFirst {
429+
project.gradle.addListener(javaPackagingReproListener)
402430
}
403-
groovyPackagingTest.doLast {
404-
project.gradle.removeListener(groovyPackagingReproListener)
431+
javaPackagingTest.doLast {
432+
project.gradle.removeListener(javaPackagingReproListener)
405433
}
406434
if (project.extensions.esvagrant.boxes.contains(box)) {
407-
packagingTest.dependsOn(groovyPackagingTest)
435+
packagingTest.dependsOn(javaPackagingTest)
408436
}
409437

410438
Task platform = project.tasks.create("vagrant${boxTask}#platformTest", VagrantCommandTask) {

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@
535535
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]gateway[/\\]ReplicaShardAllocatorTests.java" checks="LineLength" />
536536
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]gateway[/\\]ReusePeerRecoverySharedTest.java" checks="LineLength" />
537537
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]get[/\\]GetActionIT.java" checks="LineLength" />
538-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]IndexServiceTests.java" checks="LineLength" />
539538
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]IndexingSlowLogTests.java" checks="LineLength" />
540539
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]MergePolicySettingsTests.java" checks="LineLength" />
541540
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]SearchSlowLogTests.java" checks="LineLength" />

0 commit comments

Comments
 (0)