Search in sources :

Example 1 with TenantId

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

the class ControllerTester method createAndDeploy.

/**
 * Creates the given tenant and application and deploys it
 */
public Application createAndDeploy(String tenantName, String domainName, String applicationName, String instanceName, ZoneId zone, long projectId, Long propertyId) {
    TenantId tenant = createTenant(tenantName, domainName, propertyId);
    Application application = createApplication(tenant, applicationName, instanceName, projectId);
    deploy(application, zone);
    return application;
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)

Example 2 with TenantId

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

the class ControllerTester method createTenant.

public TenantId createTenant(String tenantName, String domainName, Long propertyId) {
    TenantId id = new TenantId(tenantName);
    Optional<Tenant> existing = controller().tenants().tenant(id);
    if (existing.isPresent())
        return id;
    Tenant tenant = Tenant.createAthensTenant(id, createDomain(domainName), new Property("app1Property"), propertyId == null ? Optional.empty() : Optional.of(new PropertyId(propertyId.toString())));
    controller().tenants().createAthenzTenant(tenant, TestIdentities.userNToken);
    assertNotNull(controller().tenants().tenant(id));
    return id;
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) Property(com.yahoo.vespa.hosted.controller.api.identifiers.Property) PropertyId(com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)

Example 3 with TenantId

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

the class DeploymentTriggerTest method deploymentSpecDecidesTriggerOrder.

@Test
public void deploymentSpecDecidesTriggerOrder() {
    DeploymentTester tester = new DeploymentTester();
    DeploymentQueue deploymentQueue = tester.deploymentQueue();
    TenantId tenant = tester.controllerTester().createTenant("tenant1", "domain1", 1L);
    Application application = tester.controllerTester().createApplication(tenant, "app1", "default", 1L);
    ApplicationPackage applicationPackage = new ApplicationPackageBuilder().environment(Environment.prod).region("corp-us-east-1").region("us-central-1").region("us-west-1").build();
    // Component job finishes
    tester.jobCompletion(component).application(application).uploadArtifact(applicationPackage).submit();
    // Application is deployed to all test environments and declared zones
    tester.deployAndNotify(application, applicationPackage, true, JobType.systemTest);
    tester.deployAndNotify(application, applicationPackage, true, JobType.stagingTest);
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionCorpUsEast1);
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsCentral1);
    tester.deployAndNotify(application, applicationPackage, true, JobType.productionUsWest1);
    assertTrue("All jobs consumed", deploymentQueue.jobs().isEmpty());
}
Also used : TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Application(com.yahoo.vespa.hosted.controller.Application) LockedApplication(com.yahoo.vespa.hosted.controller.LockedApplication) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) Test(org.junit.Test) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 4 with TenantId

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

the class VersionStatusTest method testVersionConfidence.

