Search in sources :

Example 66 with Application

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

the class ApplicationApiTest method setDeploymentMaintainedInfo.

/**
 * Cluster info, utilization and application and deployment metrics are maintained async by maintainers.
 *
 * This sets these values as if the maintainers has been ran.
 *
 * @param controllerTester
 */
private void setDeploymentMaintainedInfo(ContainerControllerTester controllerTester) {
    for (Application application : controllerTester.controller().applications().asList()) {
        controllerTester.controller().applications().lockOrThrow(application.id(), lockedApplication -> {
            lockedApplication = lockedApplication.with(new ApplicationMetrics(0.5, 0.7));
            for (Deployment deployment : application.deployments().values()) {
                Map<ClusterSpec.Id, ClusterInfo> clusterInfo = new HashMap<>();
                List<String> hostnames = new ArrayList<>();
                hostnames.add("host1");
                hostnames.add("host2");
                clusterInfo.put(ClusterSpec.Id.from("cluster1"), new ClusterInfo("flavor1", 37, 2, 4, 50, ClusterSpec.Type.content, hostnames));
                Map<ClusterSpec.Id, ClusterUtilization> clusterUtils = new HashMap<>();
                clusterUtils.put(ClusterSpec.Id.from("cluster1"), new ClusterUtilization(0.3, 0.6, 0.4, 0.3));
                DeploymentMetrics metrics = new DeploymentMetrics(1, 2, 3, 4, 5);
                lockedApplication = lockedApplication.withClusterInfo(deployment.zone(), clusterInfo).withClusterUtilization(deployment.zone(), clusterUtils).with(deployment.zone(), metrics);
            }
            controllerTester.controller().applications().store(lockedApplication);
        });
    }
}
Also used : DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) IssueId(com.yahoo.vespa.hosted.controller.api.integration.organization.IssueId) ApplicationId(com.yahoo.config.provision.ApplicationId) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId) UserId(com.yahoo.vespa.hosted.controller.api.identifiers.UserId) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationMetrics(com.yahoo.vespa.hosted.controller.api.integration.MetricsService.ApplicationMetrics) Application(com.yahoo.vespa.hosted.controller.Application)

Example 67 with Application

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

the class DeploymentMetricsMaintainerTest method maintain.

@Test
public void maintain() {
    ControllerTester tester = new ControllerTester();
    ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id();
    // Pre condition: no metric info on neither application nor deployment
    assertEquals(0, tester.controller().applications().require(app).metrics().queryServiceQuality(), 0);
    Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
    assertEquals(0, deployment.metrics().documentCount(), 0);
    DeploymentMetricsMaintainer maintainer = new DeploymentMetricsMaintainer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
    maintainer.maintain();
    // Post condition:
    Application application = tester.controller().applications().require(app);
    assertEquals(0.5, application.metrics().queryServiceQuality(), Double.MIN_VALUE);
    assertEquals(0.7, application.metrics().writeServiceQuality(), Double.MIN_VALUE);
    deployment = application.deployments().values().stream().findAny().get();
    assertEquals(1, deployment.metrics().queriesPerSecond(), Double.MIN_VALUE);
    assertEquals(2, deployment.metrics().writesPerSecond(), Double.MIN_VALUE);
    assertEquals(3, deployment.metrics().documentCount(), Double.MIN_VALUE);
    assertEquals(4, deployment.metrics().queryLatencyMillis(), Double.MIN_VALUE);
    assertEquals(5, deployment.metrics().writeLatencyMillis(), Double.MIN_VALUE);
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ApplicationId(com.yahoo.config.provision.ApplicationId) Application(com.yahoo.vespa.hosted.controller.Application) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 68 with Application

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

the class FailureRedeployerTest method testRetriesJobsFailingForCurrentChange.

@Test
public void testRetriesJobsFailingForCurrentChange() {
    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, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    // 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();
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // system-test fails and is left with a retry
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.systemTest);
    // Another version is released
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    assertEquals(version, tester.controller().versionStatus().systemVersion().get().versionNumber());
    // Job is left "running", so needs to time out before it can be retried.
    tester.clock().advance(Duration.ofHours(13));
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Cancellation of outdated version and triggering on a new version is done by the upgrader.
    assertEquals(version, tester.application(app.id()).deploymentJobs().jobStatus().get(systemTest).lastTriggered().get().version());
}
Also used : 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) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 69 with Application

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

