Skip to content

Commit eac72e2

Browse files
committed
Renes build changes
breskeby@2834ec0
1 parent 3725bbf commit eac72e2

File tree

2 files changed

+80
-36
lines changed

2 files changed

+80
-36
lines changed

x-pack/qa/repository-old-versions/build.gradle

Lines changed: 63 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams
1313
import org.elasticsearch.gradle.internal.test.AntFixture
1414
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
1515
import org.elasticsearch.gradle.transform.UnzipTransform
16+
1617
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
1718

1819
apply plugin: 'elasticsearch.jdk-download'
@@ -67,7 +68,7 @@ if (OS.current() == OS.WINDOWS) {
6768

6869
int currentMajorVersion = org.elasticsearch.gradle.VersionProperties.elasticsearchVersion.major
6970
assert (currentMajorVersion - 2) == 7 : "add archive BWC tests for major version " + (currentMajorVersion - 2)
70-
for (String versionString : ['5.0.0', '5.6.16', '6.0.0', '6.8.23', '7.0.0', '7.17.25']) {
71+
for (String versionString : ['5.0.0', '5.6.16', '6.0.0', '6.8.23', '7.17.25']) {
7172
Version version = Version.fromString(versionString)
7273
String packageName = 'org.elasticsearch.distribution.zip'
7374
String artifact = "${packageName}:elasticsearch:${version}@zip"
@@ -96,41 +97,59 @@ if (OS.current() == OS.WINDOWS) {
9697
setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB'
9798
}
9899

99-
TaskProvider<AntFixture> fixture = tasks.register("oldES${versionNoDots}Fixture", AntFixture) {
100-
dependsOn project.configurations.oldesFixture, jdks.legacy, config
101-
executable = "${BuildParams.runtimeJavaHome}/bin/java"
102-
env 'CLASSPATH', "${-> project.configurations.oldesFixture.asPath}"
103-
// old versions of Elasticsearch need JAVA_HOME
104-
env 'JAVA_HOME', jdks.legacy.javaHomePath
105-
// If we are running on certain arm systems we need to explicitly set the stack size to overcome JDK page size bug
106-
if (Architecture.current() == Architecture.AARCH64) {
107-
env 'ES_JAVA_OPTS', '-Xss512k'
108-
}
109-
def dataPath = "${baseDir}/data"
110-
args 'oldes.OldElasticsearch',
111-
baseDir,
112-
"${ -> config.getSingleFile().toPath()}",
113-
false,
114-
"path.repo: ${repoLocation}",
115-
"path.data: ${dataPath}"
116-
if ((version.onOrAfter('6.8.0') && Architecture.current() == Architecture.AARCH64) || (version.onOrAfter("6.4.0") && BwcVersions.isMlCompatible(version) == false)) {
117-
// We need to explicitly disable ML when running old ES versions on ARM or on systems with newer GLIBC
118-
args 'xpack.ml.enabled: false'
119-
}
120-
doFirst {
121-
delete(dataPath)
122-
mkdir(dataPath)
100+
if(version.onOrAfter('7.0.0')) {
101+
def oldCluster = testClusters.register("oldES${versionNoDots}Cluster") {
102+
testDistribution = 'DEFAULT'
103+
numberOfNodes = 1
104+
versions = [versionString]
105+
setting 'path.repo', repoLocation, IGNORE_VALUE
106+
setting 'xpack.license.self_generated.type', 'trial'
107+
setting 'xpack.security.enabled', 'true'
108+
user username: 'admin', password: 'admin-password', role: 'superuser'
109+
setting 'xpack.searchable.snapshot.shared_cache.size', '16MB'
110+
setting 'xpack.searchable.snapshot.shared_cache.region_size', '256KB'
123111
}
124-
maxWaitInSeconds 60
125-
waitCondition = { fixture, ant ->
126-
// the fixture writes the ports file when Elasticsearch's HTTP service
127-
// is ready, so we can just wait for the file to exist
128-
return fixture.portsFile.exists()
112+
} else {
113+
TaskProvider<AntFixture> fixture = tasks.register("oldES${versionNoDots}Fixture", AntFixture) {
114+
dependsOn project.configurations.oldesFixture, jdks.legacy, config
115+
executable = "${BuildParams.runtimeJavaHome}/bin/java"
116+
env 'CLASSPATH', "${-> project.configurations.oldesFixture.asPath}"
117+
// old versions of Elasticsearch need JAVA_HOME
118+
env 'JAVA_HOME', jdks.legacy.javaHomePath
119+
// If we are running on certain arm systems we need to explicitly set the stack size to overcome JDK page size bug
120+
if (Architecture.current() == Architecture.AARCH64) {
121+
env 'ES_JAVA_OPTS', '-Xss512k'
122+
}
123+
def dataPath = "${baseDir}/data"
124+
args 'oldes.OldElasticsearch',
125+
baseDir,
126+
"${-> config.getSingleFile().toPath()}",
127+
false,
128+
"path.repo: ${repoLocation}",
129+
"path.data: ${dataPath}"
130+
if ((version.onOrAfter('6.8.0') && Architecture.current() == Architecture.AARCH64) || (version.onOrAfter("6.4.0") && BwcVersions.isMlCompatible(version) == false)) {
131+
// We need to explicitly disable ML when running old ES versions on ARM or on systems with newer GLIBC
132+
args 'xpack.ml.enabled: false'
133+
}
134+
doFirst {
135+
delete(dataPath)
136+
mkdir(dataPath)
137+
}
138+
maxWaitInSeconds 60
139+
waitCondition = { fixture, ant ->
140+
// the fixture writes the ports file when Elasticsearch's HTTP service
141+
// is ready, so we can just wait for the file to exist
142+
return fixture.portsFile.exists()
143+
}
129144
}
130145
}
131146

132147
tasks.register("javaRestTestBeforeRestart#${versionNoDots}", StandaloneRestIntegTestTask) {
133-
useCluster testClusterProvider
148+
if(version.onOrAfter('7.0.0')) {
149+
useCluster testClusters.named("oldES${versionNoDots}Cluster")
150+
} else {
151+
dependsOn tasks.named("oldES${versionNoDots}Fixture")
152+
}
134153
dependsOn fixture
135154
doFirst {
136155
delete(repoLocation)
@@ -151,13 +170,25 @@ if (OS.current() == OS.WINDOWS) {
151170
}
152171

153172
tasks.matching { it.name.startsWith("javaRestTest") && it.name.endsWith(versionNoDots) }.configureEach {
173+
doFirst {
174+
def oldClusterPortProvider = testClusters.named("oldES${versionNoDots}Cluster").map { cluster ->
175+
def local = cluster.allHttpSocketURI.find { it.startsWith("127.0.0.1")}
176+
return local.substring(local.lastIndexOf(':') + 1)
177+
}
178+
it.nonInputProperties.systemProperty "tests.es.port", "${-> oldClusterPortProvider.get()}"
179+
println "oldClusterPortProvider " + oldClusterPortProvider.get()
180+
println "allRemoteAccessPortURI " + testClusters.named("oldES${versionNoDots}Cluster").get().allRemoteAccessPortURI
181+
println "allHttpSocketURI " + testClusters.named("oldES${versionNoDots}Cluster").get().allHttpSocketURI
182+
println "httpSocketURI " + testClusters.named("oldES${versionNoDots}Cluster").get().httpSocketURI
183+
}
154184
it.nonInputProperties.systemProperty "tests.repo.location", repoLocation
155185
it.systemProperty "tests.es.version", version.toString()
156186

157187
/* Use a closure on the string to delay evaluation until right before we
158188
* run the integration tests so that we can be sure that the file is
159189
* ready. */
160-
it.nonInputProperties.systemProperty "tests.es.port", "${-> fixture.get().addressAndPort}"
190+
//it.nonInputProperties.systemProperty "tests.es.port", "${-> fixture.get().addressAndPort}"
191+
// it.nonInputProperties.systemProperty "tests.es.port", "${-> testClusters.named("oldES${versionNoDots}Cluster").get().allRemoteAccessPortURI.join(',')}"
161192
it.nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusterProvider.get().allHttpSocketURI.join(",")}")
162193
it.nonInputProperties.systemProperty('tests.clustername', "${-> testClusterProvider.get().getName()}")
163194
}

x-pack/qa/repository-old-versions/src/test/java/org/elasticsearch/oldrepos/OldMappingsIT.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
import com.carrotsearch.randomizedtesting.RandomizedTest;
1111

12+
import org.apache.http.Header;
1213
import org.apache.http.HttpHost;
14+
import org.apache.http.message.BasicHeader;
1315
import org.elasticsearch.Version;
1416
import org.elasticsearch.client.Request;
1517
import org.elasticsearch.client.RequestOptions;
@@ -84,10 +86,8 @@ public void setupIndex() throws IOException {
8486
indices = Arrays.asList("filebeat", "custom", "nested");
8587
}
8688

87-
int oldEsPort = Integer.parseInt(System.getProperty("tests.es.port"));
88-
try (RestClient oldEs = RestClient.builder(new HttpHost("127.0.0.1", oldEsPort)).build()) {
89-
90-
assertOK(oldEs.performRequest(createIndex("filebeat", "filebeat.json")));
89+
try (RestClient oldEs = createOldESClient()) {
90+
// assertOK(oldEs.performRequest(createIndex("filebeat", "filebeat.json")));
9191
if (oldVersion.before(Version.fromString("6.0.0"))) {
9292
assertOK(oldEs.performRequest(createIndex("winlogbeat", "winlogbeat.json")));
9393
}
@@ -169,6 +169,19 @@ public void setupIndex() throws IOException {
169169
assertOK(client().performRequest(createRestoreRequest));
170170
}
171171

172+
private RestClient createOldESClient() {
173+
int oldEsPort = Integer.parseInt(System.getProperty("tests.es.port"));
174+
// System.out.println("oldEsPort = " + oldEsPort);
175+
Settings settings = restClientSettings();
176+
Map<String, String> headers = ThreadContext.buildDefaultHeaders(settings);
177+
Header[] defaultHeaders = new Header[headers.size()];
178+
int i = 0;
179+
for (Map.Entry<String, String> entry : headers.entrySet()) {
180+
defaultHeaders[i++] = new BasicHeader(entry.getKey(), entry.getValue());
181+
}
182+
return RestClient.builder(new HttpHost("127.0.0.1", oldEsPort)).setDefaultHeaders(defaultHeaders).build();
183+
}
184+
172185
private Request createIndex(String indexName, String file) throws IOException {
173186
Request createIndex = new Request("PUT", "/" + indexName);
174187
int numberOfShards = randomIntBetween(1, 3);

0 commit comments

Comments
 (0)