blob: 8b2bfe8ee952f1727c838f700c89a239fb054558 (
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
53
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.ControllerTester;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.LoadBalancer;
import com.yahoo.vespa.hosted.controller.api.integration.dns.Record;
import com.yahoo.vespa.hosted.controller.application.SystemApplication;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
import org.junit.Test;
import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
/**
* @author mpolden
*/
public class SystemRoutingPolicyMaintainerTest {
@Test
public void maintain() {
var tester = new ControllerTester();
var updater = new SystemRoutingPolicyMaintainer(tester.controller(), Duration.ofDays(1));
var dispatcher = new NameServiceDispatcher(tester.controller(), Duration.ofSeconds(Integer.MAX_VALUE));
var zone = ZoneId.from("prod", "us-west-1");
tester.zoneRegistry().exclusiveRoutingIn(ZoneApiMock.from(zone));
tester.configServer().putLoadBalancers(zone, List.of(new LoadBalancer("lb1",
SystemApplication.configServer.id(),
ClusterSpec.Id.from("config"),
Optional.of(HostName.of("lb1.example.com")),
LoadBalancer.State.active,
Optional.of("dns-zone-1"))));
// Record is created
updater.run();
dispatcher.run();
Set<Record> records = tester.nameService().records();
assertEquals(1, records.size());
Record record = records.iterator().next();
assertSame(Record.Type.CNAME, record.type());
assertEquals("cfg.prod.us-west-1.test.vip", record.name().asString());
assertEquals("lb1.example.com.", record.data().asString());
}
}
|