summaryrefslogtreecommitdiffstats
path: root/clustercontroller-standalone/src/test/java/com/yahoo/vespa/clustercontroller/standalone/ClusterControllerConfigFetcherTest.java
blob: 15af9bd2c8cdc51879dc0d6de7ce87827d723eeb (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.standalone;

public class ClusterControllerConfigFetcherTest extends ClusterControllerTest {
    public void testSimple() throws Exception {
        setFleetControllerConfigProperty();
        setSlobrokConfigProperty();
        addFleetControllerConfig(2, 1);
        addSlobrokConfig();
        addDistributionConfig();
        addZookeepersConfig();
        ClusterControllerConfigFetcher configFetcher = new ClusterControllerConfigFetcher();
        configFetcher.getOptions();
        configFetcher.updated(100);
        assertEquals(1, configFetcher.getGeneration());
        configFetcher.close();
    }

    public void testInitialConfigFailure() throws Exception {
        setFleetControllerConfigProperty();
        setSlobrokConfigProperty();
        addFleetControllerConfig(2, 1);
        addSlobrokConfig();
        addDistributionConfig();
        addZookeepersConfig();
        try{
            ClusterControllerConfigFetcher configFetcher = new ClusterControllerConfigFetcher() {
                boolean configReady() {
                    return false;
                }
            };
            fail("Control should not reach here");
        } catch (IllegalStateException e) {
            assertEquals("Initial configuration failed.", e.getMessage());
        }
    }

    public void testConfigUpdate() throws Exception {
        setFleetControllerConfigProperty();
        setSlobrokConfigProperty();
        addFleetControllerConfig(2, 1);
        addSlobrokConfig();
        addDistributionConfig();
        addZookeepersConfig();
        ClusterControllerConfigFetcher configFetcher = new ClusterControllerConfigFetcher() {
            boolean configUpdated(long millis) {
                return true;
            }
        };
        configFetcher.updated(1000);
    }
}