@Test
    public void test_ip_conflicts() {
        var zone = new Zone(Cloud.builder().name(CloudName.AWS).account(CloudAccount.from("aws:123456789012")).allowEnclave(true).build(),
                            SystemName.Public,
                            Environment.prod,
                            RegionName.from("aws-us-east-1a"));
        NodeRepositoryTester tester = new NodeRepositoryTester(zone);
        IP.Config ipConfig = IP.Config.of(List.of("1.2.3.4", "10.2.3.4"), List.of("1.2.3.4", "10.2.3.4"));
        IP.Config publicIpConfig = IP.Config.of(List.of("1.2.3.4"), List.of("1.2.3.4"));
        IP.Config privateIpConfig = IP.Config.of(List.of("10.2.3.4"), List.of("10.2.3.4"));

        Node host1 = Node.create("id1", ipConfig, "host1", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
                               .build();
        tester.nodeRepository().nodes().addNodes(List.of(host1), Agent.system);

        Node publicHost2 = Node.create("id2", publicIpConfig, "host2", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
                               .build();

        Node publicEnclaveHost2 = Node.create("id2", publicIpConfig, "host2", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
                                      .cloudAccount(CloudAccount.from("gcp:foo-bar-baz"))
                                      .build();

        // Public IP conflicts inside an account are not allowed
        assertEquals("Cannot assign [1.2.3.4] to host2: [1.2.3.4] already assigned to host1",
                     assertThrows(IllegalArgumentException.class,
                                  () -> tester.nodeRepository().nodes().addNodes(List.of(publicHost2), Agent.system))
                             .getMessage());

        // Public IP conflicts across accounts are not allowed
        assertEquals("Cannot assign [1.2.3.4] to host2: [1.2.3.4] already assigned to host1",
                     assertThrows(IllegalArgumentException.class,
                                  () -> tester.nodeRepository().nodes().addNodes(List.of(publicEnclaveHost2), Agent.system))
                             .getMessage());

        Node privateHost2 = Node.create("id2", privateIpConfig, "host2", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
                                .build();

        Node privateEnclaveHost2 = Node.create("id2", privateIpConfig, "host2", tester.nodeFlavors().getFlavorOrThrow("default"), NodeType.host)
                                       .cloudAccount(CloudAccount.from("gcp:foo-bar-baz"))
                                       .build();

        // Private IP conflicts inside accounts are not allowed
        assertEquals("Cannot assign [10.2.3.4] to host2: [10.2.3.4] already assigned to host1",
                     assertThrows(IllegalArgumentException.class,
                                  () -> tester.nodeRepository().nodes().addNodes(List.of(privateHost2), Agent.system))
                             .getMessage());

        // Private IP conflicts across accounts are allowed
        tester.nodeRepository().nodes().addNodes(List.of(privateEnclaveHost2), Agent.system);
    }
tests basic operation of the node repository

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