use of com.yahoo.component.Version in project vespa by vespa-engine.
the class UpgraderTest method testUpgrading.
@Test
public void testUpgrading() {
// --- Setup
DeploymentTester tester = new DeploymentTester();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("No applications: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// Setup applications
Application canary0 = tester.createAndDeploy("canary0", 1, "canary");
Application canary1 = tester.createAndDeploy("canary1", 2, "canary");
Application default0 = tester.createAndDeploy("default0", 3, "default");
Application default1 = tester.createAndDeploy("default1", 4, "default");
Application default2 = tester.createAndDeploy("default2", 5, "default");
Application conservative0 = tester.createAndDeploy("conservative0", 6, "conservative");
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("All already on the right version: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// --- 5.1 is released - everything goes smoothly
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("New system version: Should upgrade Canaries", 2, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary0, version, "canary");
assertEquals(version, tester.configServer().lastPrepareVersion().get());
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("One canary pending; nothing else", 1, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary1, version, "canary");
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Canaries done: Should upgrade defaults", 3, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(default0, version, "default");
tester.completeUpgrade(default1, version, "default");
tester.completeUpgrade(default2, version, "default");
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.high, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Normals done: Should upgrade conservatives", 1, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(conservative0, version, "conservative");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Nothing to do", 0, tester.deploymentQueue().jobs().size());
// --- 5.2 is released - which fails a Canary
version = Version.fromString("5.2");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("New system version: Should upgrade Canaries", 2, tester.deploymentQueue().jobs().size());
tester.completeUpgradeWithError(canary0, version, "canary", DeploymentJobs.JobType.stagingTest);
assertEquals("Other Canary was cancelled", 2, tester.deploymentQueue().jobs().size());
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Version broken, but Canaries should keep trying", 2, tester.deploymentQueue().jobs().size());
// --- A new version is released - which repairs the Canary app and fails a default
tester.clock().advance(Duration.ofHours(13));
version = Version.fromString("5.3");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("New system version: Should upgrade Canaries", 2, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary0, version, "canary");
assertEquals(version, tester.configServer().lastPrepareVersion().get());
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("One canary pending; nothing else", 1, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary1, version, "canary");
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Canaries done: Should upgrade defaults", 3, tester.deploymentQueue().jobs().size());
tester.completeUpgradeWithError(default0, version, "default", DeploymentJobs.JobType.stagingTest);
tester.completeUpgrade(default1, version, "default");
tester.completeUpgrade(default2, version, "default");
tester.updateVersionStatus(version);
assertEquals("Not enough evidence to mark this as neither broken nor high", VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
assertEquals("Upgrade with error should retry", 1, tester.deploymentQueue().jobs().size());
// --- Failing application is repaired by changing the application, causing confidence to move above 'high' threshold
// Deploy application change
tester.deploymentQueue().takeJobsToRun();
tester.jobCompletion(component).application(default0).nextBuildNumber().uploadArtifact(DeploymentTester.applicationPackage("default")).submit();
tester.jobCompletion(stagingTest).application(default0).unsuccessful().submit();
tester.deployAndNotify(default0, "default", true, systemTest);
tester.deployAndNotify(default0, "default", true, stagingTest);
tester.deployAndNotify(default0, "default", true, productionUsWest1);
tester.deployAndNotify(default0, "default", true, productionUsEast3);
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.high, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Normals done: Should upgrade conservatives", 1, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(conservative0, version, "conservative");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Applications are on 5.3 - nothing to do", 0, tester.deploymentQueue().jobs().size());
// --- Starting upgrading to a new version which breaks, causing upgrades to commence on the previous version
Version version54 = Version.fromString("5.4");
// need 4 to break a version
Application default3 = tester.createAndDeploy("default3", 5, "default");
Application default4 = tester.createAndDeploy("default4", 5, "default");
tester.updateVersionStatus(version54);
// cause canary upgrades to 5.4
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
tester.completeUpgrade(canary0, version54, "canary");
tester.completeUpgrade(canary1, version54, "canary");
tester.updateVersionStatus(version54);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade of defaults are scheduled", 5, tester.deploymentQueue().jobs().size());
assertEquals(version54, tester.application(default0.id()).change().platform().get());
assertEquals(version54, tester.application(default1.id()).change().platform().get());
assertEquals(version54, tester.application(default2.id()).change().platform().get());
assertEquals(version54, tester.application(default3.id()).change().platform().get());
assertEquals(version54, tester.application(default4.id()).change().platform().get());
tester.completeUpgrade(default0, version54, "default");
// State: Default applications started upgrading to 5.4 (and one completed)
Version version55 = Version.fromString("5.5");
tester.updateVersionStatus(version55);
// cause canary upgrades to 5.5
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
tester.completeUpgrade(canary0, version55, "canary");
tester.completeUpgrade(canary1, version55, "canary");
tester.updateVersionStatus(version55);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade of defaults are scheduled", 5, tester.deploymentQueue().jobs().size());
assertEquals(version55, tester.application(default0.id()).change().platform().get());
assertEquals(version54, tester.application(default1.id()).change().platform().get());
assertEquals(version54, tester.application(default2.id()).change().platform().get());
assertEquals(version54, tester.application(default3.id()).change().platform().get());
assertEquals(version54, tester.application(default4.id()).change().platform().get());
tester.completeUpgrade(default1, version54, "default");
tester.completeUpgrade(default2, version54, "default");
tester.completeUpgradeWithError(default3, version54, "default", DeploymentJobs.JobType.stagingTest);
tester.completeUpgradeWithError(default4, version54, "default", DeploymentJobs.JobType.productionUsWest1);
// State: Default applications started upgrading to 5.5
tester.clock().advance(Duration.ofHours(13));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
tester.completeUpgradeWithError(default0, version55, "default", DeploymentJobs.JobType.stagingTest);
tester.completeUpgradeWithError(default1, version55, "default", DeploymentJobs.JobType.stagingTest);
tester.completeUpgradeWithError(default2, version55, "default", DeploymentJobs.JobType.stagingTest);
tester.completeUpgradeWithError(default3, version55, "default", DeploymentJobs.JobType.productionUsWest1);
tester.updateVersionStatus(version55);
assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence());
// Finish running job, without retry.
tester.clock().advance(Duration.ofHours(1));
tester.jobCompletion(DeploymentJobs.JobType.productionUsWest1).application(default3).unsuccessful().submit();
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade of defaults are scheduled on 5.4 instead, since 5.5 broken: " + "This is default3 since it failed upgrade on both 5.4 and 5.5", 1, tester.deploymentQueue().jobs().size());
assertEquals("5.4", tester.application(default3.id()).change().platform().get().toString());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class UpgraderTest method testReschedulesUpgradeAfterTimeout.
@Test
public void testReschedulesUpgradeAfterTimeout() {
DeploymentTester tester = new DeploymentTester();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackage canaryApplicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-west-1").build();
ApplicationPackage defaultApplicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").environment(Environment.prod).region("us-west-1").build();
// Setup applications
Application canary0 = tester.createAndDeploy("canary0", 1, canaryApplicationPackage);
Application canary1 = tester.createAndDeploy("canary1", 2, canaryApplicationPackage);
Application default0 = tester.createAndDeploy("default0", 3, defaultApplicationPackage);
Application default1 = tester.createAndDeploy("default1", 4, defaultApplicationPackage);
Application default2 = tester.createAndDeploy("default2", 5, defaultApplicationPackage);
Application default3 = tester.createAndDeploy("default3", 6, defaultApplicationPackage);
Application default4 = tester.createAndDeploy("default4", 7, defaultApplicationPackage);
assertEquals(version, default0.oldestDeployedVersion().get());
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// Canaries upgrade and raise confidence
tester.completeUpgrade(canary0, version, canaryApplicationPackage);
tester.completeUpgrade(canary1, version, canaryApplicationPackage);
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
// Applications with default policy start upgrading
tester.clock().advance(Duration.ofMinutes(1));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade scheduled for remaining apps", 5, tester.deploymentQueue().jobs().size());
// 4/5 applications fail, confidence is lowered and upgrade is cancelled
tester.completeUpgradeWithError(default0, version, defaultApplicationPackage, systemTest);
tester.completeUpgradeWithError(default1, version, defaultApplicationPackage, systemTest);
tester.completeUpgradeWithError(default2, version, defaultApplicationPackage, systemTest);
tester.completeUpgradeWithError(default3, version, defaultApplicationPackage, systemTest);
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// Finish runs
tester.jobCompletion(systemTest).application(default0).unsuccessful().submit();
tester.jobCompletion(systemTest).application(default1).unsuccessful().submit();
tester.jobCompletion(systemTest).application(default2).unsuccessful().submit();
tester.jobCompletion(systemTest).application(default3).unsuccessful().submit();
// 5th app never reports back and has a dead job, but no ongoing change
Application deadLocked = tester.applications().require(default4.id());
assertTrue("Jobs in progress", deadLocked.deploymentJobs().isRunning(tester.controller().applications().deploymentTrigger().jobTimeoutLimit()));
assertFalse("No change present", deadLocked.change().isPresent());
// 4 out of 5 applications are repaired and confidence is restored
ApplicationPackage defaultApplicationPackageV2 = new ApplicationPackageBuilder().searchDefinition("search test { field test type string {} }").upgradePolicy("default").environment(Environment.prod).region("us-west-1").build();
tester.deployCompletely(default0, defaultApplicationPackageV2, 43);
tester.deployCompletely(default1, defaultApplicationPackageV2, 43);
tester.deployCompletely(default2, defaultApplicationPackageV2, 43);
tester.deployCompletely(default3, defaultApplicationPackageV2, 43);
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade scheduled for previously failing apps", 4, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(default0, version, defaultApplicationPackageV2);
tester.completeUpgrade(default1, version, defaultApplicationPackageV2);
tester.completeUpgrade(default2, version, defaultApplicationPackageV2);
tester.completeUpgrade(default3, version, defaultApplicationPackageV2);
assertEquals(version, tester.application(default0.id()).oldestDeployedVersion().get());
assertEquals(version, tester.application(default1.id()).oldestDeployedVersion().get());
assertEquals(version, tester.application(default2.id()).oldestDeployedVersion().get());
assertEquals(version, tester.application(default3.id()).oldestDeployedVersion().get());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class UpgraderTest method testUpgradingToVersionWhichBreaksSomeNonCanaries.
@Test
public void testUpgradingToVersionWhichBreaksSomeNonCanaries() {
// --- Setup
DeploymentTester tester = new DeploymentTester();
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("No system version: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// (lower than the hardcoded version in the config server client)
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("No applications: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// Setup applications
Application canary0 = tester.createAndDeploy("canary0", 1, "canary");
Application canary1 = tester.createAndDeploy("canary1", 2, "canary");
Application default0 = tester.createAndDeploy("default0", 3, "default");
Application default1 = tester.createAndDeploy("default1", 4, "default");
Application default2 = tester.createAndDeploy("default2", 5, "default");
Application default3 = tester.createAndDeploy("default3", 6, "default");
Application default4 = tester.createAndDeploy("default4", 7, "default");
Application default5 = tester.createAndDeploy("default5", 8, "default");
Application default6 = tester.createAndDeploy("default6", 9, "default");
Application default7 = tester.createAndDeploy("default7", 10, "default");
Application default8 = tester.createAndDeploy("default8", 11, "default");
Application default9 = tester.createAndDeploy("default9", 12, "default");
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("All already on the right version: Nothing to do", 0, tester.deploymentQueue().jobs().size());
// --- A new version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("New system version: Should upgrade Canaries", 2, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary0, version, "canary");
assertEquals(version, tester.configServer().lastPrepareVersion().get());
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("One canary pending; nothing else", 1, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(canary1, version, "canary");
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Canaries done: Should upgrade defaults", 10, tester.deploymentQueue().jobs().size());
tester.completeUpgrade(default0, version, "default");
tester.completeUpgradeWithError(default1, version, "default", systemTest);
tester.completeUpgradeWithError(default2, version, "default", systemTest);
tester.completeUpgradeWithError(default3, version, "default", systemTest);
tester.completeUpgradeWithError(default4, version, "default", systemTest);
// > 40% and at least 4 failed - version is broken
tester.updateVersionStatus(version);
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence());
assertEquals("Upgrades are cancelled", 0, tester.deploymentQueue().jobs().size());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class UpgraderTest method testBlockVersionChange.
@Test
public void testBlockVersionChange() {
// Tuesday, 18:00
ManualClock clock = new ManualClock(Instant.parse("2017-09-26T18:00:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(false, true, "tue", "18-19", "UTC").region("us-west-1").build();
Application app = tester.createAndDeploy("app1", 1, applicationPackage);
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
// Application is not upgraded at this time
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
// One hour passes, time is 19:00, still no upgrade
tester.clock().advance(Duration.ofHours(1));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
// Two hours pass in total, time is 20:00 and application upgrades
tester.clock().advance(Duration.ofHours(1));
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertFalse("Job is scheduled", tester.deploymentQueue().jobs().isEmpty());
tester.completeUpgrade(app, version, applicationPackage);
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class UpgraderTest method testUpgradeCancelledWithDeploymentInProgress.
@Test
public void testUpgradeCancelledWithDeploymentInProgress() {
DeploymentTester tester = new DeploymentTester();
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
// Setup applications
Application canary0 = tester.createAndDeploy("canary0", 1, "canary");
Application canary1 = tester.createAndDeploy("canary1", 2, "canary");
Application default0 = tester.createAndDeploy("default0", 3, "default");
Application default1 = tester.createAndDeploy("default1", 4, "default");
Application default2 = tester.createAndDeploy("default2", 5, "default");
Application default3 = tester.createAndDeploy("default3", 6, "default");
Application default4 = tester.createAndDeploy("default4", 7, "default");
// New version is released
version = Version.fromString("5.1");
tester.updateVersionStatus(version);
assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// Canaries upgrade and raise confidence
tester.completeUpgrade(canary0, version, "canary");
tester.completeUpgrade(canary1, version, "canary");
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.normal, tester.controller().versionStatus().systemVersion().get().confidence());
// Applications with default policy start upgrading
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
assertEquals("Upgrade scheduled for remaining apps", 5, tester.deploymentQueue().jobs().size());
// 4/5 applications fail and lowers confidence
tester.completeUpgradeWithError(default0, version, "default", systemTest);
tester.completeUpgradeWithError(default1, version, "default", systemTest);
tester.completeUpgradeWithError(default2, version, "default", systemTest);
tester.completeUpgradeWithError(default3, version, "default", systemTest);
tester.updateVersionStatus(version);
assertEquals(VespaVersion.Confidence.broken, tester.controller().versionStatus().systemVersion().get().confidence());
tester.upgrader().maintain();
tester.readyJobTrigger().maintain();
// 5th app passes system-test, but does not trigger next job as upgrade is cancelled
assertFalse("No change present", tester.applications().require(default4.id()).change().isPresent());
tester.jobCompletion(systemTest).application(default4).submit();
assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
Aggregations