Search in sources :

Example 1 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb in project vespa by vespa-engine.

the class MetricsReporterTest method createReporter.

private MetricsReporter createReporter(Clock clock, Controller controller, MetricsMock metricsMock, SystemName system) {
    Chef client = Mockito.mock(Chef.class);
    PartialNodeResult result;
    try {
        result = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(testData.resolve("chef_output.json").toFile(), PartialNodeResult.class);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    when(client.partialSearchNodes(anyString(), anyListOf(AttributeMapping.class))).thenReturn(result);
    return new MetricsReporter(controller, metricsMock, client, clock, new JobControl(new MockCuratorDb()), system);
}
Also used : PartialNodeResult(com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult) MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Chef(com.yahoo.vespa.hosted.controller.api.integration.chef.Chef) AttributeMapping(com.yahoo.vespa.hosted.controller.api.integration.chef.AttributeMapping) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb 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 3 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb in project vespa by vespa-engine.

the class DeploymentExpirerTest method testDeploymentExpiry.

@Test
public void testDeploymentExpiry() {
    tester.controllerTester().zoneRegistry().setDeploymentTimeToLive(ZoneId.from(Environment.dev, RegionName.from("us-east-1")), Duration.ofDays(14));
    DeploymentExpirer expirer = new DeploymentExpirer(tester.controller(), Duration.ofDays(10), tester.clock(), new JobControl(new MockCuratorDb()));
    Application devApp = tester.createApplication("app1", "tenant1", 123L, 1L);
    Application prodApp = tester.createApplication("app2", "tenant2", 456L, 2L);
    // Deploy dev
    tester.controllerTester().deploy(devApp, tester.controllerTester().toZone(Environment.dev));
    // Deploy prod
    ApplicationPackage prodAppPackage = new ApplicationPackageBuilder().region("us-west-1").build();
    tester.deployCompletely(prodApp, prodAppPackage);
    assertEquals(1, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
    // Not expired at first
    expirer.maintain();
    assertEquals(1, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
    // The dev application is removed
    tester.clock().advance(Duration.ofDays(15));
    expirer.maintain();
    assertEquals(0, permanentDeployments(devApp).size());
    assertEquals(1, permanentDeployments(prodApp).size());
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) ApplicationPackageBuilder(com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder) Application(com.yahoo.vespa.hosted.controller.Application) ApplicationPackage(com.yahoo.vespa.hosted.controller.application.ApplicationPackage) Test(org.junit.Test)

Example 4 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb in project vespa by vespa-engine.

the class DeploymentIssueReporterTest method setup.

@Before
public void setup() {
    tester = new DeploymentTester();
    issues = new MockDeploymentIssues();
    reporter = new DeploymentIssueReporter(tester.controller(), issues, Duration.ofDays(1), new JobControl(new MockCuratorDb()));
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) DeploymentTester(com.yahoo.vespa.hosted.controller.deployment.DeploymentTester) Before(org.junit.Before)

Example 5 with MockCuratorDb

use of com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb in project vespa by vespa-engine.

the class JobControlTest method testJobControl.

@Test
public void testJobControl() {
    JobControl jobControl = new JobControl(new MockCuratorDb());
    assertTrue(jobControl.jobs().isEmpty());
    String job1 = "Job1";
    String job2 = "Job2";
    jobControl.started(job1);
    jobControl.started(job2);
    assertEquals(2, jobControl.jobs().size());
    assertTrue(jobControl.jobs().contains(job1));
    assertTrue(jobControl.jobs().contains(job2));
    assertTrue(jobControl.isActive(job1));
    assertTrue(jobControl.isActive(job2));
    jobControl.setActive(job1, false);
    assertFalse(jobControl.isActive(job1));
    assertTrue(jobControl.isActive(job2));
    jobControl.setActive(job2, false);
    assertFalse(jobControl.isActive(job1));
    assertFalse(jobControl.isActive(job2));
    jobControl.setActive(job1, true);
    assertTrue(jobControl.isActive(job1));
    assertFalse(jobControl.isActive(job2));
    jobControl.setActive(job2, true);
    assertTrue(jobControl.isActive(job1));
    assertTrue(jobControl.isActive(job2));
}
Also used : MockCuratorDb(com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb) Test(org.junit.Test)

Aggregations

MockCuratorDb (com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb)12 Test (org.junit.Test)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)5 Application (com.yahoo.vespa.hosted.controller.Application)4 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)3 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)3 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)3 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Version (com.yahoo.component.Version)1 NToken (com.yahoo.vespa.athenz.api.NToken)1 AttributeMapping (com.yahoo.vespa.hosted.controller.api.integration.chef.AttributeMapping)1 Chef (com.yahoo.vespa.hosted.controller.api.integration.chef.Chef)1 PartialNodeResult (com.yahoo.vespa.hosted.controller.api.integration.chef.rest.PartialNodeResult)1 Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)1 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)1 SourceRevision (com.yahoo.vespa.hosted.controller.application.SourceRevision)1 VersionStatus (com.yahoo.vespa.hosted.controller.versions.VersionStatus)1