@Test
public void testVersionConfidence() {
    DeploymentTester tester = new DeploymentTester();
    Version version0 = new Version("5.0");
    tester.upgradeSystem(version0);
    // Setup applications - all running on version0
    Application canary0 = tester.createAndDeploy("canary0", 1, "canary");
    Application canary1 = tester.createAndDeploy("canary1", 2, "canary");
    Application canary2 = tester.createAndDeploy("canary2", 3, "canary");
    Application default0 = tester.createAndDeploy("default0", 4, "default");
    Application default1 = tester.createAndDeploy("default1", 5, "default");
    Application default2 = tester.createAndDeploy("default2", 6, "default");
    Application default3 = tester.createAndDeploy("default3", 7, "default");
    Application default4 = tester.createAndDeploy("default4", 8, "default");
    Application default5 = tester.createAndDeploy("default5", 9, "default");
    Application default6 = tester.createAndDeploy("default6", 10, "default");
    Application default7 = tester.createAndDeploy("default7", 11, "default");
    Application default8 = tester.createAndDeploy("default8", 12, "default");
    Application default9 = tester.createAndDeploy("default9", 13, "default");
    Application conservative0 = tester.createAndDeploy("conservative1", 14, "conservative");
    // Applications that do not affect confidence calculation:
    // Application without deployment
    Application ignored0 = tester.createApplication("ignored0", "tenant1", 1000, 1000L);
    // Pull request builds
    tester.controllerTester().createApplication(new TenantId("tenant1"), "ignored1", "43", 1000);
    assertEquals("All applications running on this version: High", Confidence.high, confidence(tester.controller(), version0));
    // New version is released
    Version version1 = new Version("5.1");
    tester.upgradeSystem(version1);
    // Canaries upgrade to new versions and fail
    tester.completeUpgrade(canary0, version1, "canary");
    tester.completeUpgradeWithError(canary1, version1, "canary", productionUsWest1);
    tester.updateVersionStatus();
    assertEquals("One canary failed: Broken", Confidence.broken, confidence(tester.controller(), version1));
    // New version is released
    Version version2 = new Version("5.2");
    tester.upgradeSystem(version2);
    assertEquals("Confidence defaults to low for version with no applications", Confidence.low, confidence(tester.controller(), version2));
    // All canaries upgrade successfully
    tester.completeUpgrade(canary0, version2, "canary");
    tester.jobCompletion(productionUsWest1).application(canary1).unsuccessful().submit();
    tester.completeUpgrade(canary1, version2, "canary");
    assertEquals("Confidence for remains unchanged for version1: Broken", Confidence.broken, confidence(tester.controller(), version1));
    assertEquals("Nothing has failed but not all canaries have upgraded: Low", Confidence.low, confidence(tester.controller(), version2));
    // Remaining canary upgrades to version2 which raises confidence to normal and more apps upgrade
    tester.jobCompletion(systemTest).application(canary2).unsuccessful().submit();
    tester.completeUpgrade(canary2, version2, "canary");
    tester.upgradeSystem(version2);
    assertEquals("Canaries have upgraded: Normal", Confidence.normal, confidence(tester.controller(), version2));
    tester.completeUpgrade(default0, version2, "default");
    tester.completeUpgrade(default1, version2, "default");
    tester.completeUpgrade(default2, version2, "default");
    tester.completeUpgrade(default3, version2, "default");
    tester.completeUpgrade(default4, version2, "default");
    tester.completeUpgrade(default5, version2, "default");
    tester.completeUpgrade(default6, version2, "default");
    tester.completeUpgrade(default7, version2, "default");
    tester.updateVersionStatus();
    // Remember confidence across restart
    tester.restartController();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("All canaries deployed + < 90% of defaults: Normal", Confidence.normal, confidence(tester.controller(), version2));
    assertTrue("Status for version without applications is removed", tester.controller().versionStatus().versions().stream().noneMatch(vespaVersion -> vespaVersion.versionNumber().equals(version1)));
    // Another default application upgrades, raising confidence to high
    tester.completeUpgrade(default8, version2, "default");
    tester.completeUpgrade(default9, version2, "default");
    tester.updateVersionStatus();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("90% of defaults deployed successfully: High", VespaVersion.Confidence.high, confidence(tester.controller(), version2));
    // A new version is released, all canaries upgrade successfully, but enough "default" apps fail to mark version
    // as broken
    Version version3 = new Version("5.3");
    tester.upgradeSystem(version3);
    tester.completeUpgrade(canary0, version3, "canary");
    tester.completeUpgrade(canary1, version3, "canary");
    tester.completeUpgrade(canary2, version3, "canary");
    tester.upgradeSystem(version3);
    tester.completeUpgradeWithError(default0, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default1, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default2, version3, "default", stagingTest);
    tester.completeUpgradeWithError(default9, version3, "default", stagingTest);
    tester.updateVersionStatus();
    assertEquals("Confidence remains unchanged for version0: High", Confidence.high, confidence(tester.controller(), version0));
    assertEquals("Confidence remains unchanged for version2: High", Confidence.high, confidence(tester.controller(), version2));
    assertEquals("40% of defaults failed: Broken", VespaVersion.Confidence.broken, confidence(tester.controller(), version3));
    // Test version order
    List<VespaVersion> versions = tester.controller().versionStatus().versions();
    assertEquals(3, versions.size());
    assertEquals("5", versions.get(0).versionNumber().toString());
    assertEquals("5.2", versions.get(1).versionNumber().toString());
    assertEquals("5.3", versions.get(2).versionNumber().toString());
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Version(com.yahoo.component.Version) Environment(com.yahoo.config.provision.Environment) URISyntaxException(java.net.URISyntaxException) Assert.assertTrue(org.junit.Assert.assertTrue) Vtag(com.yahoo.component.Vtag) Test(org.junit.Test) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) List(java.util.List) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) JobType.productionUsWest1(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest) Assert.assertFalse(org.junit.Assert.assertFalse) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Duration(java.time.Duration) URI(java.net.URI) JobType.productionUsEast3(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsEast3) Confidence(com.yahoo.vespa.hosted.controller.versions.VespaVersion.Confidence) Application(com.yahoo.vespa.hosted.controller.Application) Controller(com.yahoo.vespa.hosted.controller.Controller) Assert.assertEquals(org.junit.Assert.assertEquals) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) Version(com.yahoo.component.Version) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Application(com.yahoo.vespa.hosted.controller.Application) Test(org.junit.Test) JobType.systemTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest) JobType.stagingTest(com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)

