summaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/LoadBalancerAliasTest.java
blob: 965a639a68c1c4235db144e5f4f505123dd3b0a5 (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 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.application;

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId;
import org.junit.Test;

import static com.yahoo.vespa.hosted.controller.application.LoadBalancerAlias.createAlias;
import static org.junit.Assert.*;

/**
 * @author mpolden
 */
public class LoadBalancerAliasTest {

    @Test
    public void test_endpoint_names() {
        ZoneId zoneId = ZoneId.from("prod", "us-north-1");
        ApplicationId withInstanceName = ApplicationId.from("tenant", "application", "instance");
        testAlias("instance--application--tenant--prod.us-north-1--vespa.oath.cloud", "default", withInstanceName, zoneId);
        testAlias("cluster--instance--application--tenant--prod.us-north-1--vespa.oath.cloud", "cluster", withInstanceName, zoneId);

        ApplicationId withDefaultInstance = ApplicationId.from("tenant", "application", "default");
        testAlias("application--tenant--prod.us-north-1--vespa.oath.cloud", "default", withDefaultInstance, zoneId);
        testAlias("cluster--application--tenant--prod.us-north-1--vespa.oath.cloud", "cluster", withDefaultInstance, zoneId);
    }

    private void testAlias(String expected, String clusterName, ApplicationId applicationId, ZoneId zoneId) {
        assertEquals(expected, createAlias(ClusterSpec.Id.from(clusterName), applicationId, zoneId));
    }

}