Search in sources :

Example 1 with DeployOptions

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());
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) 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 DeployOptions

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));
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Inspector(com.yahoo.slime.Inspector) ApplicationId(com.yahoo.config.provision.ApplicationId) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage)

Example 3 with DeployOptions

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);
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) Version(com.yahoo.component.Version) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with DeployOptions

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;
        }
    };
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) PrepareResponse(com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse) Version(com.yahoo.component.Version) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) ConfigChangeActions(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)

Example 5 with DeployOptions

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

Aggregations

DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)4 Version (com.yahoo.component.Version)3 ScrewdriverBuildJob (com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)3 ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ActivateResult (com.yahoo.vespa.hosted.controller.api.ActivateResult)2 GitRevision (com.yahoo.vespa.hosted.controller.api.application.v4.model.GitRevision)2 ConfigChangeActions (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)2 GitBranch (com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch)2 GitCommit (com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit)2 GitRepository (com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository)2 TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)2 Log (com.yahoo.vespa.hosted.controller.api.integration.configserver.Log)2 PrepareResponse (com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse)2 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Jdk8Module (com.fasterxml.jackson.datatype.jdk8.Jdk8Module)1 ImmutableList (com.google.common.collect.ImmutableList)1