Skip to content

Commit

Permalink
[Linux] Fix random test failures of browser tests #1523
Browse files Browse the repository at this point in the history
Browser tests randomly fail during Jenkins execution because of too many
opened file descriptors. The reason seems to be that the build uses
parallel execution and Maven plugins executed for other bundles may have
opened and closed file descriptors in parallel, which are erroneously
taken into account by the browser tests evaluating the number of file
descriptors left open after a test execution.

This change excludes open file descriptors for Maven artifacts used in
parallel by other Maven plugins by not considering file descriptors with
their path containing ".m2" or "target/classes".

Fixes #1523
  • Loading branch information
HeikoKlare committed Feb 3, 2025
1 parent 4a201e2 commit f19242f
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2847,12 +2847,11 @@ private static Set<Entry<String, String>> getPropertiesSafe() {
private static List<String> getOpenedDescriptors() {
List<String> paths = new ArrayList<>();
Path fd = Paths.get("/proc/self/fd/");
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
directoryStream.forEach(f -> {
try {
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
} catch (IOException e) {
e.printStackTrace();
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)) {
directoryStream.forEach(path -> {
String resolvedPath = resolveSymLink(path);
if (isTestRelatedFileDescriptor(resolvedPath)) {
paths.add(resolvedPath);
}
});
} catch (IOException e1) {
Expand All @@ -2865,6 +2864,22 @@ private static List<String> getOpenedDescriptors() {
return paths;
}

private static boolean isTestRelatedFileDescriptor(String fileDescriptorPath) {
// Do not consider file descriptors of Maven artifacts that are currently opened
// by other Maven plugins executed in parallel build (such as parallel
// compilation of the swt.tools bundle etc.)
return fileDescriptorPath != null && !fileDescriptorPath.contains(".m2")
&& !fileDescriptorPath.contains("target/classes");
}

private static String resolveSymLink(Path path) {
try {
return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toString() : path.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

private static void processUiEvents() {
Display display = Display.getCurrent();
Expand Down

0 comments on commit f19242f

Please sign in to comment.