@Test
    public void delete_config_host() {
        NodeRepositoryTester tester = new NodeRepositoryTester();

        String cfghost1 = "cfghost1";
        String cfg1 = "cfg1";
        tester.addHost("id1", cfghost1, "default", NodeType.confighost);
        tester.addNode("id2", cfg1, cfghost1, "docker", NodeType.config);
        tester.setNodeState(cfghost1, Node.State.active);
        tester.setNodeState(cfg1, Node.State.active);
        assertEquals(2, tester.nodeRepository().nodes().list().size());

        try {
            tester.nodeRepository().nodes().removeRecursively(cfghost1);
            fail("Should not be able to delete host node, one of the children is in state active");
        } catch (IllegalArgumentException ignored) { }
        assertEquals(2, tester.nodeRepository().nodes().list().size());

        // Fail host and container
        tester.nodeRepository().nodes().failOrMarkRecursively(cfghost1, Agent.system, getClass().getSimpleName());

        assertEquals("cfg1 is not failed yet as it active",
                     Node.State.active, tester.nodeRepository().nodes().node(cfg1).get().state());
        assertEquals("cfghost1 is not failed yet as it active",
                     Node.State.active, tester.nodeRepository().nodes().node(cfghost1).get().state());
        assertTrue(tester.nodeRepository().nodes().node(cfg1).get().status().wantToFail());
        assertTrue(tester.nodeRepository().nodes().node(cfghost1).get().status().wantToFail());

        tester.nodeRepository().nodes().fail(cfg1, Agent.system, "test");
        tester.nodeRepository().nodes().fail(cfghost1, Agent.system, "test");

        // Remove recursively
        tester.nodeRepository().nodes().removeRecursively(cfghost1);
        assertEquals(0, tester.nodeRepository().nodes().list().not().state(Node.State.deprovisioned).size());
    }
tests basic operation of the node repository

@author bratseth
node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTest.java