Search in sources :

Example 31 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ControllerTester method createApplication.

public Application createApplication(TenantId tenant, String applicationName, String instanceName, long projectId) {
    ApplicationId applicationId = ApplicationId.from(tenant.id(), applicationName, instanceName);
    controller().applications().createApplication(applicationId, Optional.of(TestIdentities.userNToken));
    controller().applications().lockOrThrow(applicationId, lockedApplication -> controller().applications().store(lockedApplication.withProjectId(projectId)));
    return controller().applications().require(applicationId);
}
Also used : ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 32 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ClusterInfoMaintainerTest method maintain.

@Test
public void maintain() {
    ControllerTester tester = new ControllerTester();
    ApplicationId app = tester.createAndDeploy("tenant1", "domain1", "app1", Environment.dev, 123).id();
    // Precondition: no cluster info attached to the deployments
    Deployment deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
    Assert.assertEquals(0, deployment.clusterInfo().size());
    ClusterInfoMaintainer mainainer = new ClusterInfoMaintainer(tester.controller(), Duration.ofHours(1), new JobControl(new MockCuratorDb()));
    mainainer.maintain();
    deployment = tester.controller().applications().get(app).get().deployments().values().stream().findAny().get();
    Assert.assertEquals(2, deployment.clusterInfo().size());
    Assert.assertEquals(10, deployment.clusterInfo().get(ClusterSpec.Id.from("clusterA")).getFlavorCost());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) ApplicationId(com.yahoo.config.provision.ApplicationId) ControllerTester(com.yahoo.vespa.hosted.controller.ControllerTester) Test(org.junit.Test)

Example 33 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ControllerTest method testGlobalRotations.

@Test
public void testGlobalRotations() throws IOException {
    // Setup tester and app def
    ControllerTester tester = new ControllerTester();
    ZoneId zone = ZoneId.from(Environment.defaultEnvironment(), RegionName.defaultName());
    ApplicationId appId = ApplicationId.from("tenant", "app1", "default");
    DeploymentId deployId = new DeploymentId(appId, zone);
    // Check initial rotation status
    Map<String, EndpointStatus> rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
    assertEquals(1, rotationStatus.size());
    assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.in));
    // Set the global rotations out of service
    EndpointStatus status = new EndpointStatus(EndpointStatus.Status.out, "Testing I said", "Test", tester.clock().instant().getEpochSecond());
    List<String> overrides = tester.controller().applications().setGlobalRotationStatus(deployId, status);
    assertEquals(1, overrides.size());
    // Recheck the override rotation status
    rotationStatus = tester.controller().applications().getGlobalRotationStatus(deployId);
    assertEquals(1, rotationStatus.size());
    assertTrue(rotationStatus.get("qrs-endpoint").getStatus().equals(EndpointStatus.Status.out));
    assertTrue(rotationStatus.get("qrs-endpoint").getReason().equals("Testing I said"));
}
Also used : EndpointStatus(com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) ApplicationId(com.yahoo.config.provision.ApplicationId) 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 34 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class ControllerTest method testPullRequestDeployment.

