aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/WantedStateTest.java
blob: a58f75dba02f08f9083755cb0f4a604df3603a93 (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
// 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.vdslib.state.State;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class WantedStateTest extends FleetControllerTest {

    @Test
    public void testSettingStorageNodeMaintenanceAndBack() throws Exception {
        startingTest("WantedStateTest::testSettingStorageNodeMaintenanceAndBack()");
        setUpFleetController(true, defaultOptions("mycluster"));
        setUpVdsNodes(true, new DummyVdsNodeOptions());
        waitForStableSystem();

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

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

    @Test
    public void testOverridingWantedStateOtherReason() throws Exception {
        startingTest("WantedStateTest::testOverridingWantedStateOtherReason()");
        setUpFleetController(true, defaultOptions("mycluster"));
        setUpVdsNodes(true, new DummyVdsNodeOptions());
        waitForStableSystem();

        setWantedState(nodes.get(1), State.MAINTENANCE, "Foo");
        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");
        waitForCompleteCycle();
        assertEquals("Bar", fleetController.getWantedNodeState(nodes.get(1).getNode()).getDescription());

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


}