OsUpgradeActivator extends NodeRepositoryMaintainer { @Override protected boolean maintain() { for (var nodeType : NodeType.values()) { if (!nodeType.isHost()) continue; boolean resume = canUpgradeOsOf(nodeType); nodeRepository().osVersions().resumeUpgradeOf(nodeType, resume); } return true; } OsUpgradeActivator(NodeRepository nodeRepository, Duration interval, Metric metric);   }
@Test public void activates_upgrade() { var osVersions = tester.nodeRepository().osVersions(); var osUpgradeActivator = new OsUpgradeActivator(tester.nodeRepository(), Duration.ofDays(1), new TestMetric()); var version0 = Version.fromString("7.0"); var configHostApplication = ApplicationId.from("hosted-vespa", "configserver-host", "default"); var configHostNodes = tester.makeReadyNodes(3, "default", NodeType.confighost); tester.prepareAndActivateInfraApplication(configHostApplication, NodeType.confighost, version0); var tenantHostApplication = ApplicationId.from("hosted-vespa", "tenant-host", "default"); var tenantHostNodes = tester.makeReadyNodes(3, "default", NodeType.host); tester.prepareAndActivateInfraApplication(tenantHostApplication, NodeType.host, version0); var allNodes = new ArrayList<>(configHostNodes); allNodes.addAll(tenantHostNodes); assertEquals(version0, minWantedVersion(allNodes)); completeUpgradeOf(configHostNodes); completeUpgradeOf(tenantHostNodes); assertEquals("All nodes are on initial version", version0, minCurrentVersion(allNodes)); var osVersion0 = Version.fromString("8.0"); osVersions.setTarget(NodeType.host, osVersion0, Optional.empty(), false); osVersions.setTarget(NodeType.confighost, osVersion0, Optional.empty(), false); osUpgradeActivator.maintain(); assertTrue("OS version " + osVersion0 + " is active", isOsVersionActive(NodeType.confighost, NodeType.host)); var version1 = Version.fromString("7.1"); tester.prepareAndActivateInfraApplication(tenantHostApplication, NodeType.host, version1); assertEquals("Wanted version of " + NodeType.host + " is raised", version1, minWantedVersion(tenantHostNodes)); osUpgradeActivator.maintain(); assertTrue("OS version " + osVersion0 + " is active", isOsVersionActive(NodeType.confighost)); assertFalse("OS version " + osVersion0 + " is inactive", isOsVersionActive(NodeType.host)); tester.nodeRepository().fail(tenantHostNodes.get(0).hostname(), Agent.system, this.getClass().getSimpleName()); var healthyTenantHostNodes = tenantHostNodes.subList(1, tenantHostNodes.size()); completeUpgradeOf(healthyTenantHostNodes); assertEquals("Tenant hosts upgraded", version1, minCurrentVersion(healthyTenantHostNodes)); osUpgradeActivator.run(); assertTrue("OS version " + osVersion0 + " is active", isOsVersionActive(NodeType.confighost, NodeType.host)); }