@Test
    public void refuses_to_activate_on_non_active_host() {
        ProvisioningTester tester = new ProvisioningTester.Builder().zone(new Zone(Environment.prod, RegionName.from("us-east"))).build();

        List<Node> parents = tester.makeReadyNodes(10, new NodeResources(2, 4, 20, 2), NodeType.host, 1);
        for (Node parent : parents)
            tester.makeReadyChildren(1, resources2, parent.hostname());

        ApplicationId application1 = ProvisioningTester.applicationId();
        Version wantedVespaVersion = Version.fromString("6.39");
        int nodeCount = 7;
        try {
            List<HostSpec> nodes = tester.prepare(application1,
                                                  ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("my-content")).vespaVersion(wantedVespaVersion).build(),
                                                  nodeCount, 1, resources2);
            fail("Expected the allocation to fail due to parent hosts not being active yet");
        } catch (NodeAllocationException expected) { }

        // Activate the hosts, thereby allocating the parents
        tester.activateTenantHosts();

        // Try allocating tenants again
        List<HostSpec> nodes = tester.prepare(application1,
                                              ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("my-content")).vespaVersion(wantedVespaVersion).build(),
                                              nodeCount, 1, resources2);
        tester.activate(application1, new HashSet<>(nodes));

        NodeList activeNodes = tester.getNodes(application1, Node.State.active);
        assertEquals(nodeCount, activeNodes.size());
    }
Tests provisioning of virtual nodes

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