@Test
    public void testNodesJdisc() {
        String services =
                "<?xml version='1.0' encoding='utf-8' ?>\n" +
                        "<services>\n" +
                        "\n" +
                        "<container id='mydisc' version='1.0'>" +
                        "  <handler id='myHandler'>" +
                        "    <component id='injected' />" +
                        "  </handler>" +
                        "  <nodes count=\"3\"/>" +
                        "</container>" +
                        "<container id='mydisc2' version='1.0'>" +
                        "  <document-processing/>" +
                        "  <handler id='myHandler'>" +
                        "    <component id='injected' />" +
                        "  </handler>" +
                        "  <nodes count='2' preload='lib/blablamalloc.so'>" +
                        "    <jvm allocated-memory='45%' gc-options='-XX:+UseParNewGC' options='-Xlog:gc' />" +
                        "  </nodes>" +
                        "</container>" +
                        "</services>";
        String hosts ="<hosts>"
                + " <host name='myhost0'>"
                + "  <alias>node0</alias>"
                + " </host>"
                + " <host name='myhost1'>"
                + "  <alias>node1</alias>"
                + " </host>"
                + " <host name='myhost2'>"
                + "  <alias>node2</alias>"
                + " </host>"
                + " <host name='myhost3'>"
                + "  <alias>node3</alias>"
                + " </host>"
                + " <host name='myhost4'>"
                + "  <alias>node4</alias>"
                + " </host>"
                + " <host name='myhost5'>"
                + "  <alias>node5</alias>"
                + " </host>"
                + " <host name='myhost6'>"
                + "  <alias>node6</alias>"
                + " </host>"
                + "</hosts>";
        VespaModelCreatorWithMockPkg creator = new VespaModelCreatorWithMockPkg(null, services);
        VespaModel model = creator.create(new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(new StringReader(hosts)), true, false)));
        ApplicationContainerCluster mydisc = model.getContainerClusters().get("mydisc");
        ApplicationContainerCluster mydisc2 = model.getContainerClusters().get("mydisc2");
        assertEquals(3, mydisc.getContainers().size());
        assertEquals("mydisc/container.0", (mydisc.getContainers().get(0).getConfigId()));
        assertTrue(mydisc.getContainers().get(0).isInitialized());
        assertEquals("mydisc/container.1", mydisc.getContainers().get(1).getConfigId());
        assertTrue(mydisc.getContainers().get(1).isInitialized());
        assertEquals("mydisc/container.2", mydisc.getContainers().get(2).getConfigId());
        assertTrue(mydisc.getContainers().get(2).isInitialized());

        assertEquals(2, mydisc2.getContainers().size());
        assertEquals("mydisc2/container.0", mydisc2.getContainers().get(0).getConfigId());
        assertTrue(mydisc2.getContainers().get(0).isInitialized());
        assertEquals("mydisc2/container.1", mydisc2.getContainers().get(1).getConfigId());
        assertTrue(mydisc2.getContainers().get(1).isInitialized());

        assertEquals("", mydisc.getContainers().get(0).getJvmOptions());
        assertEquals("", mydisc.getContainers().get(1).getJvmOptions());
        assertEquals("", mydisc.getContainers().get(2).getJvmOptions());
        assertEquals(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so"), mydisc.getContainers().get(0).getPreLoad());
        assertEquals(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so"), mydisc.getContainers().get(1).getPreLoad());
        assertEquals(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so"), mydisc.getContainers().get(2).getPreLoad());
        assertEquals(Optional.empty(), mydisc.getMemoryPercentage());

        assertEquals("-Xlog:gc", mydisc2.getContainers().get(0).getJvmOptions());
        assertEquals("-Xlog:gc", mydisc2.getContainers().get(1).getJvmOptions());
        assertEquals("lib/blablamalloc.so", mydisc2.getContainers().get(0).getPreLoad());
        assertEquals("lib/blablamalloc.so", mydisc2.getContainers().get(1).getPreLoad());
        assertEquals(45, mydisc2.getMemoryPercentage().get().ofContainerAvailable());
        assertEquals(Optional.of("-XX:+UseParNewGC"), mydisc2.getJvmGCOptions());
        QrStartConfig.Builder qrStartBuilder = new QrStartConfig.Builder();
        mydisc2.getConfig(qrStartBuilder);
        QrStartConfig qrsStartConfig = new QrStartConfig(qrStartBuilder);
        assertEquals(45, qrsStartConfig.jvm().heapSizeAsPercentageOfPhysicalMemory());

        HostSystem hostSystem = model.hostSystem();
        assertTrue(hostNameExists(hostSystem, "myhost0"));
        assertTrue(hostNameExists(hostSystem, "myhost1"));
        assertTrue(hostNameExists(hostSystem, "myhost2"));
        assertFalse(hostNameExists(hostSystem, "Nope"));
    }
Test cases for provisioning nodes to entire Vespa models.

@author Vegard Havdal
@author bratseth
config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java