Search in sources :

Example 1 with ScrewdriverId

use of com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId in project vespa by vespa-engine.

the class ApplicationApiTest method deployment_succeeds_when_correct_domain_is_used.

@Test
public void deployment_succeeds_when_correct_domain_is_used() throws IOException {
    ContainerControllerTester controllerTester = new ContainerControllerTester(container, responseFiles);
    ContainerTester tester = controllerTester.containerTester();
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().upgradePolicy("default").athenzIdentity(com.yahoo.config.provision.AthenzDomain.from("domain1"), com.yahoo.config.provision.AthenzService.from("service")).environment(Environment.prod).region("us-west-1").build();
    long screwdriverProjectId = 123;
    ScrewdriverId screwdriverId = new ScrewdriverId(Long.toString(screwdriverProjectId));
    createAthenzDomainWithAdmin(ATHENZ_TENANT_DOMAIN, USER_ID);
    Application application = controllerTester.createApplication(ATHENZ_TENANT_DOMAIN.getName(), "tenant1", "application1");
    controllerTester.authorize(ATHENZ_TENANT_DOMAIN, screwdriverId, ApplicationAction.deploy, application);
    // Allow systemtest to succeed by notifying completion of system test
    controllerTester.jobCompletion(DeploymentJobs.JobType.component).application(application.id()).projectId(screwdriverProjectId).uploadArtifact(applicationPackage).submit();
    tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/environment/test/region/us-east-1/instance/default/", POST).data(createApplicationDeployData(applicationPackage, Optional.of(screwdriverProjectId))).screwdriverIdentity(screwdriverId), new File("deploy-result.json"));
}
Also used : ContainerControllerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) ContainerTester(com.yahoo.vespa.hosted.controller.restapi.ContainerTester) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Application(com.yahoo.vespa.hosted.controller.Application) File(java.io.File) ControllerContainerTest(com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest) Test(org.junit.Test)

Example 2 with ScrewdriverId

use of com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId 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 3 with ScrewdriverId

use of com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId in project vespa by vespa-engine.

the class ApplicationApiHandler method toSlime.

