@Test
    public void indistinct_distribution_with_known_ready_nodes() {
        ProvisioningTester tester = new ProvisioningTester.Builder().build();
        tester.makeReadyChildren(4, resources1);

        int contentNodeCount = 3;
        int groups = 1;
        List<HostSpec> contentHosts = tester.prepare(applicationId, contentClusterSpec, contentNodeCount, groups, resources1);
        tester.activate(applicationId, contentHosts);

        NodeList nodes = tester.getNodes(applicationId, Node.State.active);
        assertEquals(3, nodes.size());

        // Set indistinct parents
        tester.patchNode(nodes.asList().get(0), (n) -> n.withParentHostname("parentHost1"));
        tester.patchNode(nodes.asList().get(1), (n) -> n.withParentHostname("parentHost1"));
        tester.patchNode(nodes.asList().get(2), (n) -> n.withParentHostname("parentHost2"));
        nodes = tester.getNodes(applicationId, Node.State.active);
        assertEquals(3, nodes.stream().filter(n -> n.parentHostname().isPresent()).count());

        tester.makeReadyChildren(1, resources1, "parentHost1");
        tester.makeReadyChildren(2, resources1, "parentHost2");

        tester.activate(applicationId, tester.prepare(applicationId, contentClusterSpec, contentNodeCount, groups, resources1));
        nodes = tester.getNodes(applicationId, Node.State.active);
        assertEquals(4, nodes.size());
        assertEquals(1, nodes.retired().size());
    }
Tests provisioning of virtual nodes

@author hmusum
@author mpolden
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/VirtualNodeProvisioningTest.java