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