private void toSlime(Cursor response, DeploymentId deploymentId, Deployment deployment, HttpRequest request) {
    Cursor serviceUrlArray = response.setArray("serviceUrls");
    controller.applications().getDeploymentEndpoints(deploymentId).ifPresent(endpoints -> endpoints.forEach(endpoint -> serviceUrlArray.addString(endpoint.toString())));
    response.setString("nodes", withPath("/zone/v2/" + deploymentId.zoneId().environment() + "/" + deploymentId.zoneId().region() + "/nodes/v2/node/?&recursive=true&application=" + deploymentId.applicationId().tenant() + "." + deploymentId.applicationId().application() + "." + deploymentId.applicationId().instance(), request.getUri()).toString());
    controller.zoneRegistry().getLogServerUri(deploymentId).ifPresent(elkUrl -> response.setString("elkUrl", elkUrl.toString()));
    response.setString("yamasUrl", monitoringSystemUri(deploymentId).toString());
    response.setString("version", deployment.version().toFullString());
    response.setString("revision", deployment.applicationVersion().id());
    response.setLong("deployTimeEpochMs", deployment.at().toEpochMilli());
    controller.zoneRegistry().getDeploymentTimeToLive(deploymentId.zoneId()).ifPresent(deploymentTimeToLive -> response.setLong("expiryTimeEpochMs", deployment.at().plus(deploymentTimeToLive).toEpochMilli()));
    controller.applications().get(deploymentId.applicationId()).flatMap(application -> application.deploymentJobs().projectId()).ifPresent(i -> response.setString("screwdriverId", String.valueOf(i)));
    sourceRevisionToSlime(deployment.applicationVersion().source(), response);
    // Cost
    DeploymentCost appCost = deployment.calculateCost();
    Cursor costObject = response.setObject("cost");
    toSlime(appCost, costObject);
    // Metrics
    DeploymentMetrics metrics = deployment.metrics();
    Cursor metricsObject = response.setObject("metrics");
    metricsObject.setDouble("queriesPerSecond", metrics.queriesPerSecond());
    metricsObject.setDouble("writesPerSecond", metrics.writesPerSecond());
    metricsObject.setDouble("documentCount", metrics.documentCount());
    metricsObject.setDouble("queryLatencyMillis", metrics.queryLatencyMillis());
    metricsObject.setDouble("writeLatencyMillis", metrics.writeLatencyMillis());
}
Also used : AlreadyExistsException(com.yahoo.vespa.hosted.controller.AlreadyExistsException) EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) Inject(com.google.inject.Inject) URISyntaxException(java.net.URISyntaxException) SlimeJsonResponse(com.yahoo.vespa.hosted.controller.restapi.SlimeJsonResponse) Scanner(java.util.Scanner) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) ConfigServerException(com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException) RegionName(com.yahoo.config.provision.RegionName) TenantName(com.yahoo.config.provision.TenantName) ResourceResponse(com.yahoo.vespa.hosted.controller.restapi.ResourceResponse) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ClusterUtilization(com.yahoo.vespa.hosted.controller.application.ClusterUtilization) Duration(java.time.Duration) Map(java.util.Map) LogLevel(com.yahoo.log.LogLevel) Path(com.yahoo.vespa.hosted.controller.restapi.Path) JobStatus(com.yahoo.vespa.hosted.controller.application.JobStatus) GitRevision(com.yahoo.vespa.hosted.controller.api.application.v4.model.GitRevision) ClusterCost(com.yahoo.vespa.hosted.controller.application.ClusterCost) BadRequestException(javax.ws.rs.BadRequestException) DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) URI(java.net.URI) DeploymentCost(com.yahoo.vespa.hosted.controller.application.DeploymentCost) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob) Exceptions(com.yahoo.yolean.Exceptions) AthenzDomain(com.yahoo.vespa.athenz.api.AthenzDomain) ImmutableSet(com.google.common.collect.ImmutableSet) Inspector(com.yahoo.slime.Inspector) NotExistsException(com.yahoo.vespa.hosted.controller.NotExistsException) ApplicationVersion(com.yahoo.vespa.hosted.controller.application.ApplicationVersion) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) ErrorResponse(com.yahoo.vespa.hosted.controller.restapi.ErrorResponse) RestartAction(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RestartAction) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) ApplicationView(com.yahoo.vespa.serviceview.bindings.ApplicationView) Objects(java.util.Objects) ZmsException(com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsException) List(java.util.List) Principal(java.security.Principal) AthenzPrincipal(com.yahoo.vespa.athenz.api.AthenzPrincipal) NotAuthorizedException(javax.ws.rs.NotAuthorizedException) Optional(java.util.Optional) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Controller(com.yahoo.vespa.hosted.controller.Controller) Joiner(com.google.common.base.Joiner) Log(com.yahoo.vespa.hosted.controller.api.integration.configserver.Log) AthenzClientFactory(com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory) GitRepository(com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository) ApplicationName(com.yahoo.config.provision.ApplicationName) AthenzUser(com.yahoo.vespa.athenz.api.AthenzUser) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId) RefeedAction(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.RefeedAction) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) Slime(com.yahoo.slime.Slime) AthenzIdentity(com.yahoo.vespa.athenz.api.AthenzIdentity) IOUtils(com.yahoo.io.IOUtils) NToken(com.yahoo.vespa.athenz.api.NToken) Level(java.util.logging.Level) DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) ApplicationResource(com.yahoo.vespa.hosted.controller.api.application.v4.ApplicationResource) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) Change(com.yahoo.vespa.hosted.controller.application.Change) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) GitBranch(com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch) ServiceInfo(com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ServiceInfo) SetBouncerPassthruHeaderFilter(com.yahoo.vespa.hosted.controller.restapi.filter.SetBouncerPassthruHeaderFilter) EnvironmentResource(com.yahoo.vespa.hosted.controller.api.application.v4.EnvironmentResource) TenantResource(com.yahoo.vespa.hosted.controller.api.application.v4.TenantResource) Application(com.yahoo.vespa.hosted.controller.Application) ActivateResult(com.yahoo.vespa.hosted.controller.api.ActivateResult) Cursor(com.yahoo.slime.Cursor) StringResponse(com.yahoo.vespa.hosted.controller.restapi.StringResponse) ForbiddenException(javax.ws.rs.ForbiddenException) Hostname(com.yahoo.vespa.hosted.controller.api.identifiers.Hostname) Environment(com.yahoo.config.provision.Environment) GitCommit(com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit) HttpRequest(com.yahoo.container.jdisc.HttpRequest) SourceRevision(com.yahoo.vespa.hosted.controller.application.SourceRevision) IOException(java.io.IOException) MessageResponse(com.yahoo.vespa.hosted.controller.restapi.MessageResponse) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) LoggingRequestHandler(com.yahoo.container.jdisc.LoggingRequestHandler) User(com.yahoo.vespa.hosted.controller.api.integration.organization.User) UserId(com.yahoo.vespa.hosted.controller.api.identifiers.UserId) RotationStatus(com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) DayOfWeek(java.time.DayOfWeek) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) Collections(java.util.Collections) InputStream(java.io.InputStream) DeploymentMetrics(com.yahoo.vespa.hosted.controller.application.DeploymentMetrics) Cursor(com.yahoo.slime.Cursor) DeploymentCost(com.yahoo.vespa.hosted.controller.application.DeploymentCost)

