Skip to content

Commit

Permalink
Attempt to fix unreliable diagnostics tests (#3135)
Browse files Browse the repository at this point in the history
Co-authored-by: Trask Stalnaker <[email protected]>
  • Loading branch information
johnoliver and trask authored Jun 19, 2023
1 parent cd5d2c3 commit 775fbd2
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,35 @@ public String root() {
public String jfrFileHasDiagnostics() throws Exception {
Optional<Path> jfrFile;
for (int i = 0; i < 60; i++) {
try {
jfrFile =
Files.walk(new File("/tmp/root/applicationinsights").toPath())
.filter(Files::isRegularFile)
.filter(it -> it.toFile().getName().contains(".jfr"))
.findFirst();

jfrFile =
Files.walk(new File("/tmp/root/applicationinsights").toPath())
.filter(Files::isRegularFile)
.filter(it -> it.toFile().getName().contains(".jfr"))
.findFirst();

if (!jfrFile.isPresent()) {
Thread.sleep(1000, 0);
continue;
}
if (!jfrFile.isPresent()) {
Thread.sleep(1000, 0);
continue;
}

Path decompressedFile = decompressFile(jfrFile.get());
Path decompressedFile = decompressFile(jfrFile.get());

boolean hasTelemetry =
com.microsoft.applicationinsights.jfrfile.JfrFileReader.hasEventOfType(
decompressedFile, "com.microsoft.applicationinsights.diagnostics.jfr.Telemetry");
boolean hasTelemetry =
com.microsoft.applicationinsights.jfrfile.JfrFileReader.hasEventOfType(
decompressedFile, "com.microsoft.applicationinsights.diagnostics.jfr.Telemetry");

if (hasTelemetry) {
return String.valueOf(true);
if (hasTelemetry) {
return String.valueOf(true);
}
} catch (Exception e) {
// Ignore early exceptions, as to be expected, throw them if they are still happening
// towards the end
if (i > 55) {
throw e;
} else {
Thread.sleep(1000, 0);
}
}
}

Expand Down

0 comments on commit 775fbd2

Please sign in to comment.