Make all but one field on RegistryConfig static

The next step will be to get rid of RegistryConfig descendants and RegistryConfigLoader entirely.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143812815
This commit is contained in:
mcilwain 2017-01-06 14:06:01 -08:00 committed by Ben McIlwain
parent 7fba7c1e4f
commit c5c74961bb
23 changed files with 224 additions and 324 deletions

View file

@ -20,18 +20,17 @@ import static google.registry.mapreduce.inputs.EppResourceInputs.createEntityInp
import static google.registry.mapreduce.inputs.EppResourceInputs.createKeyInput;
import static google.registry.model.index.EppResourceIndexBucket.getBucketKey;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newContactResource;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistEppResourceInFirstBucket;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistSimpleResource;
import com.google.appengine.tools.mapreduce.InputReader;
import com.googlecode.objectify.Key;
import google.registry.config.TestRegistryConfig;
import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainApplication;
@ -41,7 +40,6 @@ import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex;
import google.registry.testing.AppEngineRule;
import google.registry.testing.ExceptionRule;
import google.registry.testing.RegistryConfigRule;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@ -66,18 +64,6 @@ public class EppResourceInputsTest {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Rule
public final RegistryConfigRule configRule = new RegistryConfigRule();
private void overrideBucketCount(final int count) {
configRule.override(new TestRegistryConfig() {
@Override
public int getEppResourceIndexBucketCount() {
return count;
}
});
}
@SuppressWarnings("unchecked")
private <T> T serializeAndDeserialize(T obj) throws Exception {
try (ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
@ -128,14 +114,12 @@ public class EppResourceInputsTest {
@Test
public void testReaderCountMatchesBucketCount() throws Exception {
overrideBucketCount(123);
assertThat(createKeyInput(DomainBase.class).createReaders()).hasSize(123);
assertThat(createEntityInput(DomainBase.class).createReaders()).hasSize(123);
assertThat(createKeyInput(DomainBase.class).createReaders()).hasSize(3);
assertThat(createEntityInput(DomainBase.class).createReaders()).hasSize(3);
}
@Test
public void testKeyInput_oneReaderPerBucket() throws Exception {
overrideBucketCount(3);
createTld("tld");
Set<Key<DomainResource>> domains = new HashSet<>();
for (int i = 1; i <= 3; i++) {
@ -159,7 +143,6 @@ public class EppResourceInputsTest {
@Test
public void testEntityInput_oneReaderPerBucket() throws Exception {
overrideBucketCount(3);
createTld("tld");
Set<DomainResource> domains = new HashSet<>();
for (int i = 1; i <= 3; i++) {
@ -186,9 +169,8 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_keyReader_survivesAcrossSerialization() throws Exception {
createTld("tld");
overrideBucketCount(1);
DomainResource domainA = persistActiveDomain("a.tld");
DomainResource domainB = persistActiveDomain("b.tld");
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld"));
// Should be ignored. We'll know if it isn't because the progress counts will be off.
persistActiveContact("contact");
Set<Key<DomainBase>> seen = new HashSet<>();
@ -212,9 +194,8 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_entityReader_survivesAcrossSerialization() throws Exception {
createTld("tld");
overrideBucketCount(1);
DomainResource domainA = persistActiveDomain("a.tld");
DomainResource domainB = persistActiveDomain("b.tld");
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
DomainResource domainB = persistEppResourceInFirstBucket(newDomainResource("b.tld"));
// Should be ignored. We'll know if it isn't because the progress counts will be off.
persistActiveContact("contact");
Set<DomainResource> seen = new HashSet<>();
@ -241,12 +222,10 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_entityReader_allowsPolymorphicMatches() throws Exception {
createTld("tld");
overrideBucketCount(1);
DomainResource domain = persistActiveDomain("a.tld");
DomainApplication application = persistActiveDomainApplication("b.tld");
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
DomainApplication application = persistEppResourceInFirstBucket(newDomainApplication("b.tld"));
Set<DomainBase> seen = new HashSet<>();
InputReader<DomainBase> reader =
createEntityInput(DomainBase.class).createReaders().get(0);
InputReader<DomainBase> reader = createEntityInput(DomainBase.class).createReaders().get(0);
reader.beginShard();
reader.beginSlice();
assertThat(reader.getProgress()).isWithin(EPSILON).of(0);
@ -262,9 +241,8 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_entityReader_skipsPolymorphicMismatches() throws Exception {
createTld("tld");
overrideBucketCount(1);
persistActiveDomainApplication("b.tld");
DomainResource domainA = persistActiveDomain("a.tld");
persistEppResourceInFirstBucket(newDomainApplication("b.tld"));
DomainResource domainA = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
InputReader<DomainResource> reader =
createEntityInput(DomainResource.class).createReaders().get(0);
reader.beginShard();
@ -281,10 +259,9 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_entityReader_filtersOnMultipleTypes() throws Exception {
createTld("tld");
overrideBucketCount(1);
DomainResource domain = persistActiveDomain("a.tld");
HostResource host = persistActiveHost("ns1.example.com");
persistActiveContact("contact");
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld"));
HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com"));
persistEppResourceInFirstBucket(newContactResource("contact"));
Set<EppResource> seen = new HashSet<>();
InputReader<EppResource> reader =
EppResourceInputs.<EppResource>createEntityInput(
@ -304,12 +281,12 @@ public class EppResourceInputsTest {
@Test
public void testSuccess_entityReader_noFilteringWhenUsingEppResource() throws Exception {
createTld("tld");
overrideBucketCount(1);
ContactResource contact = persistActiveContact("contact");
ContactResource contact = persistEppResourceInFirstBucket(newContactResource("contact"));
// Specify the contact since persistActiveDomain{Application} creates a hidden one.
DomainResource domain = persistResource(newDomainResource("a.tld", contact));
DomainApplication application = persistResource(newDomainApplication("b.tld", contact));
HostResource host = persistActiveHost("ns1.example.com");
DomainResource domain = persistEppResourceInFirstBucket(newDomainResource("a.tld", contact));
DomainApplication application =
persistEppResourceInFirstBucket(newDomainApplication("b.tld", contact));
HostResource host = persistEppResourceInFirstBucket(newHostResource("ns1.example.com"));
Set<EppResource> seen = new HashSet<>();
InputReader<EppResource> reader = createEntityInput(EppResource.class).createReaders().get(0);
reader.beginShard();