Skip to content

Commit ba89251

Browse files
committed
[Linux] Fix random test failures of browser tests #1523
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
1 parent 4a201e2 commit ba89251

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

+19-8
Original file line numberDiff line numberDiff line change
@@ -2847,14 +2847,8 @@ private static Set<Entry<String, String>> getPropertiesSafe() {
28472847
private static List<String> getOpenedDescriptors() {
28482848
List<String> paths = new ArrayList<>();
28492849
Path fd = Paths.get("/proc/self/fd/");
2850-
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
2851-
directoryStream.forEach(f -> {
2852-
try {
2853-
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
2854-
} catch (IOException e) {
2855-
e.printStackTrace();
2856-
}
2857-
});
2850+
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd, path -> isTestRelatedFileDescriptor(path))) {
2851+
directoryStream.forEach(path-> paths.add(resolveSymLink(path)));
28582852
} catch (IOException e1) {
28592853
e1.printStackTrace();
28602854
}
@@ -2866,6 +2860,23 @@ private static List<String> getOpenedDescriptors() {
28662860
}
28672861

28682862

2863+
private static boolean isTestRelatedFileDescriptor(Path fileDescriptorPath) {
2864+
// Do not consider file descriptors of Maven artifacts that are currently opened
2865+
// by other Maven plugins executed in parallel build (such as parallel
2866+
// compilation of the swt.tools bundle etc.)
2867+
String resolvedPath = resolveSymLink(fileDescriptorPath);
2868+
return resolvedPath != null && !resolvedPath.contains(".m2") && !resolvedPath.contains("target/classes");
2869+
}
2870+
2871+
private static String resolveSymLink(Path path) {
2872+
try {
2873+
return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toString() : path.toString();
2874+
} catch (IOException e) {
2875+
e.printStackTrace();
2876+
}
2877+
return null;
2878+
}
2879+
28692880
private static void processUiEvents() {
28702881
Display display = Display.getCurrent();
28712882
while (display != null && !display.isDisposed() && display.readAndDispatch()) {

0 commit comments

Comments
 (0)