Example 5 with TenantId

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

the class ApplicationApiHandler method setGlobalRotationOverride.

private HttpResponse setGlobalRotationOverride(String tenantName, String applicationName, String instanceName, String environment, String region, boolean inService, HttpRequest request) {
    // Check if request is authorized
    Optional<Tenant> existingTenant = controller.tenants().tenant(new TenantId(tenantName));
    if (!existingTenant.isPresent())
        return ErrorResponse.notFoundError("Tenant '" + tenantName + "' does not exist");
    // Decode payload (reason) and construct parameter to the configserver
    Inspector requestData = toSlime(request.getData()).get();
    String reason = mandatory("reason", requestData).asString();
    String agent = getUserPrincipal(request).getIdentity().getFullName();
    long timestamp = controller.clock().instant().getEpochSecond();
    EndpointStatus.Status status = inService ? EndpointStatus.Status.in : EndpointStatus.Status.out;
    EndpointStatus endPointStatus = new EndpointStatus(status, reason, agent, timestamp);
    // DeploymentId identifies the zone and application we are dealing with
    DeploymentId deploymentId = new DeploymentId(ApplicationId.from(tenantName, applicationName, instanceName), ZoneId.from(environment, region));
    try {
        List<String> rotations = controller.applications().setGlobalRotationStatus(deploymentId, endPointStatus);
        return new MessageResponse(String.format("Rotations %s successfully set to %s service", rotations.toString(), inService ? "in" : "out of"));
    } catch (IOException e) {
        return ErrorResponse.internalServerError("Unable to alter rotation status: " + e.getMessage());
    }
}
Also used : EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) TenantId(com.yahoo.vespa.hosted.controller.api.identifiers.TenantId) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) Tenant(com.yahoo.vespa.hosted.controller.api.Tenant) MessageResponse(com.yahoo.vespa.hosted.controller.restapi.MessageResponse) Inspector(com.yahoo.slime.Inspector) IOException(java.io.IOException)

Aggregations

TenantId (com.yahoo.vespa.hosted.controller.api.identifiers.TenantId)19 Tenant (com.yahoo.vespa.hosted.controller.api.Tenant)9 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)7 Test (org.junit.Test)7 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)6 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)6 Application (com.yahoo.vespa.hosted.controller.Application)5 Version (com.yahoo.component.Version)4 AthenzDomain (com.yahoo.vespa.athenz.api.AthenzDomain)4 Inspector (com.yahoo.slime.Inspector)3 Lock (com.yahoo.vespa.curator.Lock)3 LockedApplication (com.yahoo.vespa.hosted.controller.LockedApplication)3 Property (com.yahoo.vespa.hosted.controller.api.identifiers.Property)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 Environment (com.yahoo.config.provision.Environment)2 NToken (com.yahoo.vespa.athenz.api.NToken)2 EndpointStatus (com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus)2 ConfigChangeActions (com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbindings.ConfigChangeActions)2 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)2 PropertyId (com.yahoo.vespa.hosted.controller.api.identifiers.PropertyId)2