mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-17 22:14:56 +00:00
Test timing freshness gate
- Test that capture drops generation timings once generation is idle - Test that capture carries the engine timing averages while fresh - Remove the hand-built idle snapshot test that passed without the gate
This commit is contained in:
-20
@@ -97,26 +97,6 @@ public class IrisIntegrationServiceTest {
|
||||
assertFalse(nether.samples().get(IntegrationMetricSchema.IRIS_PREGEN_REMAINING).available());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void idleWorldsPublishGenerationTimingsAsUnavailable() {
|
||||
long now = System.currentTimeMillis();
|
||||
EngineTelemetrySnapshot idle = new EngineTelemetrySnapshot(
|
||||
now, "minecraft:overworld", "world", "dimension", true, false, false, false,
|
||||
12L, 3L, 0.25D, 20L, 20L, 0D, 0L, 2, 0, 1L, 4L, 1L, 10D, Map.of());
|
||||
IrisIntegrationService service = new IrisIntegrationService(
|
||||
() -> telemetry(List.of(idle), IrisTelemetrySnapshot.PregenSnapshot.INACTIVE, now)
|
||||
);
|
||||
|
||||
IntegrationMetricSample total = service.sampleMetrics(Set.of(IntegrationMetricSchema.IRIS_GENERATION_TOTAL_MS))
|
||||
.get(IntegrationMetricSchema.IRIS_GENERATION_TOTAL_MS);
|
||||
IntegrationMetricSample worldTotal = service.metricGroups().get(0).samples()
|
||||
.get(IntegrationMetricSchema.IRIS_GENERATION_TOTAL_MS);
|
||||
|
||||
assertFalse(total.available());
|
||||
assertEquals("timing-not-available", total.message());
|
||||
assertFalse(worldTotal.available());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishesEveryManagedWorldWithoutAWorldCountCap() {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
+30
@@ -7,6 +7,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class EngineTelemetrySnapshotTest {
|
||||
@Test
|
||||
@@ -138,6 +141,33 @@ public class EngineTelemetrySnapshotTest {
|
||||
assertEquals(1, EngineTelemetrySnapshot.aggregate(snapshots).worldCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void captureLeavesOutGenerationTimingsOnceGenerationHasGoneIdle() {
|
||||
Engine engine = engineWithTimings(Map.of("total", 12D, "terrain", 4D));
|
||||
|
||||
EngineTelemetrySnapshot snapshot = EngineTelemetrySnapshot.capture(engine, 0D, false, 5_000L);
|
||||
|
||||
assertEquals(Map.of(), snapshot.generationTimingsMs());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void captureCarriesTheEngineTimingAveragesWhileGenerationIsFresh() {
|
||||
Engine engine = engineWithTimings(Map.of("total", 12D, "terrain", 4D));
|
||||
|
||||
EngineTelemetrySnapshot snapshot = EngineTelemetrySnapshot.capture(engine, 3D, true, 5_000L);
|
||||
|
||||
assertEquals(Map.of("total", 12D, "terrain", 4D), snapshot.generationTimingsMs());
|
||||
assertEquals(3D, snapshot.chunksPerSecond(), 0D);
|
||||
}
|
||||
|
||||
private static Engine engineWithTimings(Map<String, Double> averages) {
|
||||
Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||
when(engine.getWorld().identity()).thenReturn("minecraft:overworld");
|
||||
when(engine.getWorld().name()).thenReturn("world");
|
||||
when(engine.getMetrics().telemetryAverages()).thenReturn(averages);
|
||||
return engine;
|
||||
}
|
||||
|
||||
private static EngineTelemetrySnapshot snapshot(
|
||||
String identity,
|
||||
String name,
|
||||
|
||||
Reference in New Issue
Block a user