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