Search in sources :

Example 21 with Application

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

the class DeploymentExpirerTest method testDeploymentExpiry.

@Test
public void testDeploymentExpiry() {
    tester.controllerTester().zoneRegistry().setDeploymentTimeToLive(ZoneId.from(Environment.dev, RegionName.from("us-east-1")), Duration.ofDays(14));
    DeploymentExpirer expirer = new DeploymentExpirer(tester.controller(), Duration.ofDays(10), tester.clock(), new JobControl(new MockCuratorDb()));
    Application devApp = tester.createApplication("app1", "tenant1", 123L, 1L);
    Application prodApp = tester.createApplication("app2", "tenant2", 456L, 2L);
    // Deploy dev
    tester.controllerTester().deploy(devApp, tester.controllerTester().toZone(Environment.dev));
    // Deploy prod
    ApplicationPackage prodAppPackage = new ApplicationPackageBuilder().region("us-west-1").build();
    tester.deployCompletely(prodApp, prodAppPackage);
    assertEquals(1, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
    // Not expired at first
    expirer.maintain();
    assertEquals(1, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
    // The dev application is removed
    tester.clock().advance(Duration.ofDays(15));
    expirer.maintain();
    assertEquals(0, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Test(org.junit.Test)

Example 22 with Application

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

the class OutstandingChangeDeployerTest method testChangeDeployer.

@Test
public void testChangeDeployer() {
    DeploymentTester tester = new DeploymentTester();
    tester.configServer().setDefaultVersion(new Version(6, 1));
    OutstandingChangeDeployer deployer = new OutstandingChangeDeployer(tester.controller(), Duration.ofMinutes(10), new JobControl(new MockCuratorDb()));
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("us-west-1").build();
    tester.createAndDeploy("app1", 11, applicationPackage);
    tester.createAndDeploy("app2", 22, applicationPackage);
    Version version = new Version(6, 2);
    tester.deploymentTrigger().triggerChange(tester.application("app1").id(), Change.of(version));
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals(Change.of(version), tester.application("app1").change());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
    tester.jobCompletion(DeploymentJobs.JobType.component).application(tester.application("app1")).sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).nextBuildNumber().uploadArtifact(applicationPackage).submit();
    Application app = tester.application("app1");
    assertTrue(app.outstandingChange().isPresent());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    assertEquals(1, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    assertEquals("No effect as job is in progress", 1, tester.deploymentQueue().jobs().size());
    assertEquals("1.0.43-cafed00d", app.outstandingChange().application().get().id());
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.systemTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.stagingTest);
    tester.deployAndNotify(app, applicationPackage, true, DeploymentJobs.JobType.productionUsWest1);
    assertEquals("Upgrade done", 0, tester.deploymentQueue().jobs().size());
    deployer.maintain();
    tester.deploymentTrigger().triggerReadyJobs();
    app = tester.application("app1");
    assertEquals("1.0.43-cafed00d", app.change().application().get().id());
    List<BuildService.BuildJob> jobs = tester.deploymentQueue().jobs();
    assertEquals(1, jobs.size());
    assertEquals(11, jobs.get(0).projectId());
    assertEquals(DeploymentJobs.JobType.systemTest.jobName(), jobs.get(0).jobName());
    assertFalse(tester.application("app1").outstandingChange().isPresent());
}
Also used : SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) 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)

Example 23 with Application

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

the class DeploymentApiTest method testDeploymentApi.

@Test
public void testDeploymentApi() throws IOException {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    Version version = Version.fromString("5.0");
    tester.containerTester().updateSystemVersion(version);
    long projectId = 11;
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
    // 3 applications deploy on current system version
    Application failingApplication = tester.createApplication("domain1", "tenant1", "application1");
    Application productionApplication = tester.createApplication("domain2", "tenant2", "application2");
    Application applicationWithoutDeployment = tester.createApplication("domain3", "tenant3", "application3");
    deployCompletely(failingApplication, applicationPackage, projectId, true);
    deployCompletely(productionApplication, applicationPackage, projectId, true);
    // Deploy once so that job information is stored, then remove the deployment
    deployCompletely(applicationWithoutDeployment, applicationPackage, projectId, true);
    tester.controller().applications().deactivate(applicationWithoutDeployment, ZoneId.from("prod", "corp-us-east-1"));
    // New version released
    version = Version.fromString("5.1");
    tester.containerTester().updateSystemVersion(version);
    // Applications upgrade, 1/2 succeed
    tester.upgrader().maintain();
    tester.controller().applications().deploymentTrigger().triggerReadyJobs();
    deployCompletely(failingApplication, applicationPackage, projectId, false);
    deployCompletely(productionApplication, applicationPackage, projectId, true);
    tester.controller().updateVersionStatus(censorConfigServers(VersionStatus.compute(tester.controller()), tester.controller()));
    tester.assertResponse(authenticatedRequest("http://localhost:8080/deployment/v1/"), new File("root.json"));
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) Version(com.yahoo.component.Version) VespaVersion(com.yahoo.vespa.hosted.controller.versions.VespaVersion) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 24 with Application

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

the class ScrewdriverApiTest method testTriggerJobForApplication.

@Test
public void testTriggerJobForApplication() {
    ContainerControllerTester tester = new ContainerControllerTester(container, responseFiles);
    DeploymentQueue deploymentQueue = tester.controller().applications().deploymentTrigger().deploymentQueue();
    tester.containerTester().updateSystemVersion();
    Application app = tester.createApplication();
    tester.controller().applications().lockOrThrow(app.id(), application -> tester.controller().applications().store(application.withProjectId(1)));
    // Unknown application
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/foo/application/bar", new byte[0], Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"foo.bar not found\"}");
    // Invalid job
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "invalid".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 400, "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Unknown job name 'invalid'\"}");
    // component is triggered if no job is specified in request body
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), new byte[0], Request.Method.POST), 200, "{\"message\":\"Triggered component for tenant1.application1\"}");
    assertFalse(deploymentQueue.jobs().isEmpty());
    assertEquals(JobType.component.jobName(), deploymentQueue.jobs().get(0).jobName());
    assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
    deploymentQueue.takeJobsToRun();
    // Triggers specific job when given
    assertResponse(new Request("http://localhost:8080/screwdriver/v1/trigger/tenant/" + app.id().tenant().value() + "/application/" + app.id().application().value(), "staging-test".getBytes(StandardCharsets.UTF_8), Request.Method.POST), 200, "{\"message\":\"Triggered staging-test for tenant1.application1\"}");
    assertFalse(deploymentQueue.jobs().isEmpty());
    assertEquals(JobType.stagingTest.jobName(), deploymentQueue.jobs().get(0).jobName());
    assertEquals(1L, deploymentQueue.jobs().get(0).projectId());
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) Request(com.yahoo.application.container.handler.Request) Application(com.yahoo.vespa.hosted.controller.Application) DeploymentQueue(com.yahoo.vespa.hosted.controller.deployment.DeploymentQueue) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 25 with Application

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

the class RotationTest method strips_whitespace_in_rotation_fqdn.

@Test
public void strips_whitespace_in_rotation_fqdn() {
    DeploymentTester tester = new DeploymentTester(new ControllerTester(rotationsConfigWhitespaces));
    RotationRepository repository = tester.controller().applications().rotationRepository();
    Application application = tester.createApplication("app2", "tenant2", 22L, 2L);
    tester.deployCompletely(application, applicationPackage);
    application = tester.applications().require(application.id());
    try (RotationLock lock = repository.lock()) {
        Rotation rotation = repository.getRotation(application, lock);
        Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com");
        assertEquals(assignedRotation, rotation);
    }
}
Also used : DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationRotation(com.yahoo.vespa.hosted.controller.application.ApplicationRotation) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) 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