Search in sources :

Example 26 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class UpgraderTest method testDeploymentAlreadyInProgressForUpgrade.

@Test
public void testDeploymentAlreadyInProgressForUpgrade() {
    DeploymentTester tester = new DeploymentTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").environment(Environment.prod).region("us-east-3").build();
    Version version = Version.fromString("5.0");
    tester.updateVersionStatus(version);
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    tester.jobCompletion(component).application(app).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertEquals("Application is on expected version: Nothing to do", 0, tester.deploymentQueue().jobs().size());
    // 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();
    // system-test completes successfully
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    // staging-test fails and failure is recorded
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.stagingTest);
    assertTrue("Failure is recorded", tester.application(app.id()).deploymentJobs().hasFailures());
    assertTrue("Application has pending change", tester.application(app.id()).change().isPresent());
    // New version is released
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Upgrade is scheduled. system-tests starts, but does not complete
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertTrue("Application still has failures", tester.application(app.id()).deploymentJobs().hasFailures());
    assertEquals(1, tester.deploymentQueue().jobs().size());
    tester.deploymentQueue().takeJobsToRun();
    // Upgrader runs again, nothing happens as there's already a job in progress for this change
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertTrue("No more jobs triggered at this time", tester.deploymentQueue().jobs().isEmpty());
}
Also used : Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 27 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class OutstandingChangeDeployerTest method testChangeDeployer.

@Test
public void testChangeDeployer() {
    DeploymentTester tester = new DeploymentTester();
    tester.configServer().setDefaultVersion(new Version(6, 1));
    OutstandingChangeDeployer deployer = new OutstandingChangeDeployer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    tester.createAndDeploy("app1", 11, applicationPackage);
    tester.createAndDeploy("app2", 22, applicationPackage);
    Version version = new Version(6, 2);
    tester.deploymentTrigger().triggerChange(tester.application("app1").id(), Change.of(version));
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals(Change.of(version), tester.application("app1").change());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
    tester.jobCompletion(DeploymentJobs.JobType.component).application(tester.application("app1")).sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    Application app = tester.application("app1");
    assertTrue(app.outstandingChange().isPresent());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    assertEquals(1, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals("No effect as job is in progress", 1, tester.deploymentQueue().jobs().size());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsWest1);
    assertEquals("Upgrade done", 0, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    app = tester.application("app1");
    assertEquals("1.0.43-cafed00d", app.change().application().get().id());
    List<BuildService.BuildJob> jobs = tester.deploymentQueue().jobs();
    assertEquals(1, jobs.size());
    assertEquals(11, jobs.get(0).projectId());
    assertEquals(DeploymentJobs.JobType.systemTest.jobName(), jobs.get(0).jobName());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test)

Example 28 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DeploymentApiTest method testDeploymentApi.

@Test
public void testDeploymentApi() throws IOException {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    Version version = Version.fromString("5.0");
    tester.containerTester().updateSystemVersion(version);
    long projectId = 11;
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
    // 3 applications deploy on current system version
    Application failingApplication = tester.createApplication("domain1", "tenant1", "application1");
    Application productionApplication = tester.createApplication("domain2", "tenant2", "application2");
    Application applicationWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3");
    deployCompletely(failingApplication, applicationPackage, projectId, true);
    deployCompletely(productionApplication, applicationPackage, projectId, true);
    // Deploy once so that job information is stored, then remove the deployment
    deployCompletely(applicationWithoutDeployment, applicationPackage, projectId, true);
    tester.controller().applications().deactivate(applicationWithoutDeployment, ZoneId.from("prod", "corp-us-east-1"));
    // New version released
    version = Version.fromString("5.1");
    tester.containerTester().updateSystemVersion(version);
    // Applications upgrade, 1/2 succeed
    tester.upgrader().maintain();
    tester.controller().applications().deploymentTrigger().triggerReadyJobs();
    deployCompletely(failingApplication, applicationPackage, projectId, false);
    deployCompletely(productionApplication, applicationPackage, projectId, true);
    tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()), tester.controller()));
    tester.assertResponse(authenticatedRequest("http://localhost:8080/deployment/v1/"), new File("root.json"));
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 29 with Version

use of com.yahoo.component.Version 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;
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) ArrayList(java.util.ArrayList) VersionStatus(com.yahoo.vespa.hosted.controller.versions.VersionStatus)

Example 30 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class VersionStatusTest method testVersionConfidence.

