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());
}
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"));
}
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());
}
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());
}
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()));
}
});
}
Aggregations