@Test
    public void increase_size_decrease_resources() {
        addParentHosts(14, largeResources.with(fast));

        NodeResources resources = new NodeResources(4, 8, 160, 1);
        NodeResources halvedResources = new NodeResources(2, 4, 80, 1);

        new PrepareHelper(tester, app).prepare(content1, 4, 1, resources).activate();
        assertSizeAndResources(content1, 4, resources);

        // No resizing since it would initially (before redistribution) lead to too few resources:
        new PrepareHelper(tester, app).prepare(content1, 8, 1, halvedResources).activate();
        assertSizeAndResources(listCluster(content1).retired(), 4, resources);
        assertSizeAndResources(listCluster(content1).not().retired(), 8, halvedResources);

        // Redeploying the same capacity should also not lead to any resizing
        new PrepareHelper(tester, app).prepare(content1, 8, 1, halvedResources).activate();
        assertSizeAndResources(listCluster(content1).retired(), 4, resources);
        assertSizeAndResources(listCluster(content1).not().retired(), 8, halvedResources);

        // Failing one of the new nodes should cause another new node to be allocated rather than
        // unretiring one of the existing nodes, to avoid resizing during unretiring
        Node nodeToFail = listCluster(content1).not().retired().asList().get(0);
        tester.nodeRepository().nodes().fail(nodeToFail.hostname(), Agent.system, "testing");
        new PrepareHelper(tester, app).prepare(content1, 8, 1, halvedResources).activate();
        assertFalse(listCluster(content1).stream().anyMatch(n -> n.equals(nodeToFail)));
        assertSizeAndResources(listCluster(content1).retired(), 4, resources);
        assertSizeAndResources(listCluster(content1).not().retired(), 8, halvedResources);

        // Here we'll unretire and resize one of the previously retired nodes as there is no rule against it
        Node nodeToWantToRetire = listCluster(content1).not().retired().asList().get(0);
        try (NodeMutex lock = tester.nodeRepository().nodes().lockAndGetRequired(nodeToWantToRetire)) {
            tester.nodeRepository().nodes().write(lock.node().withWantToRetire(true, Agent.system,
                    tester.clock().instant()), lock);
        }
        new PrepareHelper(tester, app).prepare(content1, 8, 1, halvedResources).activate();
        assertTrue(listCluster(content1).retired().stream().anyMatch(n -> n.equals(nodeToWantToRetire)));
        assertEquals(4, listCluster(content1).retired().size());
        assertSizeAndResources(listCluster(content1).not().retired(), 8, halvedResources);
    }
Node resources can be increased in-place if
 1. No change to topology
 2. No reduction to cluster size
 3. There is enough spare capacity on host

Node resources can be decreased in-place if
 1. No change to topology
 2. No reduction to cluster size
 3. For content/combined nodes: No increase to cluster size

Node resources are increased if at least one of the components (vcpu, memory, disk, bandwidth) is increased.

@author freva
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InPlaceResizeProvisionTest.java