aboutsummaryrefslogtreecommitdiffstats
path: root/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/internal/ConfigserverUtil.java
blob: 16963797ac8b1122a0e5163bc7e6147729740f73 (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 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.service.monitor.internal;

import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.vespa.service.monitor.application.ConfigServerApplication;

/**
 * @author hakon
 */
public class ConfigserverUtil {
    /** Create a ConfigserverConfig with the given settings. */
    public static ConfigserverConfig create(
            boolean nodeAdminInContainer,
            boolean multitenant,
            String configServerHostname1,
            String configServerHostname2,
            String configServerHostname3) {
        return new ConfigserverConfig(
                new ConfigserverConfig.Builder()
                        .nodeAdminInContainer(nodeAdminInContainer)
                        .multitenant(multitenant)
                        .zookeeperserver(new ConfigserverConfig.Zookeeperserver.Builder().hostname(configServerHostname1).port(1))
                        .zookeeperserver(new ConfigserverConfig.Zookeeperserver.Builder().hostname(configServerHostname2).port(2))
                        .zookeeperserver(new ConfigserverConfig.Zookeeperserver.Builder().hostname(configServerHostname3).port(3)));
    }

    public static ConfigserverConfig createExampleConfigserverConfig() {
        return create(true, true, "cfg1", "cfg2", "cfg3");
    }

    public static ConfigserverConfig createExampleConfigserverConfig(boolean nodeAdminInContainer,
                                                                     boolean multitenant) {
        return create(nodeAdminInContainer, multitenant, "cfg1", "cfg2", "cfg3");
    }

    public static ApplicationInfo makeConfigServerApplicationInfo(
            String configServerHostname1,
            String configServerHostname2,
            String configServerHostname3) {
        return ConfigServerApplication.CONFIG_SERVER_APPLICATION.makeApplicationInfoFromConfig(create(
                true,
                true,
                configServerHostname1,
                configServerHostname2,
                configServerHostname3));
    }

    public static ApplicationInfo makeExampleConfigServer() {
        return makeConfigServerApplicationInfo("cfg1", "cfg2", "cfg3");
    }
}