Allow multiple DNS writers on TLDs

This completes the data/functionality migration for multiple DNS writers.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163835077
This commit is contained in:
mcilwain 2017-08-01 09:00:57 -07:00 committed by Ben McIlwain
parent 05d22a2556
commit 2a29ada032
8 changed files with 38 additions and 37 deletions

View file

@ -23,7 +23,6 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.dns.DnsMetrics.Status;
@ -80,7 +79,7 @@ public class PublishDnsUpdatesActionTest {
action.tld = tld;
action.hosts = ImmutableSet.<String>of();
action.domains = ImmutableSet.<String>of();
action.dnsWriter = Optional.<String>absent();
action.dnsWriter = "mock";
action.dnsWriterProxy = new DnsWriterProxy(ImmutableMap.of("mock", dnsWriter));
action.dnsMetrics = dnsMetrics;
return action;
@ -104,7 +103,6 @@ public class PublishDnsUpdatesActionTest {
public void testDomain_published() throws Exception {
action = createAction("xn--q9jyb4c");
action.domains = ImmutableSet.of("example.xn--q9jyb4c");
action.dnsWriter = Optional.of("mock");
action.run();
verify(dnsWriter).publishDomain("example.xn--q9jyb4c");

View file

@ -33,7 +33,7 @@ import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InternetDomainName;
import google.registry.dns.DnsConstants.TargetType;
@ -123,12 +123,12 @@ public class ReadDnsQueueActionTest {
return options.param("tld", tld);
}
private void assertTldsEnqueuedInPushQueue(ImmutableMap<String, String> tldsToDnsWriters)
private void assertTldsEnqueuedInPushQueue(ImmutableMultimap<String, String> tldsToDnsWriters)
throws Exception {
assertTasksEnqueued(
DNS_PUBLISH_PUSH_QUEUE_NAME,
transform(
tldsToDnsWriters.entrySet().asList(),
tldsToDnsWriters.entries().asList(),
new Function<Entry<String, String>, TaskMatcher>() {
@Override
public TaskMatcher apply(Entry<String, String> tldToDnsWriter) {
@ -163,7 +163,20 @@ public class ReadDnsQueueActionTest {
run(false);
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
assertTldsEnqueuedInPushQueue(
ImmutableMap.of("com", "comWriter", "net", "netWriter", "example", "exampleWriter"));
ImmutableMultimap.of("com", "comWriter", "net", "netWriter", "example", "exampleWriter"));
}
@Test
public void testSuccess_twoDnsWriters() throws Exception {
persistResource(
Registry.get("com")
.asBuilder()
.setDnsWriters(ImmutableSet.of("comWriter", "otherWriter"))
.build());
dnsQueue.addDomainRefreshTask("domain.com");
run(false);
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
assertTldsEnqueuedInPushQueue(ImmutableMultimap.of("com", "comWriter", "com", "otherWriter"));
}
@Test
@ -175,7 +188,7 @@ public class ReadDnsQueueActionTest {
TaskQueueHelper.getQueueInfo(DNS_PULL_QUEUE_NAME).getTaskInfo();
run(true);
assertTldsEnqueuedInPushQueue(
ImmutableMap.of("com", "comWriter", "net", "netWriter", "example", "exampleWriter"));
ImmutableMultimap.of("com", "comWriter", "net", "netWriter", "example", "exampleWriter"));
// Check that keepTasks was honored and the pull queue tasks are still present in the queue.
assertTasksEnqueued(DNS_PULL_QUEUE_NAME, preexistingTasks);
}
@ -189,7 +202,7 @@ public class ReadDnsQueueActionTest {
run(false);
assertTasksEnqueued(DNS_PULL_QUEUE_NAME, new TaskMatcher());
assertTldsEnqueuedInPushQueue(
ImmutableMap.of("com", "comWriter", "example", "exampleWriter"));
ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter"));
}
@Test
@ -250,6 +263,4 @@ public class ReadDnsQueueActionTest {
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
assertTasksEnqueued(DNS_PUBLISH_PUSH_QUEUE_NAME, expectedTasks);
}
// TODO(b/63385597): Add a test that DNS tasks are processed for multiple DNS writers once allowed
}

View file

@ -32,6 +32,7 @@ import static org.joda.money.CurrencyUnit.USD;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.dns.writer.VoidDnsWriter;
import google.registry.model.EntityTestCase;
import google.registry.model.registry.Registry.RegistryNotFoundException;
import google.registry.model.registry.Registry.TldState;
@ -229,6 +230,14 @@ public class RegistryTest extends EntityTestCase {
assertThat(registry.getLordnUsername()).isEqualTo("username");
}
@Test
public void testSettingDnsWriters() {
Registry registry = Registry.get("tld");
assertThat(registry.getDnsWriters()).containsExactly(VoidDnsWriter.NAME);
registry = registry.asBuilder().setDnsWriters(ImmutableSet.of("baz", "bang")).build();
assertThat(registry.getDnsWriters()).containsExactly("baz", "bang");
}
@Test
public void testPdtLooksLikeGa() {
Registry registry = Registry.get("tld").asBuilder()

View file

@ -183,9 +183,12 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
}
@Test
public void testFailure_multipleDnsWritersNotYetSupported() throws Exception {
thrown.expect(IllegalArgumentException.class, "Multiple DNS writers are not yet supported");
public void testSuccess_multipleDnsWriters() throws Exception {
assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter");
runCommandForced("--dns_writers=FooDnsWriter,VoidDnsWriter", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getDnsWriters())
.containsExactly("FooDnsWriter", "VoidDnsWriter");
}
@Test