aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcVersionAutoDowngradeTest.java
blob: df0b873e25ba3ebdebba4f214d66fbc0fd60e46a (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.distribution.ConfiguredNode;
import com.yahoo.vdslib.state.NodeState;
import com.yahoo.vdslib.state.State;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

public class RpcVersionAutoDowngradeTest extends FleetControllerTest {

    private void setUpFakeCluster(int nodeRpcVersion) throws Exception {
        List<ConfiguredNode> configuredNodes = new ArrayList<>();
        for (int i = 0 ; i < 10; i++) {
            configuredNodes.add(new ConfiguredNode(i, false));
        }
        FleetControllerOptions options = defaultOptions("mycluster", configuredNodes);
        setUpFleetController(false, options);
        DummyVdsNodeOptions nodeOptions = new DummyVdsNodeOptions();
        nodeOptions.stateCommunicationVersion = nodeRpcVersion;
        List<DummyVdsNode> nodes = setUpVdsNodes(false, nodeOptions, true, configuredNodes);
        for (DummyVdsNode node : nodes) {
            node.setNodeState(new NodeState(node.getType(), State.UP).setMinUsedBits(20));
            node.connect();
        }
    }

    @Test
    void cluster_state_rpc_version_is_auto_downgraded_and_retried_for_older_nodes() throws Exception {
        setUpFakeCluster(2); // HEAD is at v4
        waitForState("version:\\d+ distributor:10 storage:10");
    }

    @Test
    void implicit_activation_for_nodes_that_return_not_found_for_version_activation_rpc() throws Exception {
        setUpFakeCluster(3); // HEAD is at v4
        waitForState("version:\\d+ distributor:10 storage:10");
    }

    // TODO partial version setup for simulating upgrades

}