use of com.yahoo.config.provision.NodeFlavors in project vespa by vespa-engine.
the class ProvisioningTest method application_deployment_multiple_flavors_default_per_type.
@Test
public void application_deployment_multiple_flavors_default_per_type() {
ConfigserverConfig.Builder config = new ConfigserverConfig.Builder();
config.environment("prod");
config.region("us-east");
config.defaultFlavor("not-used");
config.defaultContainerFlavor("small");
config.defaultContentFlavor("large");
ProvisioningTester tester = new ProvisioningTester(new Zone(new ConfigserverConfig(config), new NodeFlavors(new FlavorsConfig(new FlavorsConfig.Builder()))));
ApplicationId application1 = tester.makeApplicationId();
tester.makeReadyNodes(10, "small");
tester.makeReadyNodes(9, "large");
// deploy
SystemState state1 = prepare(application1, 2, 3, 4, 5, null, tester);
tester.activate(application1, state1.allHosts);
assertEquals("'small' nodes are used for containers", 2 + 3, tester.getNodes(application1, Node.State.active).flavor("small").size());
assertEquals("'large' nodes are used for content", 4 + 5, tester.getNodes(application1, Node.State.active).flavor("large").size());
}
use of com.yahoo.config.provision.NodeFlavors in project vespa by vespa-engine.
the class MetricsReporterTest method test_registered_metric.
@Test
public void test_registered_metric() throws Exception {
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default");
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);
Node node = nodeRepository.createNode("openStackId", "hostname", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant);
nodeRepository.addNodes(Collections.singletonList(node));
Node hostNode = nodeRepository.createNode("openStackId2", "parent", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.proxy);
nodeRepository.addNodes(Collections.singletonList(hostNode));
Map<String, Number> expectedMetrics = new HashMap<>();
expectedMetrics.put("hostedVespa.provisionedHosts", 1L);
expectedMetrics.put("hostedVespa.parkedHosts", 0L);
expectedMetrics.put("hostedVespa.readyHosts", 0L);
expectedMetrics.put("hostedVespa.reservedHosts", 0L);
expectedMetrics.put("hostedVespa.activeHosts", 0L);
expectedMetrics.put("hostedVespa.inactiveHosts", 0L);
expectedMetrics.put("hostedVespa.dirtyHosts", 0L);
expectedMetrics.put("hostedVespa.failedHosts", 0L);
expectedMetrics.put("hostedVespa.docker.totalCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.totalCapacityCpu", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityDisk", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityMem", 0.0);
expectedMetrics.put("hostedVespa.docker.freeCapacityCpu", 0.0);
expectedMetrics.put("wantedRebootGeneration", 0L);
expectedMetrics.put("currentRebootGeneration", 0L);
expectedMetrics.put("wantToReboot", 0);
expectedMetrics.put("wantToRetire", 0);
expectedMetrics.put("wantToDeprovision", 0);
expectedMetrics.put("hardwareFailure", 0);
expectedMetrics.put("hardwareDivergence", 0);
expectedMetrics.put("allowedToBeDown", 0);
expectedMetrics.put("numberOfServices", 0L);
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(expectedMetrics, metric.values);
}
use of com.yahoo.config.provision.NodeFlavors in project vespa by vespa-engine.
the class DockerHostCapacityTest method setup.
@Before
public void setup() {
// Create flavors
NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("host", "docker", "docker2");
flavorDocker = nodeFlavors.getFlavorOrThrow("docker");
flavorDocker2 = nodeFlavors.getFlavorOrThrow("docker2");
// Create three docker hosts
host1 = Node.create("host1", Collections.singleton("::1"), generateIPs(2, 4), "host1", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
host2 = Node.create("host2", Collections.singleton("::11"), generateIPs(12, 3), "host2", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
host3 = Node.create("host3", Collections.singleton("::21"), generateIPs(22, 1), "host3", Optional.empty(), nodeFlavors.getFlavorOrThrow("host"), NodeType.host);
// Add two containers to host1
nodeA = Node.create("nodeA", Collections.singleton("::2"), Collections.emptySet(), "nodeA", Optional.of("host1"), flavorDocker, NodeType.tenant);
nodeB = Node.create("nodeB", Collections.singleton("::3"), Collections.emptySet(), "nodeB", Optional.of("host1"), flavorDocker, NodeType.tenant);
// Add two containers to host 2 (same as host 1)
nodeC = Node.create("nodeC", Collections.singleton("::12"), Collections.emptySet(), "nodeC", Optional.of("host2"), flavorDocker, NodeType.tenant);
nodeD = Node.create("nodeD", Collections.singleton("::13"), Collections.emptySet(), "nodeD", Optional.of("host2"), flavorDocker, NodeType.tenant);
// Add a larger container to host3
nodeE = Node.create("nodeE", Collections.singleton("::22"), Collections.emptySet(), "nodeE", Optional.of("host3"), flavorDocker2, NodeType.tenant);
// init docker host capacity
nodes = new ArrayList<>();
Collections.addAll(nodes, host1, host2, host3, nodeA, nodeB, nodeC, nodeD, nodeE);
capacity = new DockerHostCapacity(nodes);
}
use of com.yahoo.config.provision.NodeFlavors in project vespa by vespa-engine.
the class AuthorizerTest method before.
@Before
public void before() {
NodeFlavors flavors = new MockNodeFlavors();
nodeRepository = new MockNodeRepository(new MockCurator(), flavors);
authorizer = new Authorizer(SystemName.main, nodeRepository, () -> "cfg1");
{
// Populate with nodes used in this test. Note that only nodes requiring node repository lookup are added here
Set<String> ipAddresses = new HashSet<>(Arrays.asList("127.0.0.1", "::1"));
Flavor flavor = flavors.getFlavorOrThrow("default");
List<Node> nodes = new ArrayList<>();
nodes.add(nodeRepository.createNode("host1", "host1", ipAddresses, Optional.empty(), flavor, NodeType.host));
nodes.add(nodeRepository.createNode("child1-1", "child1-1", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
nodes.add(nodeRepository.createNode("child1-2", "child1-2", ipAddresses, Optional.of("host1"), flavor, NodeType.tenant));
nodes.add(nodeRepository.createNode("host2", "host2", ipAddresses, Optional.empty(), flavor, NodeType.host));
nodes.add(nodeRepository.createNode("child2-1", "child2-1", ipAddresses, Optional.of("host1.tld"), flavor, NodeType.tenant));
nodes.add(nodeRepository.createNode("proxy1", "proxy1", ipAddresses, Optional.empty(), flavor, NodeType.proxy));
nodes.add(nodeRepository.createNode("proxy1-host1", "proxy1-host", ipAddresses, Optional.empty(), flavor, NodeType.proxyhost));
nodeRepository.addNodes(nodes);
}
}
use of com.yahoo.config.provision.NodeFlavors in project vespa by vespa-engine.
the class ReservationExpirerTest method ensure_reservation_times_out.
@Test
public void ensure_reservation_times_out() {
ManualClock clock = new ManualClock();
NodeFlavors flavors = FlavorConfigBuilder.createDummies("default");
NodeRepository nodeRepository = new NodeRepository(flavors, curator, clock, Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(nodeRepository, flavors, Zone.defaultZone());
List<Node> nodes = new ArrayList<>(2);
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.host));
nodes = nodeRepository.addNodes(nodes);
nodes = nodeRepository.setDirty(nodes, Agent.system, getClass().getSimpleName());
// Reserve 2 nodes
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.dirty).size());
nodeRepository.setReady(nodes, Agent.system, getClass().getSimpleName());
ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("bar").instanceName("fuz").build();
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1, null);
assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
// Reservation times out
// Reserved but not used time out
clock.advance(Duration.ofMinutes(14));
new ReservationExpirer(nodeRepository, clock, Duration.ofMinutes(10), new JobControl(nodeRepository.database())).run();
// Assert nothing is reserved
assertEquals(0, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
List<Node> dirty = nodeRepository.getNodes(NodeType.tenant, Node.State.dirty);
assertEquals(2, dirty.size());
assertFalse(dirty.get(0).allocation().isPresent());
assertFalse(dirty.get(1).allocation().isPresent());
}
Aggregations