use of com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions in project vespa by vespa-engine.
the class ControllerTest method testDeployWithoutProjectId.
@Test
public void testDeployWithoutProjectId() {
DeploymentTester tester = new DeploymentTester();
tester.controllerTester().zoneRegistry().setSystem(SystemName.cd);
tester.controllerTester().zoneRegistry().setZones(ZoneId.from("prod", "cd-us-central-1"));
ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("cd-us-central-1").build();
// Create application
Application app = tester.createApplication("app1", "tenant1", 1, 2L);
// Direct deploy is allowed when project ID is missing
ZoneId zone = ZoneId.from("prod", "cd-us-central-1");
// Same options as used in our integration tests
DeployOptions options = new DeployOptions(Optional.empty(), Optional.empty(), false, false);
tester.controller().applications().deployApplication(app.id(), zone, Optional.of(applicationPackage), options);
assertTrue("Application deployed and activated", tester.controllerTester().configServer().activated().getOrDefault(app.id(), false));
assertTrue("No job status added", tester.applications().require(app.id()).deploymentJobs().jobStatus().isEmpty());
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions 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.api.application.v4.model.DeployOptions in project vespa by vespa-engine.
the class DeployOptionsTest method it_serializes_version.
@Test
public void it_serializes_version() throws IOException {
DeployOptions options = new DeployOptions(Optional.empty(), Optional.of(new Version("6.98.227")), false, false);
final ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).registerModule(new Jdk8Module());
String string = objectMapper.writeValueAsString(options);
assertEquals("{\"screwdriverBuildJob\":null,\"vespaVersion\":\"6.98.227\",\"ignoreValidationErrors\":false,\"deployCurrentVersion\":false}", string);
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions in project vespa by vespa-engine.
the class ConfigServerClientMock method prepare.
@Override
public PreparedApplication prepare(DeploymentId deployment, DeployOptions deployOptions, Set<String> rotationCnames, Set<String> rotationNames, byte[] content) {
lastPrepareVersion = deployOptions.vespaVersion.map(Version::new).orElse(null);
if (prepareException != null) {
RuntimeException prepareException = this.prepareException;
this.prepareException = null;
throw prepareException;
}
applicationActivated.put(deployment.applicationId(), false);
applicationInstances.put(deployment.applicationId(), UUID.randomUUID() + ":4080");
return new PreparedApplication() {
@Override
public void activate() {
applicationActivated.put(deployment.applicationId(), true);
}
@Override
public List<Log> messages() {
Log warning = new Log();
warning.level = "WARNING";
warning.time = 1;
warning.message = "The warning";
Log info = new Log();
info.level = "INFO";
info.time = 2;
info.message = "The info";
return Arrays.asList(warning, info);
}
@Override
public PrepareResponse prepareResponse() {
PrepareResponse prepareResponse = new PrepareResponse();
prepareResponse.message = "foo";
prepareResponse.configChangeActions = new ConfigChangeActions(Collections.emptyList(), Collections.emptyList());
prepareResponse.tenant = new TenantId("tenant");
return prepareResponse;
}
};
}
use of com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions in project vespa by vespa-engine.
the class ControllerTest method testDeploymentOfNewInstanceWithIllegalApplicationName.
@Test
public void testDeploymentOfNewInstanceWithIllegalApplicationName() {
ControllerTester tester = new ControllerTester();
String application = "this_application_name_is_far_too_long_and_has_underscores";
ZoneId zone = ZoneId.from("test", "us-east-1");
DeployOptions options = new DeployOptions(Optional.of(new ScrewdriverBuildJob(new ScrewdriverId("123"), null)), Optional.empty(), false, false);
tester.createTenant("tenant", "domain", null);
// Deploy an application which doesn't yet exist, and which has an illegal application name.
try {
tester.controller().applications().deployApplication(ApplicationId.from("tenant", application, "123"), zone, Optional.empty(), options);
fail("Illegal application name should cause validation exception.");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("Invalid id"));
}
// Sneak an illegal application in the back door.
tester.createApplication(new ApplicationSerializer().toSlime(new Application(ApplicationId.from("tenant", application, "default"))));
// Deploy a PR instance for the application, with no NToken.
tester.controller().applications().deployApplication(ApplicationId.from("tenant", application, "456"), zone, Optional.empty(), options);
assertTrue(tester.controller().applications().get(ApplicationId.from("tenant", application, "456")).isPresent());
}
Aggregations