From 624a0ba190243210b3b6f54ac8a14e862081e722 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Fri, 18 Sep 2026 11:12:46 +0100 Subject: [PATCH] Count low-disk warnings separately from probe diagnostics --- src/main/docs/disk-monitor-test-warnings.adoc | 13 +++++++++++++ .../chronicle/threads/DiskSpaceMonitorTest.java | 11 +++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/main/docs/disk-monitor-test-warnings.adoc diff --git a/src/main/docs/disk-monitor-test-warnings.adoc b/src/main/docs/disk-monitor-test-warnings.adoc new file mode 100644 index 000000000..5f8941ac6 --- /dev/null +++ b/src/main/docs/disk-monitor-test-warnings.adoc @@ -0,0 +1,13 @@ += Disk monitor warning fixture +:sectnums: +:lang: en-GB + +`DiskSpaceMonitorTest.pollDiskSpace` raises the warning threshold and requires +roughly five scheduled low-space warnings in its existing observation period. +Slow file-store queries independently emit PERF diagnostics. Counting those as +warnings made the fixture fail on busy Windows hosts despite the correct warning +frequency. + +The fixture counts only the low-space WARN messages and deliberately records +eight additional PERF messages as a regression control. It retains the original +warning-count range and threshold. Production logging and monitoring are unchanged. diff --git a/src/test/java/net/openhft/chronicle/threads/DiskSpaceMonitorTest.java b/src/test/java/net/openhft/chronicle/threads/DiskSpaceMonitorTest.java index 24c0dda19..83fff3a87 100644 --- a/src/test/java/net/openhft/chronicle/threads/DiskSpaceMonitorTest.java +++ b/src/test/java/net/openhft/chronicle/threads/DiskSpaceMonitorTest.java @@ -5,6 +5,7 @@ import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.onoes.ExceptionKey; +import net.openhft.chronicle.core.onoes.LogLevel; import net.openhft.chronicle.core.time.SetTimeProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,6 +47,11 @@ void pollDiskSpace() { assertEquals(5, DiskSpaceMonitor.INSTANCE.getThresholdPercentage()); DiskSpaceMonitor.INSTANCE.setThresholdPercentage(100); final Map map = Jvm.recordExceptions(); + //! Slow disk probes emit PERF diagnostics independently of the scheduled low-space warning. + //! Keep this control deterministic under both idle and busy hosts: pollDiskSpace must still + //! require the original warning count when extra probe diagnostics are recorded. + for (int i = 0; i < 8; i++) + Jvm.perf().on(DiskSpaceMonitor.class, "Controlled slow disk probe " + i); for (int i = 0; i < 51; i++) { DiskSpaceMonitor.INSTANCE.pollDiskSpace(new File(".")); Jvm.pause(100); @@ -55,11 +61,12 @@ void pollDiskSpace() { long count = map.entrySet() .stream() .filter(e -> e.getKey().clazz() == DiskSpaceMonitor.class) + .filter(e -> e.getKey().level() == LogLevel.WARN && e.getKey().message().startsWith("your disk ")) .mapToInt(Map.Entry::getValue) .sum(); Jvm.resetExceptionHandlers(); - System.out.println("Disk space warnings/errors: " + count); - // look for 5 disk space checks and some debug messages about slow disk checks. + System.out.println("Low disk-space warnings: " + count); + // Require the scheduled warnings; probe performance messages are not additional checks. assertEquals(5.5, count, 1.5); }