Skip to content

Commit 775fbd2

Browse files
johnolivertrask
andauthored
Attempt to fix unreliable diagnostics tests (#3135)
Co-authored-by: Trask Stalnaker <[email protected]>
1 parent cd5d2c3 commit 775fbd2

File tree

1 file changed

+25
-16
lines changed
  • smoke-tests/apps/Diagnostics/src/main/java/com/microsoft/applicationinsights/smoketestapp

1 file changed

+25
-16
lines changed

smoke-tests/apps/Diagnostics/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.java

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,35 @@ public String root() {
2424
public String jfrFileHasDiagnostics() throws Exception {
2525
Optional<Path> jfrFile;
2626
for (int i = 0; i < 60; i++) {
27+
try {
28+
jfrFile =
29+
Files.walk(new File("/tmp/root/applicationinsights").toPath())
30+
.filter(Files::isRegularFile)
31+
.filter(it -> it.toFile().getName().contains(".jfr"))
32+
.findFirst();
2733

28-
jfrFile =
29-
Files.walk(new File("/tmp/root/applicationinsights").toPath())
30-
.filter(Files::isRegularFile)
31-
.filter(it -> it.toFile().getName().contains(".jfr"))
32-
.findFirst();
33-
34-
if (!jfrFile.isPresent()) {
35-
Thread.sleep(1000, 0);
36-
continue;
37-
}
34+
if (!jfrFile.isPresent()) {
35+
Thread.sleep(1000, 0);
36+
continue;
37+
}
3838

39-
Path decompressedFile = decompressFile(jfrFile.get());
39+
Path decompressedFile = decompressFile(jfrFile.get());
4040

41-
boolean hasTelemetry =
42-
com.microsoft.applicationinsights.jfrfile.JfrFileReader.hasEventOfType(
43-
decompressedFile, "com.microsoft.applicationinsights.diagnostics.jfr.Telemetry");
41+
boolean hasTelemetry =
42+
com.microsoft.applicationinsights.jfrfile.JfrFileReader.hasEventOfType(
43+
decompressedFile, "com.microsoft.applicationinsights.diagnostics.jfr.Telemetry");
4444

45-
if (hasTelemetry) {
46-
return String.valueOf(true);
45+
if (hasTelemetry) {
46+
return String.valueOf(true);
47+
}
48+
} catch (Exception e) {
49+
// Ignore early exceptions, as to be expected, throw them if they are still happening
50+
// towards the end
51+
if (i > 55) {
52+
throw e;
53+
} else {
54+
Thread.sleep(1000, 0);
55+
}
4756
}
4857
}
4958

0 commit comments

Comments
 (0)