aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/NodeGroupTest.java
blob: 373d512f811e1c6128fd60677478bdf6ab8bab9d (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.model;

import com.yahoo.vespa.applicationmodel.ApplicationInstance;
import com.yahoo.vespa.applicationmodel.ApplicationInstanceId;
import com.yahoo.vespa.applicationmodel.HostName;
import com.yahoo.vespa.applicationmodel.TenantId;
import org.junit.Test;

import java.util.Arrays;
import java.util.HashSet;

import static org.junit.Assert.assertEquals;

public class NodeGroupTest {
    @Test
    public void testBasics() {
        ApplicationInstance applicationInstance = new ApplicationInstance(
                new TenantId("tenant"),
                new ApplicationInstanceId("application-instance"),
                new HashSet<>());

        HostName hostName1 = new HostName("host1");
        HostName hostName2 = new HostName("host2");
        HostName hostName3 = new HostName("host3");
        NodeGroup nodeGroup = new NodeGroup(applicationInstance, hostName1, hostName3);
        nodeGroup.addNode(hostName2);

        // hostnames are sorted (for no good reason other than testability due to stability, readability)
        assertEquals(Arrays.asList(hostName1, hostName2, hostName3), nodeGroup.getHostNames());
        assertEquals("host1,host2,host3", nodeGroup.toCommaSeparatedString());
    }
}