Search in sources :

Example 1 with FlavorsConfig

use of com.yahoo.config.provisioning.FlavorsConfig in project vespa by vespa-engine.

the class NodeFlavorsTest method testRetiredFlavorWithoutReplacement.

@Test
public void testRetiredFlavorWithoutReplacement() {
    FlavorsConfig.Builder builder = new FlavorsConfig.Builder();
    List<FlavorsConfig.Flavor.Builder> flavorBuilderList = new ArrayList<>();
    {
        FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
        flavorBuilder.name("retired").retired(true);
        flavorBuilderList.add(flavorBuilder);
    }
    {
        FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
        flavorBuilder.name("chocolate");
        flavorBuilderList.add(flavorBuilder);
    }
    builder.flavor(flavorBuilderList);
    FlavorsConfig config = new FlavorsConfig(builder);
    exception.expect(IllegalStateException.class);
    exception.expectMessage("Flavor 'retired' is retired, but has no replacement");
    new NodeFlavors(config);
}
Also used : ArrayList(java.util.ArrayList) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Test(org.junit.Test)

Example 2 with FlavorsConfig

use of com.yahoo.config.provisioning.FlavorsConfig in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_multiple_flavors_default_per_type.

@Test
public void application_deployment_multiple_flavors_default_per_type() {
    ConfigserverConfig.Builder config = new ConfigserverConfig.Builder();
    config.environment("prod");
    config.region("us-east");
    config.defaultFlavor("not-used");
    config.defaultContainerFlavor("small");
    config.defaultContentFlavor("large");
    ProvisioningTester tester = new ProvisioningTester(new Zone(new ConfigserverConfig(config), new NodeFlavors(new FlavorsConfig(new FlavorsConfig.Builder()))));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(10, "small");
    tester.makeReadyNodes(9, "large");
    // deploy
    SystemState state1 = prepare(application1, 2, 3, 4, 5, null, tester);
    tester.activate(application1, state1.allHosts);
    assertEquals("'small' nodes are used for containers", 2 + 3, tester.getNodes(application1, Node.State.active).flavor("small").size());
    assertEquals("'large' nodes are used for content", 4 + 5, tester.getNodes(application1, Node.State.active).flavor("large").size());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) NodeFlavors(com.yahoo.config.provision.NodeFlavors) Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Test(org.junit.Test)

Example 3 with FlavorsConfig

use of com.yahoo.config.provisioning.FlavorsConfig in project vespa by vespa-engine.

the class NodeFlavorsTest method testReplacesWithBadValue.

@Test
public void testReplacesWithBadValue() {
    FlavorsConfig.Builder builder = new FlavorsConfig.Builder();
    List<FlavorsConfig.Flavor.Builder> flavorBuilderList = new ArrayList<>();
    FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
    FlavorsConfig.Flavor.Replaces.Builder flavorReplacesBuilder = new FlavorsConfig.Flavor.Replaces.Builder();
    flavorReplacesBuilder.name("non-existing-config");
    flavorBuilder.name("strawberry").cost(2).replaces.add(flavorReplacesBuilder);
    flavorBuilderList.add(flavorBuilder);
    builder.flavor(flavorBuilderList);
    FlavorsConfig config = new FlavorsConfig(builder);
    exception.expect(IllegalStateException.class);
    exception.expectMessage("Replaces for strawberry pointing to a non existing flavor: non-existing-config");
    new NodeFlavors(config);
}
Also used : ArrayList(java.util.ArrayList) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Test(org.junit.Test)

Example 4 with FlavorsConfig

use of com.yahoo.config.provisioning.FlavorsConfig in project vespa by vespa-engine.

the class NodeFlavorsTest method testConfigParsing.

@Test
public void testConfigParsing() {
    FlavorsConfig.Builder builder = new FlavorsConfig.Builder();
    List<FlavorsConfig.Flavor.Builder> flavorBuilderList = new ArrayList<>();
    {
        FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
        FlavorsConfig.Flavor.Replaces.Builder flavorReplacesBuilder = new FlavorsConfig.Flavor.Replaces.Builder();
        flavorReplacesBuilder.name("banana");
        flavorBuilder.name("strawberry").cost(2).replaces.add(flavorReplacesBuilder);
        flavorBuilderList.add(flavorBuilder);
    }
    {
        FlavorsConfig.Flavor.Builder flavorBuilder = new FlavorsConfig.Flavor.Builder();
        flavorBuilder.name("banana").cost(3);
        flavorBuilderList.add(flavorBuilder);
    }
    builder.flavor(flavorBuilderList);
    FlavorsConfig config = new FlavorsConfig(builder);
    NodeFlavors nodeFlavors = new NodeFlavors(config);
    assertThat(nodeFlavors.getFlavor("banana").get().cost(), is(3));
}
Also used : ArrayList(java.util.ArrayList) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Test(org.junit.Test)

