Search in sources :

Example 11 with MockDeployer

use of com.yahoo.vespa.hosted.provision.testutils.MockDeployer 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)

Aggregations

MockDeployer (com.yahoo.vespa.hosted.provision.testutils.MockDeployer)11 ApplicationId (com.yahoo.config.provision.ApplicationId)9 ClusterSpec (com.yahoo.config.provision.ClusterSpec)9 Node (com.yahoo.vespa.hosted.provision.Node)7 Test (org.junit.Test)7 Capacity (com.yahoo.config.provision.Capacity)4 Zone (com.yahoo.config.provision.Zone)4 MetricsReporterTest (com.yahoo.vespa.hosted.provision.monitoring.MetricsReporterTest)4 ServiceMonitorStub (com.yahoo.vespa.hosted.provision.testutils.ServiceMonitorStub)4 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)3 RetiredExpirer (com.yahoo.vespa.hosted.provision.maintenance.RetiredExpirer)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Version (com.yahoo.component.Version)2 Environment (com.yahoo.config.provision.Environment)2 HostSpec (com.yahoo.config.provision.HostSpec)2 NodeType (com.yahoo.config.provision.NodeType)2 RegionName (com.yahoo.config.provision.RegionName)2 Agent (com.yahoo.vespa.hosted.provision.node.Agent)2