Search in sources :

Example 56 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method prod_deployment_requires_redundancy.

@Test(expected = IllegalArgumentException.class)
public void prod_deployment_requires_redundancy() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application = tester.makeApplicationId();
    tester.makeReadyNodes(10, "default");
    prepare(application, 1, 2, 3, 3, "default", tester);
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 57 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_multiple_flavors_with_replacement.

@Test
public void application_deployment_multiple_flavors_with_replacement() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(8, "large");
    tester.makeReadyNodes(8, "large-variant");
    // deploy with flavor which will be fulfilled by some old and new nodes
    SystemState state1 = prepare(application1, 2, 2, 4, 4, "old-large1", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy with increased sizes, this will map to the remaining old/new nodes
    SystemState state2 = prepare(application1, 3, 4, 4, 5, "old-large2", tester);
    assertEquals("New nodes are reserved", 4, tester.getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state2.allHosts);
    assertEquals("All nodes are used", 16, tester.getNodes(application1, Node.State.active).size());
    assertEquals("No nodes are retired", 0, tester.getNodes(application1, Node.State.active).retired().size());
    // This is a noop as we are already using large nodes and nodes which replace large
    SystemState state3 = prepare(application1, 3, 4, 4, 5, "large", tester);
    assertEquals("Noop", 0, tester.getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state3.allHosts);
    try {
        SystemState state4 = prepare(application1, 3, 4, 4, 5, "large-variant", tester);
        fail("Should fail as we don't have that many large-variant nodes");
    } catch (OutOfCapacityException expected) {
    }
    // make enough nodes to complete the switch to large-variant
    tester.makeReadyNodes(8, "large-variant");
    SystemState state4 = prepare(application1, 3, 4, 4, 5, "large-variant", tester);
    assertEquals("New 'large-variant' nodes are reserved", 8, tester.getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state4.allHosts);
// (we can not check for the precise state here without carrying over from earlier as the distribution of
// old and new on different clusters is unknown)
}
Also used : Zone(com.yahoo.config.provision.Zone) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 58 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method assertCorrectFlavorPreferences.

private void assertCorrectFlavorPreferences(boolean largeIsStock) {
    FlavorConfigBuilder b = new FlavorConfigBuilder();
    b.addFlavor("large", 4., 8., 100, Flavor.Type.BARE_METAL).cost(10).stock(largeIsStock);
    FlavorsConfig.Flavor.Builder largeVariant = b.addFlavor("large-variant", 3., 9., 101, Flavor.Type.BARE_METAL).cost(9);
    b.addReplaces("large", largeVariant);
    FlavorsConfig.Flavor.Builder largeVariantVariant = b.addFlavor("large-variant-variant", 4., 9., 101, Flavor.Type.BARE_METAL).cost(11);
    b.addReplaces("large-variant", largeVariantVariant);
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build());
    // cost = 10
    tester.makeReadyNodes(6, "large");
    // cost = 9
    tester.makeReadyNodes(6, "large-variant");
    // cost = 11
    tester.makeReadyNodes(6, "large-variant-variant");
    ApplicationId applicationId = tester.makeApplicationId();
    ClusterSpec contentClusterSpec = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.42"), false);
    ClusterSpec containerClusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("myContainer"), Version.fromString("6.42"), false);
    List<HostSpec> containerNodes = tester.prepare(applicationId, containerClusterSpec, 5, 1, "large");
    List<HostSpec> contentNodes = tester.prepare(applicationId, contentClusterSpec, 10, 1, "large");
    if (largeIsStock) {
        // 'large' is replaced by 'large-variant' when possible, as it is cheaper
        tester.assertNumberOfNodesWithFlavor(containerNodes, "large-variant", 5);
        tester.assertNumberOfNodesWithFlavor(contentNodes, "large-variant", 1);
        tester.assertNumberOfNodesWithFlavor(contentNodes, "large", 6);
    } else {
        // 'large' is preferred when available, as it is what is exactly specified
        tester.assertNumberOfNodesWithFlavor(containerNodes, "large", 5);
        tester.assertNumberOfNodesWithFlavor(contentNodes, "large", 1);
        tester.assertNumberOfNodesWithFlavor(contentNodes, "large-variant", 6);
    }
    // in both cases the most expensive, never exactly specified is least preferred
    tester.assertNumberOfNodesWithFlavor(contentNodes, "large-variant-variant", 3);
}
Also used : Zone(com.yahoo.config.provision.Zone) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Flavor(com.yahoo.config.provision.Flavor)

