|
17 | 17 | * under the License.
|
18 | 18 | */
|
19 | 19 |
|
| 20 | +import org.apache.tools.ant.taskdefs.condition.Os |
| 21 | + |
| 22 | +import static org.elasticsearch.gradle.BuildPlugin.getJavaHome |
| 23 | + |
20 | 24 | apply plugin: 'elasticsearch.test-with-dependencies'
|
21 | 25 |
|
22 | 26 | esplugin {
|
@@ -60,3 +64,61 @@ thirdPartyAudit.excludes = [
|
60 | 64 | 'org.apache.log.Hierarchy',
|
61 | 65 | 'org.apache.log.Logger',
|
62 | 66 | ]
|
| 67 | + |
| 68 | +// Support for testing reindex-from-remote against old Elaticsearch versions |
| 69 | +configurations { |
| 70 | + oldesFixture |
| 71 | + es2 |
| 72 | + es1 |
| 73 | + es090 |
| 74 | +} |
| 75 | + |
| 76 | +dependencies { |
| 77 | + oldesFixture project(':test:fixtures:old-elasticsearch') |
| 78 | + /* Right now we just test against the latest version of each major we expect |
| 79 | + * reindex-from-remote to work against. We could randomize the versions but |
| 80 | + * that doesn't seem worth it at this point. */ |
| 81 | + es2 'org.elasticsearch.distribution.zip:elasticsearch:2.4.5@zip' |
| 82 | + es1 'org.elasticsearch:elasticsearch:1.7.6@zip' |
| 83 | + es090 'org.elasticsearch:elasticsearch:0.90.13@zip' |
| 84 | +} |
| 85 | + |
| 86 | +if (Os.isFamily(Os.FAMILY_WINDOWS)) { |
| 87 | + // we can't get the pid files in windows so we skip reindex-from-old |
| 88 | + integTestRunner.systemProperty "tests.fromOld", "false" |
| 89 | +} else { |
| 90 | + integTestRunner.systemProperty "tests.fromOld", "true" |
| 91 | + /* Set up tasks to unzip and run the old versions of ES before running the |
| 92 | + * integration tests. */ |
| 93 | + for (String version : ['2', '1', '090']) { |
| 94 | + Task unzip = task("unzipEs${version}", type: Sync) { |
| 95 | + Configuration oldEsDependency = configurations['es' + version] |
| 96 | + dependsOn oldEsDependency |
| 97 | + /* Use a closure here to delay resolution of the dependency until we need |
| 98 | + * it */ |
| 99 | + from { |
| 100 | + oldEsDependency.collect { zipTree(it) } |
| 101 | + } |
| 102 | + into temporaryDir |
| 103 | + } |
| 104 | + Task fixture = task("oldEs${version}Fixture", |
| 105 | + type: org.elasticsearch.gradle.test.AntFixture) { |
| 106 | + dependsOn project.configurations.oldesFixture |
| 107 | + dependsOn unzip |
| 108 | + executable = new File(project.runtimeJavaHome, 'bin/java') |
| 109 | + env 'CLASSPATH', "${ -> project.configurations.oldesFixture.asPath }" |
| 110 | + env 'JAVA_HOME', getJavaHome(it, 7) |
| 111 | + args 'oldes.OldElasticsearch', |
| 112 | + baseDir, |
| 113 | + unzip.temporaryDir, |
| 114 | + version == '090' |
| 115 | + } |
| 116 | + integTest.dependsOn fixture |
| 117 | + integTestRunner { |
| 118 | + /* Use a closure on the string to delay evaluation until right before we |
| 119 | + * run the integration tests so that we can be sure that the file is |
| 120 | + * ready. */ |
| 121 | + systemProperty "es${version}.port", "${ -> fixture.addressAndPort }" |
| 122 | + } |
| 123 | + } |
| 124 | +} |
0 commit comments