Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/docs/disk-monitor-test-warnings.adoc
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,6 +47,11 @@ void pollDiskSpace() {
assertEquals(5, DiskSpaceMonitor.INSTANCE.getThresholdPercentage());
DiskSpaceMonitor.INSTANCE.setThresholdPercentage(100);
final Map<ExceptionKey, Integer> 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);
Expand All @@ -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);
}

Expand Down