Search in sources :

Example 6 with Orchestrator

use of com.yahoo.vespa.orchestrator.Orchestrator in project vespa by vespa-engine.

the class InactiveAndFailedExpirerTest method node_that_wants_to_retire_is_moved_to_parked.

@Test
public void node_that_wants_to_retire_is_moved_to_parked() throws OrchestrationException {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    tester.makeReadyNodes(5, "default");
    // Allocate two nodes
    {
        List<HostSpec> hostSpecs = tester.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1);
        tester.activate(applicationId, new HashSet<>(hostSpecs));
        assertEquals(2, tester.getNodes(applicationId, Node.State.active).size());
    }
    // Flag one node for retirement and redeploy
    {
        Node toRetire = tester.getNodes(applicationId, Node.State.active).asList().get(0);
        tester.patchNode(toRetire.with(toRetire.status().withWantToRetire(true)));
        List<HostSpec> hostSpecs = tester.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1);
        tester.activate(applicationId, new HashSet<>(hostSpecs));
    }
    // Retire times out and one node is moved to inactive
    // Trigger RetiredExpirer
    tester.advanceTime(Duration.ofMinutes(11));
    MockDeployer deployer = new MockDeployer(tester.provisioner(), Collections.singletonMap(applicationId, new MockDeployer.ApplicationContext(applicationId, cluster, Capacity.fromNodeCount(2, Optional.of("default"), false), 1)));
    Orchestrator orchestrator = mock(Orchestrator.class);
    doThrow(new RuntimeException()).when(orchestrator).acquirePermissionToRemove(any());
    new RetiredExpirer(tester.nodeRepository(), tester.orchestrator(), deployer, tester.clock(), Duration.ofDays(30), Duration.ofMinutes(10), new JobControl(tester.nodeRepository().database())).run();
    assertEquals(1, tester.nodeRepository().getNodes(Node.State.inactive).size());
    // Inactive times out and one node is moved to parked
    // Trigger InactiveExpirer
    tester.advanceTime(Duration.ofMinutes(11));
    new InactiveExpirer(tester.nodeRepository(), tester.clock(), Duration.ofMinutes(10), new JobControl(tester.nodeRepository().database())).run();
    assertEquals(1, tester.nodeRepository().getNodes(Node.State.parked).size());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) List(java.util.List) ProvisioningTester(com.yahoo.vespa.hosted.provision.provisioning.ProvisioningTester) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with Orchestrator

use of com.yahoo.vespa.orchestrator.Orchestrator in project vespa by vespa-engine.

the class HostResourceTest method patch_state_may_throw_bad_request.

@Test(expected = BadRequestException.class)
public void patch_state_may_throw_bad_request() {
    Orchestrator orchestrator = mock(Orchestrator.class);
    HostResource hostResource = new HostResource(orchestrator, uriInfo);
    String hostNameString = "hostname";
    PatchHostRequest request = new PatchHostRequest();
    request.state = "bad state";
    hostResource.patch(hostNameString, request);
}
Also used : PatchHostRequest(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) Test(org.junit.Test)

Example 8 with Orchestrator

use of com.yahoo.vespa.orchestrator.Orchestrator in project vespa by vespa-engine.

the class HostResourceTest method patch_handles_exception_in_orchestrator.

@Test(expected = InternalServerErrorException.class)
public void patch_handles_exception_in_orchestrator() throws OrchestrationException {
    Orchestrator orchestrator = mock(Orchestrator.class);
    HostResource hostResource = new HostResource(orchestrator, uriInfo);
    String hostNameString = "hostname";
    PatchHostRequest request = new PatchHostRequest();
    request.state = "NO_REMARKS";
    doThrow(new OrchestrationException("error")).when(orchestrator).setNodeStatus(new HostName(hostNameString), HostStatus.NO_REMARKS);
    hostResource.patch(hostNameString, request);
}
Also used : OrchestrationException(com.yahoo.vespa.orchestrator.OrchestrationException) PatchHostRequest(com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) HostName(com.yahoo.vespa.applicationmodel.HostName) Test(org.junit.Test)

Aggregations

Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)8 Test (org.junit.Test)7 HostName (com.yahoo.vespa.applicationmodel.HostName)4 Node (com.yahoo.vespa.hosted.provision.Node)4 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)3 PatchHostRequest (com.yahoo.vespa.orchestrator.restapi.wire.PatchHostRequest)3 DockerImage (com.yahoo.config.provision.DockerImage)2 NodeFlavors (com.yahoo.config.provision.NodeFlavors)2 Curator (com.yahoo.vespa.curator.Curator)2 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)2 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)2 MetricsReporter (com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter)2 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)2 OrchestrationException (com.yahoo.vespa.orchestrator.OrchestrationException)2 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)2 ServiceMonitor (com.yahoo.vespa.service.monitor.ServiceMonitor)2 HashSet (java.util.HashSet)2 List (java.util.List)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1