@Test
public void testPullRequestDeployment() {
    // Setup system
    ControllerTester tester = new ControllerTester();
    ApplicationController applications = tester.controller().applications();
    // staging deployment
    long app1ProjectId = 22;
    ApplicationId app1 = tester.createAndDeploy("tenant1", "domain1", "application1", Environment.staging, app1ProjectId).id();
    // pull-request deployment - uses different instance id
    ApplicationId app1pr = tester.createAndDeploy("tenant1", "domain1", "application1", "1", Environment.staging, app1ProjectId, null).id();
    assertTrue(applications.get(app1).isPresent());
    assertEquals(app1, applications.get(app1).get().id());
    assertTrue(applications.get(app1pr).isPresent());
    assertEquals(app1pr, applications.get(app1pr).get().id());
    // Simulate restart
    tester.createNewController();
    applications = tester.controller().applications();
    assertTrue(applications.get(app1).isPresent());
    assertEquals(app1, applications.get(app1).get().id());
    assertTrue(applications.get(app1pr).isPresent());
    assertEquals(app1pr, applications.get(app1pr).get().id());
    // Deleting application also removes PR instance
    ApplicationId app2 = tester.createAndDeploy("tenant1", "domain1", "application2", Environment.staging, 33).id();
    tester.controller().applications().deleteApplication(app1, Optional.of(new NToken("ntoken")));
    assertEquals("All instances deleted", 0, tester.controller().applications().asList(app1.tenant()).stream().filter(app -> app.id().application().equals(app1.application())).count());
    assertEquals("Other application survives", 1, tester.controller().applications().asList(app1.tenant()).stream().filter(app -> app.id().application().equals(app2.application())).count());
}
Also used : NToken(com.yahoo.vespa.athenz.api.NToken) ApplicationId(com.yahoo.config.provision.ApplicationId) 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 35 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class DeploymentJobExecutorTest method testMaintenance.

@Test
public void testMaintenance() {
    DeploymentTester tester = new DeploymentTester();
    JobControl jobControl = new JobControl(tester.controller().curator());
    int project1 = 1;
    int project2 = 2;
    int project3 = 3;
    ApplicationId app1 = tester.createApplication("app1", "tenant", project1, null).id();
    ApplicationId app2 = tester.createApplication("app2", "tenant", project2, null).id();
    ApplicationId app3 = tester.createApplication("app3", "tenant", project3, null).id();
    // Create a BuildService which always rejects jobs from project2, but accepts and runs all others.
    ArrayList<BuildJob> buildJobs = new ArrayList<>();
    BuildService buildService = buildJob -> buildJob.projectId() == project2 ? false : buildJobs.add(buildJob);
    DeploymentJobExecutor triggerer = new DeploymentJobExecutor(tester.controller(), Duration.ofDays(1), jobControl, buildService, Runnable::run);
    triggerer.maintain();
    assertEquals("No jobs are triggered initially.", Collections.emptyList(), buildJobs);
    // Trigger jobs in capacity constrained environment
    tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.systemTest, false);
    tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.systemTest, false);
    tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.systemTest, false);
    // Trigger jobs in non-capacity constrained environment
    tester.deploymentQueue().addJob(app1, DeploymentJobs.JobType.productionUsWest1, false);
    tester.deploymentQueue().addJob(app2, DeploymentJobs.JobType.productionUsWest1, false);
    tester.deploymentQueue().addJob(app3, DeploymentJobs.JobType.productionUsWest1, false);
    triggerer.maintain();
    assertEquals("One system test job and all production jobs not for app2 are triggered after one maintenance run.", Arrays.asList(new BuildJob(project1, DeploymentJobs.JobType.systemTest.jobName()), new BuildJob(project1, DeploymentJobs.JobType.productionUsWest1.jobName()), new BuildJob(project3, DeploymentJobs.JobType.productionUsWest1.jobName())), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("Next job in line fails to trigger in the build service.", Collections.emptyList(), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("Next job which was waiting for capacity is triggered on next run.", Collections.singletonList(new BuildJob(project3, DeploymentJobs.JobType.systemTest.jobName())), buildJobs);
    buildJobs.clear();
    triggerer.maintain();
    assertEquals("No jobs are left.", Collections.emptyList(), tester.deploymentQueue().takeJobsToRun());
}
Also used : Arrays(java.util.Arrays) ApplicationId(com.yahoo.config.provision.ApplicationId) BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) Duration(java.time.Duration) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) Test(org.junit.Test) DeploymentJobs(com.yahoo.vespa.hosted.controller.application.DeploymentJobs) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) ArrayList(java.util.ArrayList) BuildService(com.yahoo.vespa.hosted.controller.api.integration.BuildService) ArrayList(java.util.ArrayList) JobControl(com.yahoo.vespa.hosted.controller.maintenance.JobControl) BuildJob(com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11