Skip to content

Commit 467fe8d

Browse files
authored
Fallback to working dir for native lib dir in tests (#133422)
When finding the platform dir to pass to jna we check for system properties which are either set by internal test gradle code or or the cli shell script. If neither of thse are set, we are in test code for an external plugin. This commit fixes the code to use the working dir in this fallback case. Previously we would have created a bogus path. Both are the same: external plugin tests can't load ES native libs since they don't have them available.
1 parent a314fe6 commit 467fe8d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libs/native/src/main/java/org/elasticsearch/nativeaccess/lib/LoaderHelper.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ private static Path findPlatformLibDir() {
2626
return Paths.get(path);
2727
}
2828

29-
Path homeDir = Paths.get(System.getProperty("es.path.home"));
29+
String homeDirPath = System.getProperty("es.path.home");
30+
if (homeDirPath == null) {
31+
// if we don't have the native libs passed in for tests, and we don't have the home dir set
32+
// then we must be in a test for an external plugin. there's nothing we can do to get the
33+
// native libs, they don't exist, so just return the working dir, it will fail if the test
34+
// actually tries to load a library
35+
return Paths.get("");
36+
}
37+
38+
Path homeDir = Paths.get(homeDirPath);
3039
Path platformDir = homeDir.resolve("lib/platform");
3140

3241
String osname = System.getProperty("os.name");

0 commit comments

Comments
 (0)