Set the premium cache duration in tests to 60s not 60ms

This was causing test flakiness.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155225717
This commit is contained in:
cgoldfeder 2017-05-05 12:11:12 -07:00 committed by Ben McIlwain
parent 3eef5095d4
commit 608e121a37
2 changed files with 8 additions and 6 deletions

View file

@ -52,6 +52,7 @@ import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.joda.money.Money; import org.joda.money.Money;
import org.joda.time.Duration;
/** /**
* A premium list entity, persisted to Datastore, that is used to check domain label prices. * A premium list entity, persisted to Datastore, that is used to check domain label prices.
@ -193,16 +194,15 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
* that exist, as well as those that might exist according to the Bloom filter, must be cached). * that exist, as well as those that might exist according to the Bloom filter, must be cached).
* The entries judged least likely to be accessed again will be evicted first. * The entries judged least likely to be accessed again will be evicted first.
*/ */
@NonFinalForTesting @NonFinalForTesting @VisibleForTesting
@VisibleForTesting
static LoadingCache<Key<PremiumListEntry>, Optional<PremiumListEntry>> cachePremiumListEntries = static LoadingCache<Key<PremiumListEntry>, Optional<PremiumListEntry>> cachePremiumListEntries =
createCachePremiumListEntries(getSingletonCachePersistDuration().getMillis()); createCachePremiumListEntries(getSingletonCachePersistDuration());
@VisibleForTesting @VisibleForTesting
static LoadingCache<Key<PremiumListEntry>, Optional<PremiumListEntry>> static LoadingCache<Key<PremiumListEntry>, Optional<PremiumListEntry>>
createCachePremiumListEntries(long cachePersistDurationMillis) { createCachePremiumListEntries(Duration cachePersistDuration) {
return CacheBuilder.newBuilder() return CacheBuilder.newBuilder()
.expireAfterWrite(cachePersistDurationMillis, MILLISECONDS) .expireAfterWrite(cachePersistDuration.getMillis(), MILLISECONDS)
.maximumSize(getStaticPremiumListMaxCachedEntries()) .maximumSize(getStaticPremiumListMaxCachedEntries())
.build( .build(
new CacheLoader<Key<PremiumListEntry>, Optional<PremiumListEntry>>() { new CacheLoader<Key<PremiumListEntry>, Optional<PremiumListEntry>>() {

View file

@ -33,6 +33,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.loadPremiumListEntries; import static google.registry.testing.DatastoreHelper.loadPremiumListEntries;
import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistPremiumList;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static org.joda.time.Duration.standardMinutes;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -63,7 +64,8 @@ public class PremiumListUtilsTest {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
// createTld() overwrites the premium list, so call it first. // createTld() overwrites the premium list, so call it first.
PremiumList.cachePremiumListEntries = PremiumList.createCachePremiumListEntries(60); PremiumList.cachePremiumListEntries =
PremiumList.createCachePremiumListEntries(standardMinutes(1));
createTld("tld"); createTld("tld");
PremiumList pl = PremiumList pl =
persistPremiumList( persistPremiumList(