Search in sources :

Example 6 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.

the class ControllerTest method testDeploymentApplicationVersion.

@Test
public void testDeploymentApplicationVersion() {
    DeploymentTester tester = new DeploymentTester();
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-east-3").build();
    SourceRevision source = new SourceRevision("repo", "master", "commit1");
    ApplicationVersion applicationVersion = ApplicationVersion.from(source, 101);
    runDeployment(tester, app.id(), applicationVersion, applicationPackage, source, 101);
    assertEquals("Artifact is downloaded twice in staging and once for other zones", 5, tester.artifactRepository().hits(app.id(), applicationVersion.id()));
    // Application is upgraded. This makes deployment orchestration pick the last successful application version in
    // zones which do not have permanent deployments, e.g. test and staging
    runUpgrade(tester, app.id(), applicationVersion);
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) 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 7 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.

the class ControllerTest method testDeployWithoutProjectId.

@Test
public void testDeployWithoutProjectId() {
    DeploymentTester tester = new DeploymentTester();
    tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
    tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1"));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("cd-us-central-1").build();
    // Create application
    Application app = tester.createApplication("app1", "tenant1", 1, 2L);
    // Direct deploy is allowed when project ID is missing
    ZoneId zone = ZoneId.from("prod", "cd-us-central-1");
    // Same options as used in our integration tests
    DeployOptions options = new DeployOptions(Optional.empty(), Optional.empty(), false, false);
    tester.controller().applications().deployApplication(app.id(), zone, Optional.of(applicationPackage), options);
    assertTrue("Application deployed and activated", tester.controllerTester().configServer().activated().getOrDefault(app.id(), false));
    assertTrue("No job status added", tester.applications().require(app.id()).deploymentJobs().jobStatus().isEmpty());
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) 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 8 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder 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 9 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.

the class MetricsReporterTest method test_deployment_fail_ratio.

@Test
public void test_deployment_fail_ratio() {
    DeploymentTester tester = new DeploymentTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    MetricsReporter metricsReporter = createReporter(tester.controller(), metrics, SystemName.cd);
    metricsReporter.maintain();
    assertEquals(0.0, metrics.getMetric(MetricsReporter.deploymentFailMetric));
    // Deploy all apps successfully
    Application app1 = tester.createApplication("app1", "tenant1", 1, 11L);
    Application app2 = tester.createApplication("app2", "tenant1", 2, 22L);
    Application app3 = tester.createApplication("app3", "tenant1", 3, 33L);
    Application app4 = tester.createApplication("app4", "tenant1", 4, 44L);
    tester.deployCompletely(app1, applicationPackage);
    tester.deployCompletely(app2, applicationPackage);
    tester.deployCompletely(app3, applicationPackage);
    tester.deployCompletely(app4, applicationPackage);
    metricsReporter.maintain();
    assertEquals(0.0, metrics.getMetric(MetricsReporter.deploymentFailMetric));
    // 1 app fails system-test
    tester.jobCompletion(component).application(app4).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(app4, applicationPackage, false, systemTest);
    metricsReporter.maintain();
    assertEquals(25.0, metrics.getMetric(MetricsReporter.deploymentFailMetric));
}
Also used : 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 10 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder in project vespa by vespa-engine.

the class UpgraderTest method testAllowApplicationChangeDuringFailingUpgrade.

@Test
public void testAllowApplicationChangeDuringFailingUpgrade() {
    DeploymentTester tester = new DeploymentTester();
    Version version = Version.fromString("5.0");
    tester.updateVersionStatus(version);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    Application app = tester.createAndDeploy("app1", 1, applicationPackage);
    // New version is released
    version = Version.fromString("5.1");
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, stagingTest);
    tester.deployAndNotify(app, applicationPackage, false, productionUsWest1);
    // New application change
    tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    String applicationVersion = "1.0.43-commit1";
    // Application change recorded together with ongoing upgrade
    app = tester.application(app.id());
    assertTrue("Change contains both upgrade and application change", app.change().platform().get().equals(version) && app.change().application().get().id().equals(applicationVersion));
    // Deployment completes
    tester.deployAndNotify(app, applicationPackage, true, false, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, false, stagingTest);
    tester.jobCompletion(productionUsWest1).application(app).unsuccessful().submit();
    tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
    app = tester.application(app.id());
    for (Deployment deployment : app.deployments().values()) {
        assertEquals(version, deployment.version());
        assertEquals(applicationVersion, deployment.applicationVersion().id());
    }
}
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) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) 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)

Aggregations

ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)33 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)33 Test (org.junit.Test)33 Application (com.yahoo.vespa.hosted.controller.Application)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)21 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)20 Version (com.yahoo.component.Version)16 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)15 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)10 ContainerControllerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester)6 ControllerContainerTest (com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest)6 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)4 JobStatus (com.yahoo.vespa.hosted.controller.application.JobStatus)4 ManualClock (com.yahoo.test.ManualClock)3 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)3 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)3 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)3 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)3 ContainerTester (com.yahoo.vespa.hosted.controller.restapi.ContainerTester)3 File (java.io.File)3