Search in sources :

Example 6 with DeploymentTester

use of com.yahoo.vespa.hosted.controller.deployment.DeploymentTester 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)

Example 7 with DeploymentTester

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

the class FailureRedeployerTest method applicationWithoutProjectIdIsNotTriggered.

@Test
public void applicationWithoutProjectIdIsNotTriggered() throws Exception {
    DeploymentTester tester = new DeploymentTester();
    // 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/application-without-project-id.json"));
    Slime slime = SlimeUtils.jsonToSlime(json);
    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) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 8 with DeploymentTester

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

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

the class UpgraderTest method testThrottlesUpgrades.

@Test
public void testThrottlesUpgrades() {
    DeploymentTester tester = new DeploymentTester();
    Version version = Version.fromString("5.0");
    tester.updateVersionStatus(version);
    // Setup our own upgrader as we need to control the interval
    Upgrader upgrader = new Upgrader(tester.controller(), Duration.ofMinutes(10), new JobControl(tester.controllerTester().curator()), tester.controllerTester().curator());
    upgrader.setUpgradesPerMinute(0.2);
    // 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");
    // Dev deployment which should be ignored
    Application dev0 = tester.createApplication("dev0", "tenant1", 7, 1L);
    tester.controllerTester().deploy(dev0, ZoneId.from(Environment.dev, RegionName.from("dev-region")));
    // New version is released and canaries upgrade
    version = Version.fromString("5.1");
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    upgrader.maintain();
    tester.readyJobTrigger().maintain();
    assertEquals(2, tester.deploymentQueue().jobs().size());
    tester.completeUpgrade(canary0, version, "canary");
    tester.completeUpgrade(canary1, version, "canary");
    tester.updateVersionStatus(version);
    // Next run upgrades a subset
    upgrader.maintain();
    tester.readyJobTrigger().maintain();
    assertEquals(2, tester.deploymentQueue().jobs().size());
    tester.completeUpgrade(default0, version, "default");
    tester.completeUpgrade(default2, version, "default");
    // Remaining applications upgraded
    upgrader.maintain();
    tester.readyJobTrigger().maintain();
    assertEquals(2, tester.deploymentQueue().jobs().size());
    tester.completeUpgrade(default1, version, "default");
    tester.completeUpgrade(default3, version, "default");
    upgrader.maintain();
    tester.readyJobTrigger().maintain();
    assertTrue("All jobs consumed", 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) 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 DeploymentTester

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

DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)38 Test (org.junit.Test)35 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)33 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)26 Application (com.yahoo.vespa.hosted.controller.Application)25 Version (com.yahoo.component.Version)24 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)23 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)22 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)15 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)6 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)4 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)4 MockCuratorDb (com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb)4 Environment (com.yahoo.config.provision.Environment)3 Slime (com.yahoo.slime.Slime)3 ManualClock (com.yahoo.test.ManualClock)3 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)3 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)3 JobType.productionUsEast3 (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3)3 Duration (java.time.Duration)3