private void addAndAssignNode(ApplicationId id, String hostname, String parentHostname, ClusterSpec clusterSpec, NodeResources flavor, int index, ProvisioningTester tester) {
        Node node1a = Node.create("open1", IP.Config.ofEmptyPool("127.0.233." + index), hostname,
                                  new Flavor(flavor), NodeType.tenant).parentHostname(parentHostname).build();
        ClusterMembership clusterMembership1 = ClusterMembership.from(
                clusterSpec.with(Optional.of(ClusterSpec.Group.from(0))), index); // Need to add group here so that group is serialized in node allocation
        Node node1aAllocation = node1a.allocate(id, clusterMembership1, node1a.resources(), Instant.now());

        tester.nodeRepository().nodes().addNodes(List.of(node1aAllocation), Agent.system);
        NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(tester.getCurator()));
        tester.nodeRepository().nodes().activate(List.of(node1aAllocation), new ApplicationTransaction(new ApplicationMutex(id, () -> { }), transaction));
        transaction.commit();
    }
Test redeployment of nodes that violates spare headroom - but without alternatives
<p>
Setup 2 hosts and allocate one app with a container on each. 2 spares
<p>
Initial allocation of app 1 --> final allocation:
<p>
|    |    |        |    |    |
|    |    |   -->  |    |    |
| 1a | 1b |        | 1a | 1b |
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicAllocationTest.java