Example 5 with FlavorsConfig

use of com.yahoo.config.provisioning.FlavorsConfig in project vespa by vespa-engine.

the class ResourceCapacityTest method basic_capacity_and_compare_operations.

@Test
public void basic_capacity_and_compare_operations() {
    FlavorConfigBuilder b = new FlavorConfigBuilder();
    b.addFlavor("host-large", 6., 6., 6, Flavor.Type.BARE_METAL);
    b.addFlavor("host-small", 3., 3., 3, Flavor.Type.BARE_METAL);
    b.addFlavor("d-1", 1, 1., 1, Flavor.Type.DOCKER_CONTAINER);
    b.addFlavor("d-2", 2, 2., 2, Flavor.Type.DOCKER_CONTAINER);
    b.addFlavor("d-3", 3, 3., 3, Flavor.Type.DOCKER_CONTAINER);
    b.addFlavor("d-3-disk", 3, 3., 5, Flavor.Type.DOCKER_CONTAINER);
    b.addFlavor("d-3-mem", 3, 5., 3, Flavor.Type.DOCKER_CONTAINER);
    b.addFlavor("d-3-cpu", 5, 3., 3, Flavor.Type.DOCKER_CONTAINER);
    FlavorsConfig flavors = b.build();
    Flavor hostLargeFlavor = new Flavor(flavors.flavor(0));
    Flavor hostSmallFlavor = new Flavor(flavors.flavor(1));
    Flavor d1Flavor = new Flavor(flavors.flavor(2));
    Flavor d2Flavor = new Flavor(flavors.flavor(3));
    Flavor d3Flavor = new Flavor(flavors.flavor(4));
    Flavor d3DiskFlavor = new Flavor(flavors.flavor(5));
    Flavor d3MemFlavor = new Flavor(flavors.flavor(6));
    Flavor d3CPUFlavor = new Flavor(flavors.flavor(7));
    Node nodeHostSmall = node(hostSmallFlavor);
    ResourceCapacity capacityOfHostSmall = new ResourceCapacity(nodeHostSmall);
    // Assert initial capacities
    assertTrue(capacityOfHostSmall.hasCapacityFor(hostSmallFlavor));
    assertTrue(capacityOfHostSmall.hasCapacityFor(d1Flavor));
    assertTrue(capacityOfHostSmall.hasCapacityFor(d2Flavor));
    assertTrue(capacityOfHostSmall.hasCapacityFor(d3Flavor));
    assertFalse(capacityOfHostSmall.hasCapacityFor(hostLargeFlavor));
    // Also check that we are taking all three resources into accout
    assertFalse(capacityOfHostSmall.hasCapacityFor(d3DiskFlavor));
    assertFalse(capacityOfHostSmall.hasCapacityFor(d3MemFlavor));
    assertFalse(capacityOfHostSmall.hasCapacityFor(d3CPUFlavor));
    // Compare it to various flavors
    assertEquals(1, capacityOfHostSmall.compare(nodeCapacity(d1Flavor)));
    assertEquals(1, capacityOfHostSmall.compare(nodeCapacity(d2Flavor)));
    assertEquals(0, capacityOfHostSmall.compare(nodeCapacity(d3Flavor)));
    assertEquals(-1, capacityOfHostSmall.compare(nodeCapacity(d3DiskFlavor)));
    assertEquals(-1, capacityOfHostSmall.compare(nodeCapacity(d3CPUFlavor)));
    assertEquals(-1, capacityOfHostSmall.compare(nodeCapacity(d3MemFlavor)));
    // Change free capacity and assert on rest capacity
    capacityOfHostSmall.subtract(node(d1Flavor));
    assertEquals(0, capacityOfHostSmall.compare(nodeCapacity(d2Flavor)));
    // Assert on rest capacity
    assertTrue(capacityOfHostSmall.hasCapacityFor(d1Flavor));
    assertFalse(capacityOfHostSmall.hasCapacityFor(d3Flavor));
    // At last compare the disk and cpu and mem variations
    assertEquals(-1, nodeCapacity(d3Flavor).compare(nodeCapacity(d3DiskFlavor)));
    assertEquals(1, nodeCapacity(d3DiskFlavor).compare(nodeCapacity(d3CPUFlavor)));
    assertEquals(-1, nodeCapacity(d3CPUFlavor).compare(nodeCapacity(d3MemFlavor)));
    assertEquals(1, nodeCapacity(d3MemFlavor).compare(nodeCapacity(d3DiskFlavor)));
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) Flavor(com.yahoo.config.provision.Flavor) Test(org.junit.Test)

Aggregations

FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Flavor (com.yahoo.config.provision.Flavor)1 NodeFlavors (com.yahoo.config.provision.NodeFlavors)1 Zone (com.yahoo.config.provision.Zone)1 Node (com.yahoo.vespa.hosted.provision.Node)1