aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java
blob: 17ed6ca7a7bc6f4c36a888eef2af3550872ceb3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;

import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Transport;
import com.yahoo.vdslib.state.State;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.junit.jupiter.api.Assertions.assertEquals;

@ExtendWith(CleanupZookeeperLogsOnSuccess.class)
public class WantedStateTest extends FleetControllerTest {

    private Supervisor supervisor;
    private final Timer timer = new FakeTimer();

    @BeforeEach
    public void setup() {
        supervisor = new Supervisor(new Transport());
    }

    @AfterEach
    public void teardown() {
        supervisor.transport().shutdown().join();
    }

    @Test
    void testSettingStorageNodeMaintenanceAndBack() throws Exception {
        setUpFleetController(timer, defaultOptions());
        setUpVdsNodes(timer);
        waitForStableSystem();

        setWantedState(nodes.get(1), State.MAINTENANCE, null, supervisor);
        waitForState("version:\\d+ distributor:10 storage:10 .0.s:m");

        setWantedState(nodes.get(1), State.UP, null, supervisor);
        waitForState("version:\\d+ distributor:10 storage:10");
    }

    @Test
    void testOverridingWantedStateOtherReason() throws Exception {
        setUpFleetController(timer, defaultOptions());
        setUpVdsNodes(timer);
        waitForStableSystem();

        setWantedState(nodes.get(1), State.MAINTENANCE, "Foo", supervisor);
        waitForState("version:\\d+ distributor:10 storage:10 .0.s:m");
        assertEquals("Foo", fleetController().getWantedNodeState(nodes.get(1).getNode()).getDescription());

        setWantedState(nodes.get(1), State.MAINTENANCE, "Bar", supervisor);
        waitForCompleteCycle();
        assertEquals("Bar", fleetController().getWantedNodeState(nodes.get(1).getNode()).getDescription());

        setWantedState(nodes.get(1), State.UP, null, supervisor);
        waitForState("version:\\d+ distributor:10 storage:10");
    }


}