@Test
public void testVersionConfidence() {
    DeploymentTester tester = new DeploymentTester();
    Version version0 = new Version("5.0");
    tester.upgradeSystem(version0);
    // Setup applications - all running on version0
    Application canary0 = tester.createAndDeploy("canary0", 1, "canary");
    Application canary1 = tester.createAndDeploy("canary1", 2, "canary");
    Application canary2 = tester.createAndDeploy("canary2", 3, "canary");
    Application default0 = tester.createAndDeploy("default0", 4, "default");
    Application default1 = tester.createAndDeploy("default1", 5, "default");
    Application default2 = tester.createAndDeploy("default2", 6, "default");
    Application default3 = tester.createAndDeploy("default3", 7, "default");
    Application default4 = tester.createAndDeploy("default4", 8, "default");
    Application default5 = tester.createAndDeploy("default5", 9, "default");
    Application default6 = tester.createAndDeploy("default6", 10, "default");
    Application default7 = tester.createAndDeploy("default7", 11, "default");
    Application default8 = tester.createAndDeploy("default8", 12, "default");
    Application default9 = tester.createAndDeploy("default9", 13, "default");
    Application conservative0 = tester.createAndDeploy("conservative1", 14, "conservative");
    // Applications that do not affect confidence calculation:
    // Application without deployment
    Application ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L);
    // Pull request builds
    tester.controllerTester().createApplication(new TenantId("tenant1"), "ignored1", "43", 1000);
    assertEquals("All applications running on this version: High", Confidence.high, confidence(tester.controller(), version0));
    // New version is released
    Version version1 = new Version("5.1");
    tester.upgradeSystem(version1);
    // Canaries upgrade to new versions and fail
    tester.completeUpgrade(canary0, version1, "canary");
    tester.completeUpgradeWithError(canary1, version1, "canary", productionUsWest1);
    tester.updateVersionStatus();
    assertEquals("One canary failed: Broken", Confidence.broken, confidence(tester.controller(), version1));
    // New version is released
    Version version2 = new Version("5.2");
    tester.upgradeSystem(version2);
    assertEquals("Confidence defaults to low for version with no applications", Confidence.low, confidence(tester.controller(), version2));
    // All canaries upgrade successfully
    tester.completeUpgrade(canary0, version2, "canary");
    tester.jobCompletion(productionUsWest1).application(canary1).unsuccessful().submit();
    tester.completeUpgrade(canary1, version2, "canary");
    assertEquals("Confidence for remains unchanged for version1: Broken", Confidence.broken, confidence(tester.controller(), version1));
    assertEquals("Nothing has failed but not all canaries have upgraded: Low", Confidence.low, confidence(tester.controller(), version2));
    // Remaining canary upgrades to version2 which raises confidence to normal and more apps upgrade
    tester.jobCompletion(systemTest).application(canary2).unsuccessful().submit();
    tester.completeUpgrade(canary2, version2, "canary");
    tester.upgradeSystem(version2);
    assertEquals("Canaries have upgraded: Normal", Confidence.normal, confidence(tester.controller(), version2));
    tester.completeUpgrade(default0, version2, "default");
    tester.completeUpgrade(default1, version2, "default");
    tester.completeUpgrade(default2, version2, "default");
    tester.completeUpgrade(default3, version2, "default");
    tester.completeUpgrade(default4, version2, "default");
    tester.completeUpgrade(default5, version2, "default");
    tester.completeUpgrade(default6, version2, "default");
    tester.completeUpgrade(default7, version2, "default");
    tester.updateVersionStatus();
    // Remember confidence across restart
    tester.restartController();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("All canaries deployed + < 90% of defaults: Normal", Confidence.normal, confidence(tester.controller(), version2));
    assertTrue("Status for version without applications is removed", tester.controller().versionStatus().versions().stream().noneMatch(vespaVersion -> vespaVersion.versionNumber().equals(version1)));
    // Another default application upgrades, raising confidence to high
    tester.completeUpgrade(default8, version2, "default");
    tester.completeUpgrade(default9, version2, "default");
    tester.updateVersionStatus();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("90% of defaults deployed successfully: High", VespaVersion.Confidence.high, confidence(tester.controller(), version2));
    // A new version is released, all canaries upgrade successfully, but enough "default" apps fail to mark version
    // as broken
    Version version3 = new Version("5.3");
    tester.upgradeSystem(version3);
    tester.completeUpgrade(canary0, version3, "canary");
    tester.completeUpgrade(canary1, version3, "canary");
    tester.completeUpgrade(canary2, version3, "canary");
    tester.upgradeSystem(version3);
    tester.completeUpgradeWithError(default0, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default1, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default2, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default9, version3, "default", stagingTest);
    tester.updateVersionStatus();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("Confidence remains unchanged for version2: High", Confidence.high, confidence(tester.controller(), version2));
    assertEquals("40% of defaults failed: Broken", VespaVersion.Confidence.broken, confidence(tester.controller(), version3));
    // Test version order
    List<VespaVersion> versions = tester.controller().versionStatus().versions();
    assertEquals(3, versions.size());
    assertEquals("5", versions.get(0).versionNumber().toString());
    assertEquals("5.2", versions.get(1).versionNumber().toString());
    assertEquals("5.3", versions.get(2).versionNumber().toString());
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Version(com.yahoo.component.Version) Environment(com.yahoo.config.provision.Environment) URISyntaxException(java.net.URISyntaxException) Assert.assertTrue(org.junit.Assert.assertTrue) Vtag(com.yahoo.component.Vtag) Test(org.junit.Test) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) List(java.util.List) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) JobType.productionUsWest1(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) Assert.assertFalse(org.junit.Assert.assertFalse) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Duration(java.time.Duration) URI(java.net.URI) JobType.productionUsEast3(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3) Confidence(com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence) Application(com.yahoo.vespa.hosted.controller.Application) Controller(com.yahoo.vespa.hosted.controller.Controller) Assert.assertEquals(org.junit.Assert.assertEquals) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7