mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 17:01:51 +02:00
Add sharded DNS publishing capability
This enables sharded DNS publishing on a per-TLD basis. Instead of a TLD-wide lock, the sharded scheme locks each update on the shard number, allowing parallel writes to DNS. We allow N (the number of shards) to be 0 or 1 for no sharding, and N > 1 for an N-way sharding scheme. Unless explicitly set, all TLDs default to a numShards of 0, so we don't have to reload all registry objects explicitly. WARNING: This will change the lock name upon deployment for the PublishDnsAction from "<TLD> Dns Updates" to "<TLD> Dns Updates shard 0". This may cause concurrency issues if the underlying DNSWriter is not parallel-write tolerant (currently all production usages are ZonemanWriter, which is parallel-tolerant, so no issues are expected). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=187525655
This commit is contained in:
parent
24799b394d
commit
fa989e754b
16 changed files with 474 additions and 64 deletions
|
@ -20,6 +20,7 @@ java_library(
|
|||
"//java/google/registry/model",
|
||||
"//java/google/registry/module/backend",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/lock",
|
||||
"//java/google/registry/util",
|
||||
"//javatests/google/registry/testing",
|
||||
"//third_party/objectify:objectify-v4_1",
|
||||
|
|
|
@ -20,10 +20,12 @@ import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
|||
import static google.registry.testing.DatastoreHelper.persistActiveSubordinateHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -35,6 +37,7 @@ import google.registry.model.domain.DomainResource;
|
|||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.request.HttpException.ServiceUnavailableException;
|
||||
import google.registry.request.lock.LockHandler;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeLockHandler;
|
||||
|
@ -96,6 +99,8 @@ public class PublishDnsUpdatesActionTest {
|
|||
action.dnsWriterProxy = new DnsWriterProxy(ImmutableMap.of("correctWriter", dnsWriter));
|
||||
action.dnsMetrics = dnsMetrics;
|
||||
action.dnsQueue = dnsQueue;
|
||||
action.lockIndex = 1;
|
||||
action.numPublishLocks = 1;
|
||||
action.lockHandler = lockHandler;
|
||||
action.clock = clock;
|
||||
return action;
|
||||
|
@ -105,12 +110,12 @@ public class PublishDnsUpdatesActionTest {
|
|||
public void testHost_published() throws Exception {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.hosts = ImmutableSet.of("ns1.example.xn--q9jyb4c");
|
||||
|
||||
action.run();
|
||||
|
||||
verify(dnsWriter).publishHost("ns1.example.xn--q9jyb4c");
|
||||
verify(dnsWriter).commit();
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.ACCEPTED);
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.REJECTED);
|
||||
verify(dnsMetrics).incrementPublishHostRequests(1, PublishStatus.ACCEPTED);
|
||||
|
@ -124,7 +129,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
@ -132,12 +136,12 @@ public class PublishDnsUpdatesActionTest {
|
|||
public void testDomain_published() throws Exception {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.xn--q9jyb4c");
|
||||
|
||||
action.run();
|
||||
|
||||
verify(dnsWriter).publishDomain("example.xn--q9jyb4c");
|
||||
verify(dnsWriter).commit();
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(1, PublishStatus.ACCEPTED);
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.REJECTED);
|
||||
verify(dnsMetrics).incrementPublishHostRequests(0, PublishStatus.ACCEPTED);
|
||||
|
@ -151,10 +155,27 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAction_acquiresCorrectLock() throws Exception {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.lockIndex = 2;
|
||||
action.numPublishLocks = 4;
|
||||
action.domains = ImmutableSet.of("example.xn--q9jyb4c");
|
||||
LockHandler mockLockHandler = mock(LockHandler.class);
|
||||
when(mockLockHandler.executeWithLocks(any(), any(), any(), any())).thenReturn(true);
|
||||
action.lockHandler = mockLockHandler;
|
||||
|
||||
action.run();
|
||||
|
||||
verify(mockLockHandler)
|
||||
.executeWithLocks(
|
||||
action, "xn--q9jyb4c", Duration.standardSeconds(10), "DNS updates-lock 2 of 4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublish_commitFails() throws Exception {
|
||||
action = createAction("xn--q9jyb4c");
|
||||
|
@ -163,6 +184,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
ImmutableSet.of(
|
||||
"ns1.example.xn--q9jyb4c", "ns2.example.xn--q9jyb4c", "ns1.example2.xn--q9jyb4c");
|
||||
doThrow(new RuntimeException()).when(dnsWriter).commit();
|
||||
|
||||
assertThrows(RuntimeException.class, action::run);
|
||||
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(2, PublishStatus.ACCEPTED);
|
||||
|
@ -178,7 +200,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
@ -188,6 +209,7 @@ public class PublishDnsUpdatesActionTest {
|
|||
action.domains = ImmutableSet.of("example.xn--q9jyb4c", "example2.xn--q9jyb4c");
|
||||
action.hosts = ImmutableSet.of(
|
||||
"ns1.example.xn--q9jyb4c", "ns2.example.xn--q9jyb4c", "ns1.example2.xn--q9jyb4c");
|
||||
|
||||
action.run();
|
||||
|
||||
verify(dnsWriter).publishDomain("example.xn--q9jyb4c");
|
||||
|
@ -197,7 +219,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
verify(dnsWriter).publishHost("ns1.example2.xn--q9jyb4c");
|
||||
verify(dnsWriter).commit();
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(2, PublishStatus.ACCEPTED);
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.REJECTED);
|
||||
verify(dnsMetrics).incrementPublishHostRequests(3, PublishStatus.ACCEPTED);
|
||||
|
@ -211,7 +232,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
@ -220,11 +240,11 @@ public class PublishDnsUpdatesActionTest {
|
|||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
|
||||
action.run();
|
||||
|
||||
verify(dnsWriter).commit();
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(0, PublishStatus.ACCEPTED);
|
||||
verify(dnsMetrics).incrementPublishDomainRequests(2, PublishStatus.REJECTED);
|
||||
verify(dnsMetrics).incrementPublishHostRequests(0, PublishStatus.ACCEPTED);
|
||||
|
@ -238,7 +258,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
@ -248,12 +267,12 @@ public class PublishDnsUpdatesActionTest {
|
|||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
action.lockHandler = new FakeLockHandler(false);
|
||||
|
||||
ServiceUnavailableException thrown =
|
||||
assertThrows(ServiceUnavailableException.class, action::run);
|
||||
|
||||
assertThat(thrown).hasMessageThat().contains("Lock failure");
|
||||
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics)
|
||||
.recordActionResult(
|
||||
"correctWriter",
|
||||
|
@ -262,7 +281,56 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParam_invalidLockIndex() throws Exception {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com");
|
||||
action.lockIndex = 5;
|
||||
action.numPublishLocks = 4;
|
||||
|
||||
action.run();
|
||||
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
verify(dnsMetrics)
|
||||
.recordActionResult(
|
||||
"correctWriter",
|
||||
ActionStatus.BAD_LOCK_INDEX,
|
||||
2,
|
||||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
verify(dnsQueue).addDomainRefreshTask("example.com");
|
||||
verify(dnsQueue).addHostRefreshTask("ns1.example.com");
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegistryParam_mismatchedMaxLocks() throws Exception {
|
||||
persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build());
|
||||
action = createAction("xn--q9jyb4c");
|
||||
action.domains = ImmutableSet.of("example.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com");
|
||||
action.lockIndex = 3;
|
||||
action.numPublishLocks = 5;
|
||||
|
||||
action.run();
|
||||
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
verify(dnsMetrics)
|
||||
.recordActionResult(
|
||||
"correctWriter",
|
||||
ActionStatus.BAD_LOCK_INDEX,
|
||||
2,
|
||||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
verify(dnsQueue).addDomainRefreshTask("example.com");
|
||||
verify(dnsQueue).addHostRefreshTask("ns1.example.com");
|
||||
verifyNoMoreInteractions(dnsQueue);
|
||||
}
|
||||
|
||||
|
@ -272,10 +340,10 @@ public class PublishDnsUpdatesActionTest {
|
|||
action.domains = ImmutableSet.of("example.com", "example2.com");
|
||||
action.hosts = ImmutableSet.of("ns1.example.com", "ns2.example.com", "ns1.example2.com");
|
||||
action.dnsWriter = "wrongWriter";
|
||||
|
||||
action.run();
|
||||
|
||||
verifyNoMoreInteractions(dnsWriter);
|
||||
|
||||
verify(dnsMetrics)
|
||||
.recordActionResult(
|
||||
"wrongWriter",
|
||||
|
@ -284,7 +352,6 @@ public class PublishDnsUpdatesActionTest {
|
|||
Duration.standardHours(2),
|
||||
Duration.standardHours(1));
|
||||
verifyNoMoreInteractions(dnsMetrics);
|
||||
|
||||
verify(dnsQueue).addDomainRefreshTask("example.com");
|
||||
verify(dnsQueue).addDomainRefreshTask("example2.com");
|
||||
verify(dnsQueue).addHostRefreshTask("ns1.example.com");
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.google.common.base.Joiner;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.dns.DnsConstants.TargetType;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -91,7 +92,7 @@ public class ReadDnsQueueActionTest {
|
|||
// Because of b/73372999 - the FakeClock can't be in the past, or the TaskQueues stop working.
|
||||
// To make sure it's never in the past, we set the date far-far into the future
|
||||
clock.setTo(DateTime.parse("3000-01-01TZ"));
|
||||
createTlds("com", "net", "example");
|
||||
createTlds("com", "net", "example", "multilock.uk");
|
||||
persistResource(
|
||||
Registry.get("com").asBuilder().setDnsWriters(ImmutableSet.of("comWriter")).build());
|
||||
persistResource(
|
||||
|
@ -102,6 +103,12 @@ public class ReadDnsQueueActionTest {
|
|||
.setTldType(TldType.TEST)
|
||||
.setDnsWriters(ImmutableSet.of("exampleWriter"))
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("multilock.uk")
|
||||
.asBuilder()
|
||||
.setNumDnsPublishLocks(1000)
|
||||
.setDnsWriters(ImmutableSet.of("multilockWriter"))
|
||||
.build());
|
||||
dnsQueue = DnsQueue.createForTesting(clock);
|
||||
}
|
||||
|
||||
|
@ -112,10 +119,12 @@ public class ReadDnsQueueActionTest {
|
|||
action.clock = clock;
|
||||
action.dnsQueue = dnsQueue;
|
||||
action.dnsPublishPushQueue = QueueFactory.getQueue(DNS_PUBLISH_PUSH_QUEUE_NAME);
|
||||
action.hashFunction = Hashing.murmur3_32();
|
||||
action.taskEnqueuer = new TaskEnqueuer(new Retrier(null, 1));
|
||||
action.jitterSeconds = Optional.empty();
|
||||
// Advance the time a little, to ensure that leaseTasks() returns all tasks.
|
||||
clock.advanceBy(Duration.standardHours(1));
|
||||
|
||||
action.run();
|
||||
}
|
||||
|
||||
|
@ -149,6 +158,9 @@ public class ReadDnsQueueActionTest {
|
|||
.param("dnsWriter", tldToDnsWriter.getValue())
|
||||
.param("itemsCreated", "3000-01-01T00:00:00.000Z")
|
||||
.param("enqueued", "3000-01-01T01:00:00.000Z")
|
||||
// Single-lock TLDs should use lock 1 of 1 by default
|
||||
.param("lockIndex", "1")
|
||||
.param("numPublishLocks", "1")
|
||||
.header("content-type", "application/x-www-form-urlencoded")));
|
||||
}
|
||||
|
||||
|
@ -157,7 +169,9 @@ public class ReadDnsQueueActionTest {
|
|||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTasksEnqueued(
|
||||
DNS_PUBLISH_PUSH_QUEUE_NAME,
|
||||
|
@ -167,11 +181,13 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_allTlds() throws Exception {
|
||||
public void testSuccess_allSingleLockTlds() throws Exception {
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
ImmutableMultimap.of("com", "comWriter", "net", "netWriter", "example", "exampleWriter"));
|
||||
|
@ -186,7 +202,9 @@ public class ReadDnsQueueActionTest {
|
|||
.mapToObj(i -> String.format("domain_%04d.com", i))
|
||||
.collect(toImmutableList());
|
||||
domains.forEach(dnsQueue::addDomainRefreshTask);
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
ImmutableList<ImmutableMultimap<String, String>> queuedParams =
|
||||
getQueuedParams(DNS_PUBLISH_PUSH_QUEUE_NAME);
|
||||
|
@ -209,7 +227,9 @@ public class ReadDnsQueueActionTest {
|
|||
.setDnsWriters(ImmutableSet.of("comWriter", "otherWriter"))
|
||||
.build());
|
||||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(ImmutableMultimap.of("com", "comWriter", "com", "otherWriter"));
|
||||
}
|
||||
|
@ -222,7 +242,9 @@ public class ReadDnsQueueActionTest {
|
|||
dnsQueue.addDomainRefreshTask("domain2.com");
|
||||
clock.setTo(DateTime.parse("3000-02-05TZ"));
|
||||
dnsQueue.addDomainRefreshTask("domain3.com");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertThat(getQueuedParams(DNS_PUBLISH_PUSH_QUEUE_NAME))
|
||||
.containsExactly(
|
||||
|
@ -234,6 +256,8 @@ public class ReadDnsQueueActionTest {
|
|||
.put("domains", "domain1.com")
|
||||
.put("domains", "domain2.com")
|
||||
.put("domains", "domain3.com")
|
||||
.put("lockIndex", "1")
|
||||
.put("numPublishLocks", "1")
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -243,7 +267,9 @@ public class ReadDnsQueueActionTest {
|
|||
dnsQueue.addDomainRefreshTask("domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addDomainRefreshTask("domain.example");
|
||||
|
||||
run();
|
||||
|
||||
assertTasksEnqueued(DNS_PULL_QUEUE_NAME, createDomainRefreshTaskMatcher("domain.net"));
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter"));
|
||||
|
@ -260,7 +286,9 @@ public class ReadDnsQueueActionTest {
|
|||
.param(DNS_TARGET_TYPE_PARAM, TargetType.DOMAIN.toString())
|
||||
.param(DNS_TARGET_NAME_PARAM, "domain.unknown")
|
||||
.param(PARAM_TLD, "unknown"));
|
||||
|
||||
run();
|
||||
|
||||
assertTasksEnqueued(DNS_PULL_QUEUE_NAME, createDomainRefreshTaskMatcher("domain.unknown"));
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter"));
|
||||
|
@ -279,7 +307,9 @@ public class ReadDnsQueueActionTest {
|
|||
.param(DNS_TARGET_NAME_PARAM, "domain.wrongtld")
|
||||
.param(DNS_TARGET_CREATE_TIME_PARAM, "3000-01-01TZ")
|
||||
.param(PARAM_TLD, "net"));
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
ImmutableMultimap.of("com", "comWriter", "example", "exampleWriter", "net", "netWriter"));
|
||||
|
@ -295,7 +325,9 @@ public class ReadDnsQueueActionTest {
|
|||
.method(Method.PULL)
|
||||
.param(DNS_TARGET_TYPE_PARAM, TargetType.DOMAIN.toString())
|
||||
.param(DNS_TARGET_NAME_PARAM, "domain.net"));
|
||||
|
||||
run();
|
||||
|
||||
// The corrupt task isn't in the pull queue, but also isn't in the push queue
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
|
@ -312,7 +344,9 @@ public class ReadDnsQueueActionTest {
|
|||
.method(Method.PULL)
|
||||
.param(DNS_TARGET_TYPE_PARAM, TargetType.DOMAIN.toString())
|
||||
.param(PARAM_TLD, "net"));
|
||||
|
||||
run();
|
||||
|
||||
// The corrupt task isn't in the pull queue, but also isn't in the push queue
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
|
@ -329,7 +363,9 @@ public class ReadDnsQueueActionTest {
|
|||
.method(Method.PULL)
|
||||
.param(DNS_TARGET_NAME_PARAM, "domain.net")
|
||||
.param(PARAM_TLD, "net"));
|
||||
|
||||
run();
|
||||
|
||||
// The corrupt task isn't in the pull queue, but also isn't in the push queue
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
|
@ -347,7 +383,9 @@ public class ReadDnsQueueActionTest {
|
|||
.param(DNS_TARGET_TYPE_PARAM, "Wrong type")
|
||||
.param(DNS_TARGET_NAME_PARAM, "domain.net")
|
||||
.param(PARAM_TLD, "net"));
|
||||
|
||||
run();
|
||||
|
||||
// The corrupt task isn't in the pull queue, but also isn't in the push queue
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTldsEnqueuedInPushQueue(
|
||||
|
@ -359,7 +397,9 @@ public class ReadDnsQueueActionTest {
|
|||
dnsQueue.addHostRefreshTask("ns1.domain.com");
|
||||
dnsQueue.addDomainRefreshTask("domain.net");
|
||||
dnsQueue.addZoneRefreshTask("example");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTasksEnqueued(
|
||||
DNS_PUBLISH_PUSH_QUEUE_NAME,
|
||||
|
@ -408,8 +448,47 @@ public class ReadDnsQueueActionTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
assertTasksEnqueued(DNS_PUBLISH_PUSH_QUEUE_NAME, expectedTasks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_lockGroupsHostBySuperordinateDomain() throws Exception {
|
||||
dnsQueue.addDomainRefreshTask("hello.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns1.abc.hello.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns2.hello.multilock.uk");
|
||||
dnsQueue.addDomainRefreshTask("another.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns3.def.another.multilock.uk");
|
||||
dnsQueue.addHostRefreshTask("ns4.another.multilock.uk");
|
||||
|
||||
run();
|
||||
|
||||
assertNoTasksEnqueued(DNS_PULL_QUEUE_NAME);
|
||||
// Expect two different groups; in-balliwick hosts are locked with their superordinate domains.
|
||||
assertTasksEnqueued(
|
||||
DNS_PUBLISH_PUSH_QUEUE_NAME,
|
||||
new TaskMatcher()
|
||||
.url(PublishDnsUpdatesAction.PATH)
|
||||
.param("tld", "multilock.uk")
|
||||
.param("dnsWriter", "multilockWriter")
|
||||
.param("itemsCreated", "3000-01-01T00:00:00.000Z")
|
||||
.param("enqueued", "3000-01-01T01:00:00.000Z")
|
||||
.param("domains", "hello.multilock.uk")
|
||||
.param("hosts", "ns1.abc.hello.multilock.uk")
|
||||
.param("hosts", "ns2.hello.multilock.uk")
|
||||
.header("content-type", "application/x-www-form-urlencoded"),
|
||||
new TaskMatcher()
|
||||
.url(PublishDnsUpdatesAction.PATH)
|
||||
.param("tld", "multilock.uk")
|
||||
.param("dnsWriter", "multilockWriter")
|
||||
.param("itemsCreated", "3000-01-01T00:00:00.000Z")
|
||||
.param("enqueued", "3000-01-01T01:00:00.000Z")
|
||||
.param("domains", "another.multilock.uk")
|
||||
.param("hosts", "ns3.def.another.multilock.uk")
|
||||
.param("hosts", "ns4.another.multilock.uk")
|
||||
.header("content-type", "application/x-www-form-urlencoded"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,19 @@ public class RegistryTest extends EntityTestCase {
|
|||
assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.of(USD, 42));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultNumDnsPublishShards_equalToOne() {
|
||||
Registry registry = Registry.get("tld").asBuilder().build();
|
||||
assertThat(registry.getNumDnsPublishLocks()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingNumDnsPublishShards() {
|
||||
Registry registry =
|
||||
Registry.get("tld").asBuilder().setNumDnsPublishLocks(2).build();
|
||||
assertThat(registry.getNumDnsPublishLocks()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetReservedList_doesntMutateExistingRegistry() {
|
||||
ReservedList rl15 = persistReservedList(
|
||||
|
@ -458,6 +471,26 @@ public class RegistryTest extends EntityTestCase {
|
|||
assertThat(thrown).hasMessageThat().contains("restoreBillingCost cannot be negative");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_nonPositiveNumDnsPublishLocks() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> Registry.get("tld").asBuilder().setNumDnsPublishLocks(-1));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"numDnsPublishLocks must be positive when set explicitly (use 1 for TLD-wide locks)");
|
||||
thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> Registry.get("tld").asBuilder().setNumDnsPublishLocks(0));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"numDnsPublishLocks must be positive when set explicitly (use 1 for TLD-wide locks)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeServerStatusChangeBillingCost() {
|
||||
IllegalArgumentException thrown =
|
||||
|
|
|
@ -681,6 +681,7 @@ class google.registry.model.registry.Registry {
|
|||
google.registry.model.common.TimedTransitionProperty<org.joda.money.Money, google.registry.model.registry.Registry$BillingCostTransition> eapFeeSchedule;
|
||||
google.registry.model.common.TimedTransitionProperty<org.joda.money.Money, google.registry.model.registry.Registry$BillingCostTransition> renewBillingCostTransitions;
|
||||
google.registry.model.registry.Registry$TldType tldType;
|
||||
int numDnsPublishLocks;
|
||||
java.lang.String driveFolderId;
|
||||
java.lang.String lordnUsername;
|
||||
java.lang.String pricingEngineClassName;
|
||||
|
|
|
@ -540,7 +540,8 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
System.setErr(new PrintStream(errContent));
|
||||
runReservedListsTestOverride("common_abuse,tld_banned");
|
||||
String errMsg =
|
||||
"Error overriden: The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c";
|
||||
"Error overridden: The reserved list(s) tld_banned "
|
||||
+ "cannot be applied to the tld xn--q9jyb4c";
|
||||
assertThat(errContent.toString()).contains(errMsg);
|
||||
System.setOut(null);
|
||||
}
|
||||
|
|
|
@ -964,7 +964,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
System.setErr(new PrintStream(errContent));
|
||||
runReservedListsTestOverride("common_abuse,tld_banned");
|
||||
String errMsg =
|
||||
"Error overriden: The reserved list(s) tld_banned cannot be applied to the tld xn--q9jyb4c";
|
||||
"Error overridden: The reserved list(s) tld_banned "
|
||||
+ "cannot be applied to the tld xn--q9jyb4c";
|
||||
assertThat(errContent.toString()).contains(errMsg);
|
||||
System.setOut(null);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.util;
|
|||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
|
||||
import static google.registry.util.DomainNameUtils.getSecondLevelDomain;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -26,7 +27,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class DomainNameUtilsTest {
|
||||
@Test
|
||||
public void testCanonicalizeDomainName() throws Exception {
|
||||
public void testCanonicalizeDomainName() {
|
||||
assertThat(canonicalizeDomainName("foo")).isEqualTo("foo");
|
||||
assertThat(canonicalizeDomainName("FOO")).isEqualTo("foo");
|
||||
assertThat(canonicalizeDomainName("foo.tld")).isEqualTo("foo.tld");
|
||||
|
@ -40,7 +41,33 @@ public class DomainNameUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCanonicalizeDomainName_acePrefixUnicodeChars() throws Exception {
|
||||
public void testCanonicalizeDomainName_acePrefixUnicodeChars() {
|
||||
assertThrows(IllegalArgumentException.class, () -> canonicalizeDomainName("xn--みんな"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecondLevelDomain_returnsProperDomain() {
|
||||
assertThat(getSecondLevelDomain("foo.bar", "bar")).isEqualTo("foo.bar");
|
||||
assertThat(getSecondLevelDomain("ns1.foo.bar", "bar")).isEqualTo("foo.bar");
|
||||
assertThat(getSecondLevelDomain("ns1.abc.foo.bar", "bar")).isEqualTo("foo.bar");
|
||||
assertThat(getSecondLevelDomain("ns1.abc.foo.bar", "foo.bar")).isEqualTo("abc.foo.bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecondLevelDomain_insufficientDomainNameDepth() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> getSecondLevelDomain("bar", "bar"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("hostName must be at least one level below the tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecondLevelDomain_domainNotUnderTld() {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> getSecondLevelDomain("foo.bar", "abc"));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("hostName must be under the tld");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue