mirror of
https://github.com/google/nomulus.git
synced 2025-05-17 01:47:14 +02:00
Change commit log bucket counts in tests
I'm setting it to three buckets across all tests, because the default one bucket wasn't realistic enough, and allowed some tests to pass that shouldn't have, essentially by accident. This also changes RegistryConfig from being an interface to being an abstract base class. The medium term goal here is to have it be a static class so that it can provide fields from the YAML-derived POJO in situations where Dagger injection isn't feasible. The expected end state is as follows: default-config.yaml -- The master config file that provides defaults for all values. nomulus-config.yaml -- A per-environment config file that overrides the defaults from the previous file. YamlConfig.java -- The POJO that the aforementioned YAML files are deserialized into. RegistryConfig.java -- Contains a static, memoized instance of YamlConfig and provides static methods for getting some of those values. ConfigModule -- Will become a static inner class of RegistryConfig, using Dagger to provide most of the fields from the memoized YamlConfig instance. This way, all configuration will be coming from a single place: RegistryConfig.java. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143567288
This commit is contained in:
parent
734130aa73
commit
c35c3a678b
18 changed files with 119 additions and 206 deletions
|
@ -53,7 +53,7 @@ public class ContactResourceTest extends EntityTestCase {
|
|||
public void setUp() throws Exception {
|
||||
createTld("foobar");
|
||||
// Set up a new persisted ContactResource entity.
|
||||
contactResource = cloneAndSetAutoTimestamps(
|
||||
contactResource = persistResource(cloneAndSetAutoTimestamps(
|
||||
new ContactResource.Builder()
|
||||
.setContactId("contact_id")
|
||||
.setRepoId("1-FOOBAR")
|
||||
|
@ -113,8 +113,7 @@ public class ContactResourceTest extends EntityTestCase {
|
|||
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
||||
.setTransferRequestTrid(Trid.create("client trid"))
|
||||
.build())
|
||||
.build());
|
||||
persistResource(contactResource);
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
public void setUp() throws Exception {
|
||||
createTld("com");
|
||||
// Set up a new persisted domain application entity.
|
||||
domainApplication = cloneAndSetAutoTimestamps(
|
||||
domainApplication = persistResource(cloneAndSetAutoTimestamps(
|
||||
new DomainApplication.Builder()
|
||||
.setFullyQualifiedDomainName("example.com")
|
||||
.setRepoId("1-COM")
|
||||
|
@ -96,8 +96,7 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
.setEncodedSignedMarks(ImmutableList.of(EncodedSignedMark.create("base64", "abcdefg=")))
|
||||
.setApplicationStatus(ApplicationStatus.ALLOCATED)
|
||||
.setAuctionPrice(Money.of(USD, 11))
|
||||
.build());
|
||||
persistResource(domainApplication);
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -107,7 +107,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
Key<PollMessage.OneTime> onetimePollKey =
|
||||
Key.create(historyEntryKey, PollMessage.OneTime.class, 1);
|
||||
// Set up a new persisted domain entity.
|
||||
domain = cloneAndSetAutoTimestamps(
|
||||
domain = persistResource(cloneAndSetAutoTimestamps(
|
||||
new DomainResource.Builder()
|
||||
.setFullyQualifiedDomainName("example.com")
|
||||
.setRepoId("4-COM")
|
||||
|
@ -158,8 +158,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
.setApplication(Key.create(DomainApplication.class, 1))
|
||||
.addGracePeriod(GracePeriod.create(
|
||||
GracePeriodStatus.ADD, clock.nowUtc().plusDays(1), "registrar", null))
|
||||
.build());
|
||||
persistResource(domain);
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -72,21 +72,21 @@ public class HostResourceTest extends EntityTestCase {
|
|||
.build())
|
||||
.build());
|
||||
hostResource =
|
||||
cloneAndSetAutoTimestamps(
|
||||
new HostResource.Builder()
|
||||
.setRepoId("DEADBEEF-COM")
|
||||
.setFullyQualifiedHostName("ns1.example.com")
|
||||
.setCreationClientId("a registrar")
|
||||
.setLastEppUpdateTime(clock.nowUtc())
|
||||
.setLastEppUpdateClientId("another registrar")
|
||||
.setLastTransferTime(clock.nowUtc())
|
||||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.OK))
|
||||
.setSuperordinateDomain(
|
||||
Key.create(
|
||||
loadByForeignKey(DomainResource.class, "example.com", clock.nowUtc())))
|
||||
.build());
|
||||
persistResource(hostResource);
|
||||
persistResource(
|
||||
cloneAndSetAutoTimestamps(
|
||||
new HostResource.Builder()
|
||||
.setRepoId("DEADBEEF-COM")
|
||||
.setFullyQualifiedHostName("ns1.example.com")
|
||||
.setCreationClientId("a registrar")
|
||||
.setLastEppUpdateTime(clock.nowUtc())
|
||||
.setLastEppUpdateClientId("another registrar")
|
||||
.setLastTransferTime(clock.nowUtc())
|
||||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.OK))
|
||||
.setSuperordinateDomain(
|
||||
Key.create(
|
||||
loadByForeignKey(DomainResource.class, "example.com", clock.nowUtc())))
|
||||
.build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -24,11 +24,9 @@ import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
|||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.annotation.Cache;
|
||||
import google.registry.config.TestRegistryConfig;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.InjectRule;
|
||||
import google.registry.testing.RegistryConfigRule;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
@ -44,9 +42,6 @@ public class CommitLogBucketTest {
|
|||
.withDatastore()
|
||||
.build();
|
||||
|
||||
@Rule
|
||||
public final RegistryConfigRule configRule = new RegistryConfigRule();
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
|
||||
|
@ -57,12 +52,6 @@ public class CommitLogBucketTest {
|
|||
|
||||
@Before
|
||||
public void before() {
|
||||
// Use 10 buckets to make the tests below more realistic.
|
||||
configRule.override(new TestRegistryConfig() {
|
||||
@Override
|
||||
public int getCommitLogBucketCount() {
|
||||
return 10;
|
||||
}});
|
||||
// Save the bucket with some non-default properties set so that we can distinguish a correct
|
||||
// load from one that returns a newly created bucket instance.
|
||||
bucket = persistResource(
|
||||
|
@ -108,19 +97,17 @@ public class CommitLogBucketTest {
|
|||
|
||||
@Test
|
||||
public void test_loadBucket_forNonexistentBucket_returnsNewBucket() {
|
||||
assertThat(loadBucket(getBucketKey(10))).isEqualTo(
|
||||
new CommitLogBucket.Builder().setBucketNum(10).build());
|
||||
assertThat(loadBucket(getBucketKey(3))).isEqualTo(
|
||||
new CommitLogBucket.Builder().setBucketNum(3).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_loadAllBuckets_loadsExistingBuckets_orNewOnesIfNonexistent() {
|
||||
ImmutableSet<CommitLogBucket> buckets = loadAllBuckets();
|
||||
assertThat(buckets).hasSize(10);
|
||||
assertThat(buckets).hasSize(3);
|
||||
assertThat(buckets).contains(bucket);
|
||||
for (int i = 2; i <= 10; ++i) {
|
||||
assertThat(buckets).contains(
|
||||
new CommitLogBucket.Builder().setBucketNum(i).build());
|
||||
}
|
||||
assertThat(buckets).contains(new CommitLogBucket.Builder().setBucketNum(2).build());
|
||||
assertThat(buckets).contains(new CommitLogBucket.Builder().setBucketNum(3).build());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,12 +19,10 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
|||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.config.TestRegistryConfig;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.ExceptionRule;
|
||||
import google.registry.testing.RegistryConfigRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -49,16 +47,6 @@ public class CommitLogCheckpointTest {
|
|||
private static final DateTime T2 = START_OF_TIME.plusMillis(1);
|
||||
private static final DateTime T3 = START_OF_TIME.plusMillis(2);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
// Use 3 buckets to make the tests below more realistic.
|
||||
configRule.override(new TestRegistryConfig() {
|
||||
@Override
|
||||
public int getCommitLogBucketCount() {
|
||||
return 3;
|
||||
}});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getCheckpointTime() {
|
||||
DateTime now = DateTime.now(UTC);
|
||||
|
@ -74,18 +62,6 @@ public class CommitLogCheckpointTest {
|
|||
assertThat(checkpoint.getBucketTimestamps()).containsExactly(1, T1, 2, T2, 3, T3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getBucketTimestamps_whenOnlyOneBucket_stillWorks() {
|
||||
configRule.override(new TestRegistryConfig() {
|
||||
@Override
|
||||
public int getCommitLogBucketCount() {
|
||||
return 1;
|
||||
}});
|
||||
CommitLogCheckpoint checkpoint =
|
||||
CommitLogCheckpoint.create(DateTime.now(UTC), ImmutableMap.of(1, T1));
|
||||
assertThat(checkpoint.getBucketTimestamps()).containsExactly(1, T1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_create_notEnoughBucketTimestamps_throws() {
|
||||
thrown.expect(IllegalArgumentException.class, "Bucket ids are incorrect");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue