Require that DNS writer be set on Registry entities

We ran into a bunch of prober deployment issues this past week when
attempting to spin up a new cluster because the newly created prober
TLDs had null values for the dnsWriter field. Given that VoidDnsWriter
exists, we can require that dnsWriter always be set, and have people
use that if DNS publishing is not required.

Also cleans up a bunch of related inconsistent exception messages and
tests not verifying said exception messages properly.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154325830
This commit is contained in:
mcilwain 2017-04-26 11:58:09 -07:00 committed by Ben McIlwain
parent d7da112c19
commit d30f9411d8
11 changed files with 332 additions and 115 deletions

View file

@ -260,7 +260,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
assertAllowedEnvironment();
initTldCommand();
String duplicates = Joiner.on(", ").join(findDuplicates(mainParameters));
checkArgument(duplicates.isEmpty(), "Duplicate arguments found: \"%s\"", duplicates);
checkArgument(duplicates.isEmpty(), "Duplicate arguments found: '%s'", duplicates);
Set<String> tlds = ImmutableSet.copyOf(mainParameters);
checkArgument(roidSuffix == null || tlds.size() == 1,
"Can't update roid suffixes on multiple TLDs simultaneously");
@ -268,7 +268,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
checkArgument(tld.equals(canonicalizeDomainName(tld)));
checkArgument(
!CharMatcher.javaDigit().matches(tld.charAt(0)),
"TLDs cannot begin with a number.");
"TLDs cannot begin with a number");
Registry oldRegistry = getOldRegistry(tld);
// TODO(b/26901539): Add a flag to set the pricing engine once we have more than one option.
Registry.Builder builder =
@ -388,14 +388,12 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand {
}
}
if (dnsWriter != null) {
if (dnsWriter.isPresent()) {
if (dnsWriter != null && dnsWriter.isPresent()) {
checkArgument(
dnsWriterNames.contains(dnsWriter.get()),
"The DNS writer '%s' doesn't exist",
dnsWriter.get());
builder.setDnsWriter(dnsWriter.get());
}
}
if (lrpPeriod != null) {