Search in sources :

Example 1 with ApplicationSerializer

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());
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob) ApplicationSerializer(com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test)

Example 2 with ApplicationSerializer

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;
}
Also used : ApplicationSerializer(com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer) Lock(com.yahoo.vespa.curator.Lock)

Aggregations

ApplicationSerializer (com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer)2 Lock (com.yahoo.vespa.curator.Lock)1 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)1 ScrewdriverBuildJob (com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)1 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)1 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)1 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)1 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)1 Test (org.junit.Test)1