8278628: jdk/jfr/jmx/streaming/TestMaxSize.java Expected only one or two chunks
Reviewed-by: mgronlun
This commit is contained in:
parent
e38df21641
commit
bd35f9740d
@ -70,12 +70,17 @@ public class TestMaxSize {
|
||||
while (directorySize(dir) < 50_000_000) {
|
||||
emitEvents(500_000);
|
||||
}
|
||||
System.out.println("Before setMaxSize(1_000_000)");
|
||||
fileCount(dir);
|
||||
e.setMaxSize(1_000_000);
|
||||
System.out.println("After setMaxSize(1_000_000)");
|
||||
long count = fileCount(dir);
|
||||
if (count > 2) {
|
||||
// Two chunks can happen when header of new chunk is written and previous
|
||||
// chunk is not finalized.
|
||||
throw new Exception("Expected only one or two chunks with setMaxSize(1_000_000). Found " + count);
|
||||
if (count > 3) {
|
||||
// Three files can happen when:
|
||||
// File 1: Header of new chunk is written to disk
|
||||
// File 2: Previous chunk is not yet finalized and added to list of DiskChunks
|
||||
// File 3: Previous previous file is in the list of DiskChunks.
|
||||
throw new Exception("Expected at most three chunks with setMaxSize(1_000_000). Found " + count);
|
||||
}
|
||||
finished.set(true);
|
||||
}
|
||||
@ -94,21 +99,24 @@ public class TestMaxSize {
|
||||
System.out.println("Files:");
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
Files.list(dir).forEach(p -> {
|
||||
System.out.println(p);
|
||||
System.out.println(p + " " + fileSize(p));
|
||||
count.incrementAndGet();
|
||||
});
|
||||
return count.get();
|
||||
}
|
||||
|
||||
private static long directorySize(Path dir) throws IOException {
|
||||
long p = Files.list(dir).mapToLong(f -> {
|
||||
try {
|
||||
return Files.size(f);
|
||||
} catch (IOException e) {
|
||||
return 0;
|
||||
}
|
||||
}).sum();
|
||||
long p = Files.list(dir).mapToLong(f -> fileSize(f)).sum();
|
||||
System.out.println("Directory size: " + p);
|
||||
return p;
|
||||
}
|
||||
|
||||
private static long fileSize(Path p) {
|
||||
try {
|
||||
return Files.size(p);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Could not determine file size for " + p);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user