diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-06-15 13:38:35 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-06-15 13:58:59 +0200 |
commit | 9aba0cad6c00627e6572eb7f6c19c9c67304db75 (patch) | |
tree | 2da2fa051c4b1c4c074fe84ba7ab86750c6c4a11 /controller-server/src/test/java/com | |
parent | f34efe30c2a17ba6fc9b4b80fabd1c612d958bee (diff) |
Maintain routing policies for system applications
Diffstat (limited to 'controller-server/src/test/java/com')
2 files changed, 64 insertions, 0 deletions
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemRoutingPolicyMaintainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemRoutingPolicyMaintainerTest.java new file mode 100644 index 00000000000..8d6316d447f --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/SystemRoutingPolicyMaintainerTest.java @@ -0,0 +1,61 @@ +// Copyright Verizon Media. 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.flags.Flags; +import com.yahoo.vespa.flags.InMemoryFlagSource; +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.ofDays(1), 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"), + HostName.from("lb1.example.com"), + LoadBalancer.State.active, + Optional.of("dns-zone-1")))); + + // Nothing happens without feature flag + updater.run(); + dispatcher.run(); + assertEquals(Set.of(), tester.nameService().records()); + + // Record is created + ((InMemoryFlagSource) tester.controller().flagSource()).withBooleanFlag(Flags.CONFIGSERVER_PROVISION_LB.id(), true); + 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()); + } + +} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json index ecb5c319f44..acd542b001c 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json @@ -52,6 +52,9 @@ "name": "RotationStatusUpdater" }, { + "name": "SystemRoutingPolicyMaintainer" + }, + { "name": "SystemUpgrader" }, { |