Skip to content

Commit 912fbb2

Browse files
authored
Reindex: Fold "from old" tests into reindex module (#30142)
This folds the `:qa:reindex-from-old` project into the `:modules:reindex` project. This should speed up the build marginally by removing a single clsuter start up at the cost of having to wait for old versions of Elasticsearch to start up when checking reindex's integration tests. Those don't take that long so this feels worth it.
1 parent d633130 commit 912fbb2

File tree

3 files changed

+67
-95
lines changed

3 files changed

+67
-95
lines changed

modules/reindex/build.gradle

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
* under the License.
1818
*/
1919

20+
import org.apache.tools.ant.taskdefs.condition.Os
21+
22+
import static org.elasticsearch.gradle.BuildPlugin.getJavaHome
23+
2024
apply plugin: 'elasticsearch.test-with-dependencies'
2125

2226
esplugin {
@@ -60,3 +64,61 @@ thirdPartyAudit.excludes = [
6064
'org.apache.log.Hierarchy',
6165
'org.apache.log.Logger',
6266
]
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+
}

qa/reindex-from-old/src/test/java/org/elasticsearch/smoketest/ReindexFromOldRemoteIT.java renamed to modules/reindex/src/test/java/org/elasticsearch/index/reindex/remote/ReindexFromOldRemoteIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.smoketest;
20+
package org.elasticsearch.index.reindex.remote;
2121

2222
import org.apache.http.HttpEntity;
2323
import org.apache.http.HttpHost;
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.client.Response;
2828
import org.elasticsearch.client.ResponseException;
2929
import org.elasticsearch.client.RestClient;
30+
import org.elasticsearch.common.Booleans;
3031
import org.elasticsearch.test.rest.ESRestTestCase;
3132

3233
import java.io.IOException;
@@ -38,6 +39,9 @@
3839

3940
public class ReindexFromOldRemoteIT extends ESRestTestCase {
4041
private void oldEsTestCase(String portPropertyName, String requestsPerSecond) throws IOException {
42+
boolean enabled = Booleans.parseBoolean(System.getProperty("tests.fromOld"));
43+
assumeTrue("test is disabled, probably because this is windows", enabled);
44+
4145
int oldEsPort = Integer.parseInt(System.getProperty(portPropertyName));
4246
try (RestClient oldEs = RestClient.builder(new HttpHost("127.0.0.1", oldEsPort)).build()) {
4347
try {

qa/reindex-from-old/build.gradle

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

0 commit comments

Comments
 (0)