use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class ProvisioningTest method application_deployment_retires_nodes_having_retired_flavor.
@Test
public void application_deployment_retires_nodes_having_retired_flavor() {
String flavorToRetire = "default";
String replacementFlavor = "new-default";
ApplicationId application = ApplicationId.from(TenantName.from(UUID.randomUUID().toString()), ApplicationName.from(UUID.randomUUID().toString()), InstanceName.from(UUID.randomUUID().toString()));
Curator curator = new MockCurator();
NameResolver nameResolver = new MockNameResolver().mockAnyLookup();
// Deploy with flavor that will eventually be retired
{
FlavorConfigBuilder b = new FlavorConfigBuilder();
b.addFlavor("default", 1., 1., 10, Flavor.Type.BARE_METAL).cost(2);
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
tester.makeReadyNodes(4, flavorToRetire);
SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
tester.activate(application, state.allHosts);
}
// Re-deploy with same flavor, which is now retired
{
// Retire "default" flavor and add "new-default" as replacement
FlavorConfigBuilder b = new FlavorConfigBuilder();
b.addFlavor(flavorToRetire, 1., 1., 10, Flavor.Type.BARE_METAL).cost(2).retired(true);
FlavorsConfig.Flavor.Builder newDefault = b.addFlavor(replacementFlavor, 2., 2., 20, Flavor.Type.BARE_METAL).cost(2);
b.addReplaces(flavorToRetire, newDefault);
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build(), curator, nameResolver);
// Add nodes with "new-default" flavor
tester.makeReadyNodes(4, replacementFlavor);
SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
tester.activate(application, state.allHosts);
// Nodes with retired flavor are retired
NodeList retired = tester.getNodes(application).retired();
assertEquals(4, retired.size());
assertTrue("Nodes are retired by system", retired.asList().stream().allMatch(retiredBy(Agent.system)));
}
}
use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class PeriodicApplicationMaintainerTest method before.
@Before
public void before() {
Curator curator = new MockCurator();
Zone zone = new Zone(Environment.prod, RegionName.from("us-east"));
this.nodeRepository = new NodeRepository(nodeFlavors, curator, new ManualClock(), zone, new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
this.fixture = new Fixture(zone, nodeRepository, nodeFlavors, curator);
}
use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class MetricsReporterTest method docker_metrics.
@Test
public void docker_metrics() throws Exception {
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("host", "docker", "docker2");
Curator curator = new MockCurator();
NodeRepository nodeRepository = new NodeRepository(nodeFlavors, curator, Clock.systemUTC(), Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
// Allow 4 containers
Set<String> additionalIps = new HashSet<>();
additionalIps.add("::2");
additionalIps.add("::3");
additionalIps.add("::4");
additionalIps.add("::5");
Node dockerHost = Node.create("openStackId1", Collections.singleton("::1"), additionalIps, "dockerHost", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
nodeRepository.addNodes(Collections.singletonList(dockerHost));
nodeRepository.setDirty("dockerHost", Agent.system, getClass().getSimpleName());
nodeRepository.setReady("dockerHost", Agent.system, getClass().getSimpleName());
Node container1 = Node.createDockerNode("openStackId1:1", Collections.singleton("::2"), Collections.emptySet(), "container1", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker"), NodeType.tenant);
container1 = container1.with(allocation(Optional.of("app1")).get());
nodeRepository.addDockerNodes(Collections.singletonList(container1));
Node container2 = Node.createDockerNode("openStackId1:2", Collections.singleton("::3"), Collections.emptySet(), "container2", Optional.of("dockerHost"), nodeFlavors.getFlavorOrThrow("docker2"), NodeType.tenant);
container2 = container2.with(allocation(Optional.of("app2")).get());
nodeRepository.addDockerNodes(Collections.singletonList(container2));
Orchestrator orchestrator = mock(Orchestrator.class);
ServiceMonitor serviceMonitor = mock(ServiceMonitor.class);
when(orchestrator.getNodeStatus(any())).thenReturn(HostStatus.NO_REMARKS);
ServiceModel serviceModel = mock(ServiceModel.class);
when(serviceMonitor.getServiceModelSnapshot()).thenReturn(serviceModel);
when(serviceModel.getServiceInstancesByHostName()).thenReturn(Collections.emptyMap());
TestMetric metric = new TestMetric();
MetricsReporter metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
metricsReporter.maintain();
assertEquals(0L, metric.values.get("hostedVespa.readyHosts"));
/**
* Only tenants counts *
*/
assertEquals(2L, metric.values.get("hostedVespa.reservedHosts"));
assertEquals(12.0, metric.values.get("hostedVespa.docker.totalCapacityDisk"));
assertEquals(10.0, metric.values.get("hostedVespa.docker.totalCapacityMem"));
assertEquals(7.0, metric.values.get("hostedVespa.docker.totalCapacityCpu"));
assertEquals(6.0, metric.values.get("hostedVespa.docker.freeCapacityDisk"));
assertEquals(3.0, metric.values.get("hostedVespa.docker.freeCapacityMem"));
assertEquals(4.0, metric.values.get("hostedVespa.docker.freeCapacityCpu"));
assertContext(metric, "hostedVespa.docker.freeCapacityFlavor", 1, 0);
assertContext(metric, "hostedVespa.docker.idealHeadroomFlavor", 0, 0);
assertContext(metric, "hostedVespa.docker.hostsAvailableFlavor", 1l, 0l);
}
use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class OperatorChangeApplicationMaintainerTest method test_application_maintenance.
@Test
public void test_application_maintenance() throws InterruptedException {
ManualClock clock = new ManualClock();
Curator curator = new MockCurator();
Zone zone = new Zone(Environment.prod, RegionName.from("us-east"));
this.nodeRepository = new NodeRepository(nodeFlavors, curator, clock, zone, new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
this.fixture = new Fixture(zone, nodeRepository, nodeFlavors, curator);
createReadyNodes(15, nodeRepository, nodeFlavors);
createHostNodes(2, nodeRepository, nodeFlavors);
// Create applications
fixture.activate();
OperatorChangeApplicationMaintainer maintainer = new OperatorChangeApplicationMaintainer(fixture.deployer, nodeRepository, clock, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
clock.advance(Duration.ofMinutes(2));
maintainer.maintain();
assertEquals("No changes -> no redeployments", 0, fixture.deployer.redeployments);
nodeRepository.fail(nodeRepository.getNodes(fixture.app1).get(3).hostname(), Agent.system, "Failing to unit test");
clock.advance(Duration.ofMinutes(2));
maintainer.maintain();
assertEquals("System change -> no redeployments", 0, fixture.deployer.redeployments);
clock.advance(Duration.ofSeconds(1));
nodeRepository.fail(nodeRepository.getNodes(fixture.app2).get(4).hostname(), Agent.operator, "Manual node failing");
clock.advance(Duration.ofMinutes(2));
maintainer.maintain();
assertEquals("Operator change -> redeployment", 1, fixture.deployer.redeployments);
clock.advance(Duration.ofMinutes(2));
maintainer.maintain();
assertEquals("No further operator changes -> no (new) redeployments", 1, fixture.deployer.redeployments);
}
use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.
the class ZookeeperStatusServiceTest method createConnectedCurator.
private static Curator createConnectedCurator(TestingServer server) throws InterruptedException {
Curator curator = Curator.create(server.getConnectString());
curator.framework().blockUntilConnected(1, TimeUnit.MINUTES);
return curator;
}
Aggregations