use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.
the class ApplicationApiHandler method deploy.
private HttpResponse deploy(String tenantName, String applicationName, String instanceName, String environment, String region, HttpRequest request) {
ApplicationId applicationId = ApplicationId.from(tenantName, applicationName, instanceName);
ZoneId zone = ZoneId.from(environment, region);
Map<String, byte[]> dataParts = new MultipartParser().parse(request);
if (!dataParts.containsKey("deployOptions"))
return ErrorResponse.badRequest("Missing required form part 'deployOptions'");
Inspector deployOptions = SlimeUtils.jsonToSlime(dataParts.get("deployOptions")).get();
Optional<ApplicationPackage> applicationPackage = Optional.ofNullable(dataParts.get("applicationZip")).map(ApplicationPackage::new);
verifyApplicationIdentityConfiguration(tenantName, applicationPackage);
// TODO: get rid of the json object
DeployOptions deployOptionsJsonClass = new DeployOptions(screwdriverBuildJobFromSlime(deployOptions.field("screwdriverBuildJob")), optional("vespaVersion", deployOptions).map(Version::new), deployOptions.field("ignoreValidationErrors").asBool(), deployOptions.field("deployCurrentVersion").asBool());
ActivateResult result = controller.applications().deployApplication(applicationId, zone, applicationPackage, deployOptionsJsonClass);
return new SlimeJsonResponse(toSlime(result));
}
use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.
the class ApplicationController method artifactFor.
/**
* Decide application package and version pair to use in given zone
*/
private Pair<ApplicationPackage, ApplicationVersion> artifactFor(ZoneId zone, Application application, Optional<ApplicationPackage> applicationPackage, boolean canDeployDirectly, boolean deployCurrentVersion) {
ApplicationVersion version;
ApplicationPackage pkg;
Optional<DeploymentJobs.JobType> job = DeploymentJobs.JobType.from(controller.system(), zone);
if (canDeployDirectly) {
pkg = applicationPackage.orElseThrow(() -> new IllegalArgumentException("Application package must be " + "given when deploying to " + zone));
version = ApplicationVersion.unknown;
} else {
if (!job.isPresent()) {
throw new IllegalArgumentException("No job found for zone " + zone);
}
version = application.deployApplicationVersionFor(job.get(), controller, deployCurrentVersion).orElseThrow(() -> new IllegalArgumentException("Cannot determine application version to use for " + job.get()));
pkg = new ApplicationPackage(artifactRepository.getApplicationPackage(application.id(), version.id()));
}
return new Pair<>(pkg, version);
}
use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.
the class DeploymentTriggerTest method testBlockRevisionChange.
@Test
public void testBlockRevisionChange() {
// Tuesday, 17:30
ManualClock clock = new ManualClock(Instant.parse("2017-09-26T17:30:00.00Z"));
DeploymentTester tester = new DeploymentTester(new ControllerTester(clock));
ReadyJobsTrigger readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), Duration.ofHours(1), new JobControl(tester.controllerTester().curator()));
Version version = Version.fromString("5.0");
tester.updateVersionStatus(version);
ApplicationPackageBuilder applicationPackageBuilder = new ApplicationPackageBuilder().upgradePolicy("canary").blockChange(true, false, "tue", "18-19", "UTC").region("us-west-1").region("us-central-1").region("us-east-3");
Application app = tester.createAndDeploy("app1", 1, applicationPackageBuilder.build());
// --------------- Enter block window: 18:30
tester.clock().advance(Duration.ofHours(1));
readyJobsTrigger.run();
assertEquals(0, tester.deploymentQueue().jobs().size());
String searchDefinition = "search test {\n" + " document test {\n" + " field test type string {\n" + " }\n" + " }\n" + "}\n";
ApplicationPackage changedApplication = applicationPackageBuilder.searchDefinition(searchDefinition).build();
tester.jobCompletion(component).application(app).nextBuildNumber().sourceRevision(new SourceRevision("repository1", "master", "cafed00d")).uploadArtifact(changedApplication).submit();
assertTrue(tester.applications().require(app.id()).change().isPresent());
tester.deployAndNotify(app, changedApplication, true, systemTest);
tester.deployAndNotify(app, changedApplication, true, stagingTest);
readyJobsTrigger.run();
assertEquals(0, tester.deploymentQueue().jobs().size());
// ---------------- Exit block window: 20:30
tester.clock().advance(Duration.ofHours(2));
// Schedules the blocked production job(s)
tester.deploymentTrigger().triggerReadyJobs();
assertEquals(1, tester.deploymentQueue().jobs().size());
BuildService.BuildJob productionJob = tester.deploymentQueue().takeJobsToRun().get(0);
assertEquals("production-us-west-1", productionJob.jobName());
}
use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.
the class DeploymentTriggerTest method testHandleMultipleNotificationsFromLastJob.
@Test
public void testHandleMultipleNotificationsFromLastJob() {
DeploymentTester tester = new DeploymentTester();
DeploymentQueue deploymentQueue = tester.deploymentQueue();
TenantId tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L);
Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L);
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").build();
// Component job finishes
tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
// Application is deployed to all test environments and declared zones
tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest);
tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest);
tester.deployAndNotify(application, applicationPackage, true, JobType.productionCorpUsEast1);
// Extra notification for last job
tester.jobCompletion(JobType.productionCorpUsEast1).application(application).submit();
assertFalse("Change has been deployed", tester.applications().require(application.id()).change().isPresent());
assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
use of com.yahoo.vespa.hosted.controller.application.ApplicationPackage in project vespa by vespa-engine.
the class DeploymentTriggerTest method testSuccessfulDeploymentApplicationPackageChanged.
@Test
public void testSuccessfulDeploymentApplicationPackageChanged() {
DeploymentTester tester = new DeploymentTester();
DeploymentQueue deploymentQueue = tester.deploymentQueue();
TenantId tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L);
Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L);
ApplicationPackage previousApplicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-central-1").region("us-west-1").build();
ApplicationPackage newApplicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-central-1").region("us-west-1").region("eu-west-1").build();
// Component job finishes
tester.jobCompletion(component).application(application).uploadArtifact(newApplicationPackage).submit();
// Application is deployed to all test environments and declared zones
tester.deployAndNotify(application, newApplicationPackage, true, JobType.systemTest);
tester.deploy(JobType.stagingTest, application, previousApplicationPackage, true);
tester.deployAndNotify(application, newApplicationPackage, true, JobType.stagingTest);
tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionCorpUsEast1);
tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsCentral1);
tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionUsWest1);
tester.deployAndNotify(application, newApplicationPackage, true, JobType.productionEuWest1);
assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
Aggregations