Example 4 with ScrewdriverId

use of com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId in project vespa by vespa-engine.

the class ControllerTester method deploy.

public void deploy(Application application, ZoneId zone, Optional<ApplicationPackage> applicationPackage, boolean deployCurrentVersion) {
    ScrewdriverId app1ScrewdriverId = new ScrewdriverId(String.valueOf(application.deploymentJobs().projectId().get()));
    GitRevision app1RevisionId = new GitRevision(new GitRepository("repo"), new GitBranch("master"), new GitCommit("commit1"));
    controller().applications().deployApplication(application.id(), zone, applicationPackage, new DeployOptions(Optional.of(new ScrewdriverBuildJob(app1ScrewdriverId, app1RevisionId)), Optional.empty(), false, deployCurrentVersion));
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) GitRepository(com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository) GitRevision(com.yahoo.vespa.hosted.controller.api.application.v4.model.GitRevision) GitCommit(com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit) GitBranch(com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)

Example 5 with ScrewdriverId

use of com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId in project vespa by vespa-engine.

the class ContainerControllerTester method deploy.

public Application deploy(Application application, ApplicationPackage applicationPackage, ZoneId zone, long projectId) {
    ScrewdriverId app1ScrewdriverId = new ScrewdriverId(String.valueOf(projectId));
    GitRevision app1RevisionId = new GitRevision(new GitRepository("repo"), new GitBranch("master"), new GitCommit("commit1"));
    controller().applications().deployApplication(application.id(), zone, Optional.of(applicationPackage), new DeployOptions(Optional.of(new ScrewdriverBuildJob(app1ScrewdriverId, app1RevisionId)), Optional.empty(), false, false));
    return application;
}
Also used : DeployOptions(com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions) ScrewdriverId(com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId) GitRepository(com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository) GitRevision(com.yahoo.vespa.hosted.controller.api.application.v4.model.GitRevision) GitCommit(com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit) GitBranch(com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch) ScrewdriverBuildJob(com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)

Aggregations

ScrewdriverId (com.yahoo.vespa.hosted.controller.api.identifiers.ScrewdriverId)6 DeployOptions (com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions)4 ScrewdriverBuildJob (com.yahoo.vespa.hosted.controller.api.application.v4.model.ScrewdriverBuildJob)4 Application (com.yahoo.vespa.hosted.controller.Application)3 GitRevision (com.yahoo.vespa.hosted.controller.api.application.v4.model.GitRevision)3 GitBranch (com.yahoo.vespa.hosted.controller.api.identifiers.GitBranch)3 GitCommit (com.yahoo.vespa.hosted.controller.api.identifiers.GitCommit)3 GitRepository (com.yahoo.vespa.hosted.controller.api.identifiers.GitRepository)3 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)3 Test (org.junit.Test)3 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)2 Joiner (com.google.common.base.Joiner)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Inject (com.google.inject.Inject)1 Version (com.yahoo.component.Version)1 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ApplicationName (com.yahoo.config.provision.ApplicationName)1 Environment (com.yahoo.config.provision.Environment)1 RegionName (com.yahoo.config.provision.RegionName)1