Search in sources :

Example 46 with Zone

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

the class ProvisioningTest method out_of_desired_flavor.

@Test
public void out_of_desired_flavor() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    // need 2+2+3+3=10
    tester.makeReadyNodes(10, "small");
    // need 2+2+3+3=10
    tester.makeReadyNodes(9, "large");
    ApplicationId application = tester.makeApplicationId();
    try {
        prepare(application, 2, 2, 3, 3, "large", tester);
        fail("Expected exception");
    } catch (OutOfCapacityException e) {
        assertTrue(e.getMessage().startsWith("Could not satisfy request for 3 nodes of flavor 'large'"));
    }
}
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 47 with Zone

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

the class ProvisioningTest method application_deployment_extends_existing_reservations_on_deploy.

@Test
public void application_deployment_extends_existing_reservations_on_deploy() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application = tester.makeApplicationId();
    tester.makeReadyNodes(2, "default");
    // Deploy fails with out of capacity
    try {
        prepare(application, 2, 0, 2, 0, "default", tester);
        fail("Expected exception");
    } catch (OutOfCapacityException ignored) {
    }
    assertEquals("Reserved a subset of required nodes", 2, tester.getNodes(application, Node.State.reserved).size());
    // Enough nodes become available
    tester.makeReadyNodes(2, "default");
    // Deploy is retried after a few minutes
    tester.clock().advance(Duration.ofMinutes(2));
    SystemState state = prepare(application, 2, 0, 2, 0, "default", tester);
    List<Node> reserved = tester.getNodes(application, Node.State.reserved).asList();
    assertEquals("Reserved required nodes", 4, reserved.size());
    assertTrue("Time of event is updated for all nodes", reserved.stream().allMatch(n -> n.history().event(History.Event.Type.reserved).get().at().equals(tester.clock().instant())));
    // Over 10 minutes pass since first reservation. First set of reserved nodes are not expired
    tester.clock().advance(Duration.ofMinutes(8).plus(Duration.ofSeconds(1)));
    ReservationExpirer expirer = new ReservationExpirer(tester.nodeRepository(), tester.clock(), Duration.ofMinutes(10), new JobControl(tester.nodeRepository().database()));
    expirer.run();
    assertEquals("Nodes remain reserved", 4, tester.getNodes(application, Node.State.reserved).size());
    tester.activate(application, state.allHosts);
    assertEquals(4, tester.getNodes(application, Node.State.active).size());
}
Also used : Capacity(com.yahoo.config.provision.Capacity) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) ClusterSpec(com.yahoo.config.provision.ClusterSpec) Node(com.yahoo.vespa.hosted.provision.Node) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) Function(java.util.function.Function) RegionName(com.yahoo.config.provision.RegionName) NameResolver(com.yahoo.vespa.hosted.provision.persistence.NameResolver) TenantName(com.yahoo.config.provision.TenantName) Curator(com.yahoo.vespa.curator.Curator) HashSet(java.util.HashSet) ReservationExpirer(com.yahoo.vespa.hosted.provision.maintenance.ReservationExpirer) History(com.yahoo.vespa.hosted.provision.node.History) NestedTransaction(com.yahoo.transaction.NestedTransaction) Duration(java.time.Duration) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Assert.fail(org.junit.Assert.fail) NodeFlavors(com.yahoo.config.provision.NodeFlavors) Iterator(java.util.Iterator) Environment(com.yahoo.config.provision.Environment) Predicate(java.util.function.Predicate) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) HostSpec(com.yahoo.config.provision.HostSpec) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) HostFilter(com.yahoo.config.provision.HostFilter) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Ignore(org.junit.Ignore) Flavor(com.yahoo.config.provision.Flavor) Assert.assertFalse(org.junit.Assert.assertFalse) Zone(com.yahoo.config.provision.Zone) Optional(java.util.Optional) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) ReservationExpirer(com.yahoo.vespa.hosted.provision.maintenance.ReservationExpirer) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 48 with Zone

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

the class ProvisioningTest method test_deployment_flavor.

/**
 * Test always uses the zone default flavor
 */
@Test
public void test_deployment_flavor() {
    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, "large", 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 49 with Zone

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

the class ProvisioningTest method dev_deployment_flavor.

/**
 * Dev always uses the zone default flavor
 */
@Test
public void dev_deployment_flavor() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.dev, RegionName.from("us-east")));
    ApplicationId application = tester.makeApplicationId();
    tester.makeReadyNodes(4, "default");
    SystemState state = prepare(application, 2, 2, 3, 3, "large", 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 50 with Zone

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

the class ProvisioningTest method application_deployment_multiple_flavors.

@Test
public void application_deployment_multiple_flavors() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(12, "small");
    tester.makeReadyNodes(16, "large");
    // deploy
    SystemState state1 = prepare(application1, 2, 2, 4, 4, "small", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy with reduced size (to cause us to have retired nodes before switching flavor)
    SystemState state2 = prepare(application1, 2, 2, 3, 3, "small", tester);
    tester.activate(application1, state2.allHosts);
    // redeploy with increased sizes and new flavor
    SystemState state3 = prepare(application1, 3, 4, 4, 5, "large", tester);
    assertEquals("New nodes are reserved", 16, tester.nodeRepository().getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state3.allHosts);
    assertEquals("'small' container nodes are retired because we are swapping the entire cluster", 2 + 2, tester.getNodes(application1, Node.State.active).retired().type(ClusterSpec.Type.container).flavor("small").size());
    assertEquals("'small' content nodes are retired", 4 + 4, tester.getNodes(application1, Node.State.active).retired().type(ClusterSpec.Type.content).flavor("small").size());
    assertEquals("No 'large' content nodes are retired", 0, tester.getNodes(application1, Node.State.active).retired().flavor("large").size());
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) 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