Upgrader extends ControllerMaintainer { public double upgradesPerMinute() { return curator.readUpgradesPerMinute(); } Upgrader(Controller controller, Duration interval, CuratorDb curator); @Override boolean maintain(); double upgradesPerMinute(); void setUpgradesPerMinute(double n); Optional<Integer> targetMajorVersion(); void setTargetMajorVersion(Optional<Integer> targetMajorVersion); void overrideConfidence(Version version, Confidence confidence); Map<Version, Confidence> confidenceOverrides(); void removeConfidenceOverride(Version version);  }
@Test public void testUpgradesPerMinute() { assertEquals(0, Upgrader.numberOfApplicationsToUpgrade(10, 0, 0)); for (long now = 0; now < 60_000; now++) assertEquals(7, Upgrader.numberOfApplicationsToUpgrade(60_000, now, 7)); assertEquals(3, Upgrader.numberOfApplicationsToUpgrade(30_000, 0, 7.5)); assertEquals(4, Upgrader.numberOfApplicationsToUpgrade(30_000, 30_000, 7.5)); assertEquals(4, Upgrader.numberOfApplicationsToUpgrade(30_000, 60_000, 7.5)); assertEquals(4, Upgrader.numberOfApplicationsToUpgrade(30_000, 90_000, 7.5)); assertEquals(3, Upgrader.numberOfApplicationsToUpgrade(30_000, 120_000, 7.5)); int upgrades = 0; for (int i = 0, now = 0; i < 30; i++, now += 40_000) upgrades += Upgrader.numberOfApplicationsToUpgrade(40_000, now, 8.7); assertEquals(174, upgrades); }