Skip to content

Commit 365da1e

Browse files
committed
Fix secure repository-hdfs tests on JDK 9
The secure repository-hdfs tests fail on JDK 9 because some Hadoop code reaches into sun.security.krb5. This commit adds the necessary flags to open the java.security.jgss module. Note that these flags are actually needed at runtime as well when using secure repository-hdfs. For now we will punt on how best to help users obtain this when running on JDK 9 with this plugin. Relates #25205
1 parent d54c667 commit 365da1e

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

plugins/repository-hdfs/build.gradle

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,18 @@ task secureHdfsFixture(type: org.elasticsearch.gradle.test.AntFixture) {
119119
Path keytabPath = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs").resolve("hdfs_hdfs.build.elastic.co.keytab")
120120
Path krb5Config = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("conf").resolve("krb5.conf")
121121

122-
args "-Djava.security.krb5.conf=${krb5Config}", 'hdfs.MiniHDFS',
123-
baseDir,
124-
"hdfs/hdfs.build.elastic.co@${realm}",
125-
"${keytabPath}"
122+
final List<String> miniHDFSArgs = ["-Djava.security.krb5.conf=${krb5Config}"]
123+
124+
if (project.rootProject.ext.javaVersion == JavaVersion.VERSION_1_9) {
125+
miniHDFSArgs.add('--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED')
126+
}
127+
128+
miniHDFSArgs.add('hdfs.MiniHDFS')
129+
miniHDFSArgs.add(baseDir)
130+
miniHDFSArgs.add("hdfs/hdfs.build.elastic.co@${realm}")
131+
miniHDFSArgs.add("${keytabPath}")
132+
133+
args miniHDFSArgs.toArray()
126134
}
127135

128136
boolean fixtureSupported = false;
@@ -189,10 +197,19 @@ if (secureFixtureSupported && false) { // This fails due to a vagrant configurat
189197
project.integTestSecureCluster.dependsOn(project.bundlePlugin)
190198
project.integTestSecure.clusterConfig.plugin(project.path)
191199
project.integTestSecure.clusterConfig.extraConfigFile("repository-hdfs/krb5.keytab", "${elasticsearchKT}")
192-
project.integTestSecure.clusterConfig.jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
200+
201+
final String baseJvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
193202
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +
194203
" " + "-Djava.security.krb5.conf=${krb5conf}" +
195204
" " + System.getProperty('tests.jvm.argline', '')
205+
final String jvmArgs
206+
if (project.rootProject.ext.javaVersion == JavaVersion.VERSION_1_9) {
207+
jvmArgs = baseJvmArgs + " " + '--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
208+
} else {
209+
jvmArgs = baseJvmArgs
210+
}
211+
212+
project.integTestSecure.clusterConfig.jvmArgs = jvmArgs
196213
}
197214

198215
RestIntegTestTask integTestSecure = project.tasks.create('integTestSecure', RestIntegTestTask.class) {

0 commit comments

Comments
 (0)