the class FailureRedeployerTest method testRetryingFailedJobsDuringDeployment.

@Test
public void testRetryingFailedJobsDuringDeployment() {
    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, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    // 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();
    // Test environments pass
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Production job fails and is retried
    // Advance time so that we can detect jobs in progress
    tester.clock().advance(Duration.ofSeconds(1));
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
    assertEquals("Production job is retried", 1, tester.deploymentQueue().jobs().size());
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Another version is released, which cancels any pending upgrades to lower versions
    version = Version.fromString("5.2");
    tester.updateVersionStatus(version);
    tester.upgrader().maintain();
    tester.readyJobTrigger().maintain();
    assertEquals("Application starts upgrading to new version", 1, tester.deploymentQueue().jobs().size());
    assertEquals("Application has pending upgrade to " + version, version, tester.application(app.id()).change().platform().get());
    // Failure re-deployer does not retry failing job for prod.us-east-3, since it no longer has an available change
    tester.clock().advance(Duration.ofMinutes(1));
    tester.jobCompletion(DeploymentJobs.JobType.productionUsEast3).application(app).unsuccessful().submit();
    assertFalse("Job is not retried", tester.deploymentQueue().jobs().stream().anyMatch(j -> j.jobName().equals(DeploymentJobs.JobType.productionUsEast3.jobName())));
    // Test environments pass
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    // Production job fails again, and is retried
    tester.deployAndNotify(app, applicationPackage, false, DeploymentJobs.JobType.productionUsEast3);
    tester.readyJobTrigger().maintain();
    assertEquals("Job is retried", Collections.singletonList(new BuildService.BuildJob(app.deploymentJobs().projectId().get(), productionUsEast3.jobName())), tester.deploymentQueue().jobs());
    // Production job finally succeeds
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsEast3);
    assertTrue("All jobs consumed", tester.deploymentQueue().jobs().isEmpty());
    assertFalse("No failures", tester.application(app.id()).deploymentJobs().hasFailures());
}
Also used : Collection(com.yahoo.log.event.Collection) Version(com.yahoo.component.Version) Files(java.nio.file.Files) Environment(com.yahoo.config.provision.Environment) Slime(com.yahoo.slime.Slime) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) Paths(java.nio.file.Paths) Assert.assertFalse(org.junit.Assert.assertFalse) Duration(java.time.Duration) SystemName(com.yahoo.config.provision.SystemName) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) JobType.productionUsEast3(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3) Collections(java.util.Collections) JobType.component(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component) Application(com.yahoo.vespa.hosted.controller.Application) Assert.assertEquals(org.junit.Assert.assertEquals) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) 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) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)

Example 70 with Application

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

the class RotationTest method application_with_only_one_non_corp_region.

@Test
public void application_with_only_one_non_corp_region() {
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().globalServiceId("foo").region("us-east-3").region("corp-us-east-1").build();
    Application application = tester.createApplication("app2", "tenant2", 22L, 2L);
    thrown.expect(RuntimeException.class);
    thrown.expectMessage("less than 2 prod zones are defined");
    tester.deployCompletely(application, applicationPackage);
}
Also used : 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)

Aggregations

Application (com.yahoo.vespa.hosted.controller.Application)75 Test (org.junit.Test)52 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)40 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)34 Version (com.yahoo.component.Version)32 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)28 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)26 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)25 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)15 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)14 ApplicationId (com.yahoo.config.provision.ApplicationId)13 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)12 Slime (com.yahoo.slime.Slime)11 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)9 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)8 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)8 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)8 SlimeJsonResponse (com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse)7 Cursor (com.yahoo.slime.Cursor)6 Controller (com.yahoo.vespa.hosted.controller.Controller)6