Search in sources :

Example 16 with Version

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

the class ControllerTest method testDeployVersion.

@Test
public void testDeployVersion() {
    // Setup system
    DeploymentTester tester = new DeploymentTester();
    ApplicationController applications = tester.controller().applications();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    Version systemVersion = tester.controller().versionStatus().systemVersion().get().versionNumber();
    Application app1 = tester.createApplication("application1", "tenant1", 1, 1L);
    // First deployment: An application change
    tester.jobCompletion(component).application(app1).uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    app1 = applications.require(app1.id());
    assertEquals("First deployment gets system version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    // Unexpected deployment
    tester.deploy(productionUsWest1, app1, applicationPackage);
    // applications are immutable, so any change to one, including deployment changes, would give rise to a new instance.
    assertEquals("Unexpected deployment is ignored", app1, applications.require(app1.id()));
    // Application change after a new system version, and a region added
    Version newSystemVersion = incrementSystemVersion(tester.controller());
    assertTrue(newSystemVersion.isAfter(systemVersion));
    applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").region("us-east-3").build();
    tester.jobCompletion(component).application(app1).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    app1 = applications.require(app1.id());
    assertEquals("Application change preserves version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    // A deployment to the new region gets the same version
    tester.deployAndNotify(app1, applicationPackage, true, productionUsEast3);
    app1 = applications.require(app1.id());
    assertEquals("Application change preserves version", systemVersion, app1.oldestDeployedVersion().get());
    assertEquals(systemVersion, tester.configServer().lastPrepareVersion().get());
    assertFalse("Change deployed", app1.change().isPresent());
    // Version upgrade changes system version
    applications.deploymentTrigger().triggerChange(app1.id(), Change.of(newSystemVersion));
    tester.deploymentTrigger().triggerReadyJobs();
    tester.deployAndNotify(app1, applicationPackage, true, systemTest);
    tester.deployAndNotify(app1, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsWest1);
    tester.deployAndNotify(app1, applicationPackage, true, productionUsEast3);
    app1 = applications.require(app1.id());
    assertEquals("Version upgrade changes version", newSystemVersion, app1.oldestDeployedVersion().get());
    assertEquals(newSystemVersion, tester.configServer().lastPrepareVersion().get());
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) 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) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test)

Example 17 with Version

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

the class ControllerTest method runUpgrade.

private void runUpgrade(DeploymentTester tester, ApplicationId application, ApplicationVersion version) {
    Version next = Version.fromString("6.2");
    tester.upgradeSystem(next);
    runDeployment(tester, tester.applications().require(application), version, Optional.of(next), Optional.empty());
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version)

Example 18 with Version

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

the class ControllerTest method runDeployment.

private void runDeployment(DeploymentTester tester, Application app, ApplicationVersion version, Optional<Version> upgrade, Optional<ApplicationPackage> applicationPackage) {
    Version vespaVersion = upgrade.orElseGet(tester::defaultVespaVersion);
    // Deploy in test
    tester.deployAndNotify(app, applicationPackage, true, true, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, true, stagingTest);
    assertStatus(JobStatus.initial(stagingTest).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
    // Deploy in production
    tester.deployAndNotify(app, applicationPackage, true, true, productionCorpUsEast1);
    assertStatus(JobStatus.initial(productionCorpUsEast1).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
    tester.deployAndNotify(app, applicationPackage, true, true, productionUsEast3);
    assertStatus(JobStatus.initial(productionUsEast3).withTriggering(vespaVersion, version, "", tester.clock().instant().minus(Duration.ofMillis(1))).withCompletion(42, Optional.empty(), tester.clock().instant(), tester.controller()), app.id(), tester.controller());
    // Verify deployed version
    app = tester.controller().applications().require(app.id());
    for (Deployment deployment : app.productionDeployments().values()) {
        assertEquals(version, deployment.applicationVersion());
        upgrade.ifPresent(v -> assertEquals(v, deployment.version()));
    }
}
Also used : ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) Version(com.yahoo.component.Version) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment)

Example 19 with Version

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

the class FailureRedeployerTest method retryIgnoresStaleJobData.

@Test
public void retryIgnoresStaleJobData() throws Exception {
    DeploymentTester tester = new DeploymentTester();
    tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
    tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1"));
    // Current system version, matches version in test data
    Version version = Version.fromString("6.141.117");
    tester.configServer().setDefaultVersion(version);
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Load test data data
    byte[] json = Files.readAllBytes(Paths.get("src/test/java/com/yahoo/vespa/hosted/controller/maintenance/testdata/canary-with-stale-data.json"));
    Slime slime = SlimeUtils.jsonToSlime(json);
    Application application = tester.controllerTester().createApplication(slime);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("canary").region("cd-us-central-1").build();
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    // New version is released
    version = Version.fromString("6.142.1");
    tester.configServer().setDefaultVersion(version);
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    // Test environments pass
    tester.deploy(DeploymentJobs.JobType.systemTest, application, applicationPackage);
    tester.deploymentQueue().takeJobsToRun();
    tester.clock().advance(Duration.ofMinutes(10));
    tester.jobCompletion(DeploymentJobs.JobType.systemTest).application(application).submit();
    tester.deploy(DeploymentJobs.JobType.stagingTest, application, applicationPackage);
    tester.deploymentQueue().takeJobsToRun();
    tester.clock().advance(Duration.ofMinutes(10));
    tester.jobCompletion(DeploymentJobs.JobType.stagingTest).application(application).submit();
    // Production job starts, but does not complete
    assertEquals(1, tester.deploymentQueue().jobs().size());
    assertEquals("Production job triggered", DeploymentJobs.JobType.productionCdUsCentral1.jobName(), tester.deploymentQueue().jobs().get(0).jobName());
    tester.deploymentQueue().takeJobsToRun();
    // Failure re-deployer runs
    tester.readyJobTrigger().maintain();
    assertTrue("No jobs retried", tester.deploymentQueue().jobs().isEmpty());
    // Deployment notifies completeness but has not actually made a deployment
    tester.jobCompletion(DeploymentJobs.JobType.productionCdUsCentral1).application(application).submit();
    assertTrue("Change not really deployed", tester.application(application.id()).change().isPresent());
    // Deployment actually deploys and notifies completeness
    tester.deploy(DeploymentJobs.JobType.productionCdUsCentral1, application, applicationPackage);
    tester.jobCompletion(DeploymentJobs.JobType.productionCdUsCentral1).application(application).submit();
    assertFalse("Change not really deployed", tester.application(application.id()).change().isPresent());
}
Also used : Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 20 with Version

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

the class FailureRedeployerTest method ignoresPullRequestInstances.

@Test
public void ignoresPullRequestInstances() throws Exception {
    DeploymentTester tester = new DeploymentTester();
    tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
    // Current system version, matches version in test data
    Version version = Version.fromString("6.42.1");
    tester.configServer().setDefaultVersion(version);
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Load test data data
    byte[] json = Files.readAllBytes(Paths.get("src/test/java/com/yahoo/vespa/hosted/controller/maintenance/testdata/pr-instance-with-dead-locked-job.json"));
    Slime slime = SlimeUtils.jsonToSlime(json);
    Application application = tester.controllerTester().createApplication(slime);
    // Failure redeployer does not restart deployment
    tester.readyJobTrigger().maintain();
    assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
}
Also used : Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Slime(com.yahoo.slime.Slime) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

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