use of com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer 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());
}
use of com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer in project vespa by vespa-engine.
the class ControllerTester method createApplication.
/**
* Create application from slime
*/
public Application createApplication(Slime slime) {
ApplicationSerializer serializer = new ApplicationSerializer();
Application application = serializer.fromSlime(slime);
try (Lock lock = controller().applications().lock(application.id())) {
controller().applications().store(new LockedApplication(application, lock));
}
return application;
}
Aggregations