use of com.yahoo.vespa.hosted.controller.versions.VersionStatus in project vespa by vespa-engine.
the class VersionStatusUpdaterTest method testVersionUpdating.
/**
* Test that this job updates the status. Test of the content of the update is in VersionStatusTest
*/
@Test
public void testVersionUpdating() {
ControllerTester tester = new ControllerTester();
tester.controller().updateVersionStatus(new VersionStatus(Collections.emptyList()));
assertFalse(tester.controller().versionStatus().systemVersion().isPresent());
VersionStatusUpdater updater = new VersionStatusUpdater(tester.controller(), Duration.ofMinutes(3), new JobControl(new MockCuratorDb()));
updater.maintain();
assertTrue(tester.controller().versionStatus().systemVersion().isPresent());
}
use of com.yahoo.vespa.hosted.controller.versions.VersionStatus in project vespa by vespa-engine.
the class VersionStatusSerializerTest method testSerialization.
@Test
public void testSerialization() {
List<VespaVersion> vespaVersions = new ArrayList<>();
DeploymentStatistics statistics = new DeploymentStatistics(Version.fromString("5.0"), Arrays.asList(ApplicationId.from("tenant1", "failing1", "default")), Arrays.asList(ApplicationId.from("tenant2", "success1", "default"), ApplicationId.from("tenant2", "success2", "default")), Arrays.asList(ApplicationId.from("tenant1", "failing1", "default"), ApplicationId.from("tenant2", "success2", "default")));
vespaVersions.add(new VespaVersion(statistics, "dead", Instant.now(), false, Arrays.asList("cfg1", "cfg2", "cfg3"), VespaVersion.Confidence.normal));
vespaVersions.add(new VespaVersion(statistics, "cafe", Instant.now(), true, Arrays.asList("cfg1", "cfg2", "cfg3"), VespaVersion.Confidence.normal));
VersionStatus status = new VersionStatus(vespaVersions);
VersionStatusSerializer serializer = new VersionStatusSerializer();
VersionStatus deserialized = serializer.fromSlime(serializer.toSlime(status));
assertEquals(status.versions().size(), deserialized.versions().size());
for (int i = 0; i < status.versions().size(); i++) {
VespaVersion a = status.versions().get(i);
VespaVersion b = deserialized.versions().get(i);
assertEquals(a.releaseCommit(), b.releaseCommit());
assertEquals(a.committedAt(), b.committedAt());
assertEquals(a.isCurrentSystemVersion(), b.isCurrentSystemVersion());
assertEquals(a.statistics(), b.statistics());
assertEquals(a.configServerHostnames(), b.configServerHostnames());
assertEquals(a.confidence(), b.confidence());
}
}
use of com.yahoo.vespa.hosted.controller.versions.VersionStatus in project vespa by vespa-engine.
the class ControllerTest method incrementSystemVersion.
/**
* Adds a new version, higher than the current system version, makes it the system version and returns it
*/
private Version incrementSystemVersion(Controller controller) {
Version systemVersion = controller.versionStatus().systemVersion().get().versionNumber();
Version newSystemVersion = new Version(systemVersion.getMajor(), systemVersion.getMinor() + 1, 0);
VespaVersion newSystemVespaVersion = new VespaVersion(DeploymentStatistics.empty(newSystemVersion), "commit1", Instant.now(), true, Collections.emptyList(), VespaVersion.Confidence.low);
List<VespaVersion> versions = new ArrayList<>(controller.versionStatus().versions());
for (int i = 0; i < versions.size(); i++) {
VespaVersion c = versions.get(i);
if (c.isCurrentSystemVersion())
versions.set(i, new VespaVersion(c.statistics(), c.releaseCommit(), c.committedAt(), false, c.configServerHostnames(), c.confidence()));
}
versions.add(newSystemVespaVersion);
controller.updateVersionStatus(new VersionStatus(versions));
return newSystemVersion;
}
use of com.yahoo.vespa.hosted.controller.versions.VersionStatus in project vespa by vespa-engine.
the class VersionStatusUpdater method maintain.
@Override
protected void maintain() {
try {
VersionStatus newStatus = VersionStatus.compute(controller());
controller().updateVersionStatus(newStatus);
} catch (UncheckedIOException e) {
log.warning("Failed to compute version status. This is likely a transient error: " + e.getMessage());
}
}
use of com.yahoo.vespa.hosted.controller.versions.VersionStatus in project vespa by vespa-engine.
the class Controller method updateVersionStatus.
/**
* Replace the current version status by a new one
*/
public void updateVersionStatus(VersionStatus newStatus) {
VersionStatus currentStatus = versionStatus();
if (newStatus.systemVersion().isPresent() && !newStatus.systemVersion().equals(currentStatus.systemVersion())) {
log.info("Changing system version from " + printableVersion(currentStatus.systemVersion()) + " to " + printableVersion(newStatus.systemVersion()));
}
curator.writeVersionStatus(newStatus);
// Removes confidence overrides for versions that no longer exist in the system
removeConfidenceOverride(version -> newStatus.versions().stream().noneMatch(vespaVersion -> vespaVersion.versionNumber().equals(version)));
}
Aggregations