Search in sources :

Example 71 with ApplicationId

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

the class RetiredExpirerTest method ensure_early_inactivation.

@Test
public void ensure_early_inactivation() throws OrchestrationException {
    createReadyNodes(7, nodeRepository, nodeFlavors);
    createHostNodes(4, nodeRepository, nodeFlavors);
    ApplicationId applicationId = ApplicationId.from(TenantName.from("foo"), ApplicationName.from("bar"), InstanceName.from("fuz"));
    // Allocate content cluster of sizes 7 -> 2 -> 3:
    // Should end up with 3 nodes in the cluster (one previously retired), and 4 retired
    ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    int wantedNodes;
    activate(applicationId, cluster, wantedNodes = 7, 1, provisioner);
    activate(applicationId, cluster, wantedNodes = 2, 1, provisioner);
    activate(applicationId, cluster, wantedNodes = 3, 1, provisioner);
    assertEquals(7, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(0, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    // Cause inactivation of retired nodes
    MockDeployer deployer = new MockDeployer(provisioner, Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(wantedNodes, Optional.of("default"), false), 1)));
    // Allow the 1st and 3rd retired nodes permission to inactivate
    doNothing().doThrow(new OrchestrationException("Permission not granted 1")).doNothing().doThrow(new OrchestrationException("Permission not granted 2")).when(orchestrator).acquirePermissionToRemove(any());
    RetiredExpirer retiredExpirer = createRetiredExpirer(deployer);
    retiredExpirer.run();
    assertEquals(5, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(2, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    assertEquals(1, deployer.redeployments);
    verify(orchestrator, times(4)).acquirePermissionToRemove(any());
    // Running it again has no effect
    retiredExpirer.run();
    assertEquals(5, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(2, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    assertEquals(1, deployer.redeployments);
    verify(orchestrator, times(6)).acquirePermissionToRemove(any());
    clock.advance(RETIRED_EXPIRATION.plusMinutes(1));
    retiredExpirer.run();
    assertEquals(3, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(4, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    assertEquals(2, deployer.redeployments);
    verify(orchestrator, times(6)).acquirePermissionToRemove(any());
    // inactivated nodes are not retired
    for (Node node : nodeRepository.getNodes(applicationId, Node.State.inactive)) assertFalse(node.allocation().get().membership().retired());
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) Test(org.junit.Test)

Example 72 with ApplicationId

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

the class RetiredExpirerTest method ensure_retired_nodes_time_out.

@Test
public void ensure_retired_nodes_time_out() {
    createReadyNodes(7, nodeRepository, nodeFlavors);
    createHostNodes(4, nodeRepository, nodeFlavors);
    ApplicationId applicationId = ApplicationId.from(TenantName.from("foo"), ApplicationName.from("bar"), InstanceName.from("fuz"));
    // Allocate content cluster of sizes 7 -> 2 -> 3:
    // Should end up with 3 nodes in the cluster (one previously retired), and 4 retired
    ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    int wantedNodes;
    activate(applicationId, cluster, wantedNodes = 7, 1, provisioner);
    activate(applicationId, cluster, wantedNodes = 2, 1, provisioner);
    activate(applicationId, cluster, wantedNodes = 3, 1, provisioner);
    assertEquals(7, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(0, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    // Cause inactivation of retired nodes
    // Retire period spent
    clock.advance(Duration.ofHours(30));
    MockDeployer deployer = new MockDeployer(provisioner, Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(wantedNodes, Optional.of("default"), false), 1)));
    createRetiredExpirer(deployer).run();
    assertEquals(3, nodeRepository.getNodes(applicationId, Node.State.active).size());
    assertEquals(4, nodeRepository.getNodes(applicationId, Node.State.inactive).size());
    assertEquals(1, deployer.redeployments);
    // inactivated nodes are not retired
    for (Node node : nodeRepository.getNodes(applicationId, Node.State.inactive)) assertFalse(node.allocation().get().membership().retired());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) Test(org.junit.Test)

Example 73 with ApplicationId

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

the class DockerProvisioningTest method docker_application_deployment_with_exclusive_app_causing_allocation_failure.

/**
 * Non-exclusive app first, then an exclusive: Should give the same result as above
 */
@Test
public void docker_application_deployment_with_exclusive_app_causing_allocation_failure() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    for (int i = 1; i <= 4; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host1");
    for (int i = 5; i <= 8; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host2");
    for (int i = 9; i <= 12; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host3");
    for (int i = 13; i <= 16; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host4");
    ApplicationId application1 = tester.makeApplicationId();
    prepareAndActivate(application1, 2, true, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    try {
        ApplicationId application2 = tester.makeApplicationId();
        prepareAndActivate(application2, 3, false, tester);
        fail("Expected allocation failure");
    } catch (Exception e) {
        assertEquals("No room for 3 nodes as 2 of 4 hosts are exclusive", "Could not satisfy request for 3 nodes of flavor 'dockerSmall' for container cluster 'myContainer' group 0 6.39: Not enough nodes available due to host exclusivity constraints.", e.getMessage());
    }
    // Adding 3 nodes of another application for the same tenant works
    ApplicationId application3 = ApplicationId.from(application1.tenant(), ApplicationName.from("app3"), InstanceName.from("default"));
    prepareAndActivate(application3, 2, true, tester);
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 74 with ApplicationId

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

the class DockerProvisioningTest method docker_application_deployment_change_to_exclusive_and_back.

/**
 * Test making an application exclusive
 */
@Test
public void docker_application_deployment_change_to_exclusive_and_back() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    for (int i = 1; i <= 4; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host1");
    for (int i = 5; i <= 8; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host2");
    for (int i = 9; i <= 12; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host3");
    for (int i = 13; i <= 16; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host4");
    ApplicationId application1 = tester.makeApplicationId();
    prepareAndActivate(application1, 2, false, tester);
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertFalse(node.allocation().get().membership().cluster().isExclusive());
    prepareAndActivate(application1, 2, true, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertTrue(node.allocation().get().membership().cluster().isExclusive());
    prepareAndActivate(application1, 2, false, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertFalse(node.allocation().get().membership().cluster().isExclusive());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 75 with ApplicationId

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

the class MultigroupProvisioningTest method test_provisioning_of_multiple_groups.

@Test
public void test_provisioning_of_multiple_groups() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(21, "default");
    deploy(application1, 6, 1, tester);
    deploy(application1, 6, 2, tester);
    deploy(application1, 6, 3, tester);
    deploy(application1, 6, 6, tester);
    deploy(application1, 6, 1, tester);
    deploy(application1, 6, 6, tester);
    deploy(application1, 6, 6, tester);
    deploy(application1, 6, 2, tester);
    deploy(application1, 8, 2, tester);
    deploy(application1, 9, 3, tester);
    deploy(application1, 9, 3, tester);
    deploy(application1, 9, 3, tester);
    deploy(application1, 12, 4, tester);
    deploy(application1, 8, 4, tester);
    deploy(application1, 12, 4, tester);
    deploy(application1, 8, 2, tester);
    deploy(application1, 6, 3, tester);
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11