OsVersionStatusUpdater extends ControllerMaintainer { @Override protected boolean maintain() { try { OsVersionStatus newStatus = OsVersionStatus.compute(controller()); controller().updateOsVersionStatus(newStatus); return true; } catch (Exception e) { log.log(Level.WARNING, "Failed to compute version status: " + Exceptions.toMessageString(e) + ". Retrying in " + interval()); } return false; } OsVersionStatusUpdater(Controller controller, Duration interval);   }
@Test public void test_update() { ControllerTester tester = new ControllerTester(); OsVersionStatusUpdater statusUpdater = new OsVersionStatusUpdater(tester.controller(), Duration.ofDays(1) ); UpgradePolicy upgradePolicy = UpgradePolicy.create(); for (ZoneApi zone : tester.zoneRegistry().zones().controllerUpgraded().zones()) { upgradePolicy = upgradePolicy.upgrade(zone); } tester.zoneRegistry().setOsUpgradePolicy(CloudName.defaultName(), upgradePolicy); assertSame(OsVersionStatus.empty, tester.controller().osVersionStatus()); Version version1 = Version.fromString("7.1"); CloudName cloud = CloudName.defaultName(); tester.controller().upgradeOsIn(cloud, version1, Optional.empty(), false); statusUpdater.maintain(); var osVersions = tester.controller().osVersionStatus().versions(); assertEquals(2, osVersions.size()); assertFalse("All nodes on unknown version", osVersions.get(new OsVersion(Version.emptyVersion, cloud)).asMap().isEmpty()); assertTrue("No nodes on current target", osVersions.get(new OsVersion(version1, cloud)).asMap().isEmpty()); }