Search in sources :

Example 21 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage 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 22 with ApplicationPackage

use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage 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 23 with ApplicationPackage

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

the class RotationTest method assigns_and_reuses_rotation.

@Test
public void assigns_and_reuses_rotation() {
    // Deploying assigns a rotation
    tester.deployCompletely(application, applicationPackage);
    Rotation expected = new Rotation(new RotationId("foo-1"), "foo-1.com");
    application = tester.applications().require(application.id());
    assertEquals(expected.id(), application.rotation().get().id());
    assertEquals(URI.create("http://app1.tenant1.global.vespa.yahooapis.com:4080/"), application.rotation().get().url());
    try (RotationLock lock = repository.lock()) {
        Rotation rotation = repository.getRotation(tester.applications().require(application.id()), lock);
        assertEquals(expected, rotation);
    }
    // Deploying once more assigns same rotation
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().globalServiceId("foo").region("us-east-3").region("us-west-1").searchDefinition(// Update application package so there is something to deploy
    "search foo { }").build();
    tester.deployCompletely(application, applicationPackage, 43);
    assertEquals(expected.id(), tester.applications().require(application.id()).rotation().get().id());
}
Also used : ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationRotation(com.yahoo.vespa.hosted.controller.application.ApplicationRotation) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Test(org.junit.Test)

Example 24 with ApplicationPackage

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

the class RotationTest method no_rotation_assigned_for_application_without_service_id.

@Test
public void no_rotation_assigned_for_application_without_service_id() {
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().region("us-east-3").region("us-west-1").build();
    tester.deployCompletely(application, applicationPackage);
    Application app = tester.applications().require(application.id());
    Optional<ApplicationRotation> rotation = app.rotation();
    assertFalse(rotation.isPresent());
}
Also used : ApplicationRotation(com.yahoo.vespa.hosted.controller.application.ApplicationRotation) 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 25 with ApplicationPackage

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

the class ApplicationApiHandler method verifyApplicationIdentityConfiguration.

private void verifyApplicationIdentityConfiguration(String tenantName, Optional<ApplicationPackage> applicationPackage) {
    // Validate that domain in identity configuration (deployment.xml) is same as tenant domain
    applicationPackage.map(ApplicationPackage::deploymentSpec).flatMap(DeploymentSpec::athenzDomain).ifPresent(identityDomain -> {
        Tenant tenant = controller.tenants().tenant(new TenantId(tenantName)).orElseThrow(() -> new IllegalArgumentException("Tenant does not exist"));
        AthenzDomain tenantDomain = tenant.getAthensDomain().orElseThrow(() -> new IllegalArgumentException("Identity provider only available to Athenz onboarded tenants"));
        if (!Objects.equals(tenantDomain.getName(), identityDomain.value())) {
            throw new ForbiddenException(String.format("Athenz domain in deployment.xml: [%s] must match tenant domain: [%s]", identityDomain.value(), tenantDomain.getName()));
        }
    });
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) ForbiddenException(javax.ws.rs.ForbiddenException) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage)

Aggregations

ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)50 Test (org.junit.Test)44 Application (com.yahoo.vespa.hosted.controller.Application)37 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)33 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)31 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)26 Version (com.yahoo.component.Version)23 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)22 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)11 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)10 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)10 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)8 ApplicationId (com.yahoo.config.provision.ApplicationId)5 ManualClock (com.yahoo.test.ManualClock)5 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)5 Environment (com.yahoo.config.provision.Environment)4 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)4 BuildService (com.yahoo.vespa.hosted.controller.api.integration.BuildService)4 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)4