Example 59 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method test_deployment_size.

@Test
public void test_deployment_size() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.test, RegionName.from("us-east")));
    ApplicationId application = tester.makeApplicationId();
    tester.makeReadyNodes(4, "default");
    SystemState state = prepare(application, 2, 2, 3, 3, "default", tester);
    assertEquals(4, state.allHosts.size());
    tester.activate(application, state.allHosts);
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 60 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_variable_application_size.

@Test
public void application_deployment_variable_application_size() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(24, "default");
    // deploy
    SystemState state1 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy with increased sizes
    SystemState state2 = prepare(application1, 3, 4, 4, 5, "default", tester);
    state2.assertExtends(state1);
    assertEquals("New nodes are reserved", 6, tester.getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state2.allHosts);
    // decrease again
    SystemState state3 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state3.allHosts);
    assertEquals("Superfluous container nodes are deactivated", 3 - 2 + 4 - 2, tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Superfluous content nodes are retired", 4 - 3 + 5 - 3, tester.getNodes(application1, Node.State.active).retired().size());
    // increase even more, and remove one node before deploying
    SystemState state4 = prepare(application1, 4, 5, 5, 6, "default", tester);
    assertEquals("Inactive nodes are reused", 0, tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Earlier retired nodes are not unretired before activate", 4 - 3 + 5 - 3, tester.getNodes(application1, Node.State.active).retired().size());
    state4.assertExtends(state2);
    assertEquals("New and inactive nodes are reserved", 4 + 3, tester.getNodes(application1, Node.State.reserved).size());
    // Remove a retired host from one of the content clusters (which one is random depending on host names)
    HostSpec removed = state4.removeHost(tester.getNodes(application1, Node.State.active).retired().asList().get(0).hostname());
    tester.activate(application1, state4.allHosts);
    assertEquals("Retired active removed when activating became inactive", 1, tester.getNodes(application1, Node.State.inactive).asList().size());
    assertEquals(removed.hostname(), tester.getNodes(application1, Node.State.inactive).asList().get(0).hostname());
    assertEquals("Earlier retired nodes are unretired on activate", 0, tester.getNodes(application1, Node.State.active).retired().size());
    // decrease again
    SystemState state5 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state5.allHosts);
    assertEquals("Superfluous container nodes are also deactivated", 4 - 2 + 5 - 2 + 1, // 
    tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Superfluous content nodes are retired", 5 - 3 + 6 - 3 - 1, tester.getNodes(application1, Node.State.active).retired().size());
    // increase content slightly
    SystemState state6 = prepare(application1, 2, 2, 4, 3, "default", tester);
    tester.activate(application1, state6.allHosts);
    assertEquals("One content node is unretired", 5 - 4 + 6 - 3 - 1, tester.getNodes(application1, Node.State.active).retired().size());
    // Then reserve more
    SystemState state7 = prepare(application1, 8, 2, 2, 2, "default", tester);
    // delete app
    NestedTransaction removeTransaction = new NestedTransaction();
    tester.provisioner().remove(removeTransaction, application1);
    removeTransaction.commit();
    assertEquals(0, tester.getNodes(application1, Node.State.active).size());
    assertEquals(0, tester.getNodes(application1, Node.State.reserved).size());
}
Also used : Zone(com.yahoo.config.provision.Zone) NestedTransaction(com.yahoo.transaction.NestedTransaction) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Aggregations

Zone (com.yahoo.config.provision.Zone)71 Test (org.junit.Test)64 ApplicationId (com.yahoo.config.provision.ApplicationId)51 Node (com.yahoo.vespa.hosted.provision.Node)17 Flavor (com.yahoo.config.provision.Flavor)15 ClusterSpec (com.yahoo.config.provision.ClusterSpec)13 HostSpec (com.yahoo.config.provision.HostSpec)12 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)10 HashSet (java.util.HashSet)8 DeployState (com.yahoo.config.model.deploy.DeployState)6 NestedTransaction (com.yahoo.transaction.NestedTransaction)6 Curator (com.yahoo.vespa.curator.Curator)6 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)6 NodeList (com.yahoo.vespa.hosted.provision.NodeList)6 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)6 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)5 Version (com.yahoo.component.Version)5 RegionName (com.yahoo.config.provision.RegionName)5 TenantName (com.yahoo.config.provision.TenantName)5 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)5