Search in sources :

Example 21 with ApplicationPackageBuilder

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

the class DnsMaintainerTest method removes_record_for_unassigned_rotation.

@Test
public void removes_record_for_unassigned_rotation() {
    DeploymentTester tester = new DeploymentTester();
    Application application = tester.createApplication("app1", "tenant1", 1, 1L);
    DnsMaintainer dnsMaintainer = new DnsMaintainer(tester.controller(), Duration.ofHours(12), new JobControl(new MockCuratorDb()), tester.controllerTester().nameService());
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).globalServiceId("foo").region("us-west-1").region("us-central-1").build();
    // Deploy application
    tester.deployCompletely(application, applicationPackage);
    assertEquals(2, tester.controllerTester().nameService().records().size());
    Optional<Record> record = tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com"));
    assertTrue(record.isPresent());
    assertEquals("app1--tenant1.global.vespa.yahooapis.com", record.get().name().asString());
    assertEquals("rotation-fqdn-01.", record.get().data().asString());
    record = tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com"));
    assertTrue(record.isPresent());
    assertEquals("app1.tenant1.global.vespa.yahooapis.com", record.get().name().asString());
    assertEquals("rotation-fqdn-01.", record.get().data().asString());
    // DnsMaintainer does nothing
    dnsMaintainer.maintain();
    assertTrue("DNS record is not removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com")).isPresent());
    assertTrue("DNS record is not removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com")).isPresent());
    // Remove application
    applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).allow(ValidationId.deploymentRemoval).build();
    tester.jobCompletion(component).application(application).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.deployAndNotify(application, applicationPackage, true, systemTest);
    tester.applications().deactivate(application, ZoneId.from(Environment.test, RegionName.from("us-east-1")));
    tester.applications().deactivate(application, ZoneId.from(Environment.staging, RegionName.from("us-east-3")));
    tester.applications().deleteApplication(application.id(), Optional.of(new NToken("ntoken")));
    // DnsMaintainer removes records
    dnsMaintainer.maintain();
    assertFalse("DNS record removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1--tenant1.global.vespa.yahooapis.com")).isPresent());
    dnsMaintainer.maintain();
    assertFalse("DNS record removed", tester.controllerTester().nameService().findRecord(Record.Type.CNAME, RecordName.from("app1.tenant1.global.vespa.yahooapis.com")).isPresent());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) NToken(com.yahoo.vespa.athenz.api.NToken) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) 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 22 with ApplicationPackageBuilder

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

the class MetricsReporterTest method test_deployment_average_duration.

@Test
public void test_deployment_average_duration() {
    DeploymentTester tester = new DeploymentTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    MetricsReporter reporter = createReporter(tester.controller(), metrics, SystemName.cd);
    Application app = tester.createApplication("app1", "tenant1", 1, 11L);
    tester.deployCompletely(app, applicationPackage);
    reporter.maintain();
    // An exceptionally fast deployment :-)
    assertEquals(Duration.ZERO, getAverageDeploymentDuration(app));
    // App spends 3 hours deploying
    tester.jobCompletion(component).application(app).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    tester.clock().advance(Duration.ofHours(1));
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    tester.clock().advance(Duration.ofMinutes(30));
    tester.deployAndNotify(app, applicationPackage, true, stagingTest);
    tester.clock().advance(Duration.ofMinutes(90));
    tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
    reporter.maintain();
    // Average time is 1 hour
    assertEquals(Duration.ofHours(1), getAverageDeploymentDuration(app));
    // Another deployment starts and stalls for 12 hours
    tester.jobCompletion(component).application(app).nextBuildNumber(2).uploadArtifact(applicationPackage).submit();
    tester.clock().advance(Duration.ofHours(12));
    reporter.maintain();
    assertEquals(// hanging system-test
    Duration.ofHours(12).plus(// previous staging-test
    Duration.ofMinutes(30)).plus(// previous production job
    Duration.ofMinutes(90)).dividedBy(// Total number of orchestrated jobs
    3), getAverageDeploymentDuration(app));
}
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 23 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder 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());
}
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 24 with ApplicationPackageBuilder

use of com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder 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());
}
Also used : ManualClock(com.yahoo.test.ManualClock) 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) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) 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 25 with ApplicationPackageBuilder

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

the class UpgraderTest method testBlockVersionChangeHalfwayThough.

@Test
public void testBlockVersionChangeHalfwayThough() {
    // Tuesday, 17:00
    ManualClock clock = new ManualClock(Instant.parse("2017-09-26T17:00:00.00Z"));
    DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
    ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
    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").region("us-central-1").region("us-east-3").build();
    Application app = tester.createAndDeploy("app1", 1, applicationPackage);
    // New version is released
    version = Version.fromString("5.1");
    tester.updateVersionStatus(version);
    // Application upgrade starts
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    tester.deployAndNotify(app, applicationPackage, true, systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Entering block window after prod job is triggered
    clock.advance(Duration.ofHours(1));
    tester.deployAndNotify(app, applicationPackage, true, productionUsWest1);
    // Next job not triggered due to being in the block window
    assertTrue(tester.deploymentQueue().jobs().isEmpty());
    // One hour passes, time is 19:00, still no upgrade
    tester.clock().advance(Duration.ofHours(1));
    readyJobsTrigger.maintain();
    assertTrue("No jobs scheduled", tester.deploymentQueue().jobs().isEmpty());
    // Another hour pass, time is 20:00 and application upgrades
    tester.clock().advance(Duration.ofHours(1));
    readyJobsTrigger.maintain();
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsCentral1);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
}
Also used : ManualClock(com.yahoo.test.ManualClock) 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) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) 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