Remove all vestiges of memcache

Memcache is already off but now it's not in the code anymore.

This includes removing domain creation failfast, since that is actually
slower now than just running the flow - all you gain is a non-transactional
read over a transactional read, but the cost is that you always pay that
read, which is going to drive up latency.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=158183506
This commit is contained in:
cgoldfeder 2017-06-06 13:43:42 -07:00 committed by Ben McIlwain
parent 445faab977
commit ae039aa0d8
37 changed files with 29 additions and 341 deletions

View file

@ -85,7 +85,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.withMemcache()
.withTaskQueue()
.build();

View file

@ -69,8 +69,8 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
}
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
// Force the session to be cleared so that when we read it back, we read from Datastore and
// not from the transaction cache or memcache.
// Force the session to be cleared so that when we read it back, we read from Datastore and not
// from the transaction's session cache.
ofy().clearSessionCache();
return loadByForeignKey(getResourceClass(), getUniqueIdFromCommand(), now);
}

View file

@ -17,7 +17,6 @@ package google.registry.flows.domain;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import static google.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
import static google.registry.model.ofy.ObjectifyService.ofy;
@ -25,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.deleteTld;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
@ -33,7 +31,6 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.EUR;
import static org.joda.money.CurrencyUnit.USD;
@ -107,12 +104,10 @@ import google.registry.flows.domain.DomainFlowUtils.UnsupportedFeeAttributeExcep
import google.registry.flows.domain.DomainFlowUtils.UnsupportedMarkTypeException;
import google.registry.flows.exceptions.ResourceAlreadyExistsException;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.LrpTokenEntity;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchPhase;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry;
@ -1526,7 +1521,7 @@ public class DomainApplicationCreateFlowTest
@Test
public void testFailure_alreadyExists_triggersFailfast() throws Exception {
public void testFailure_alreadyExists() throws Exception {
persistContactsAndHosts();
clock.advanceOneMilli();
persistActiveDomain(getUniqueIdFromCommand());
@ -1537,7 +1532,6 @@ public class DomainApplicationCreateFlowTest
+ "Object with given ID (%s) already exists",
getUniqueIdFromCommand());
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isTrue();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
@ -1712,37 +1706,6 @@ public class DomainApplicationCreateFlowTest
runFlow();
}
/**
* There is special logic that disallows a failfast for domains in add grace period and sunrush
* add grace period, so make sure that they fail anyways in the actual flow.
*/
private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus)
throws Exception {
persistContactsAndHosts();
clock.advanceOneMilli();
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null))
.build());
try {
runFlow();
assertWithMessage("Expected ResourceAlreadyExistsException to be thrown").fail();
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isFalse();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
}
@Test
public void testFailure_alreadyExists_addGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.ADD);
}
@Test
public void testFailure_alreadyExists_sunrushAddGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.SUNRUSH_ADD);
}
private void doFailingDomainNameTest(String domainName, Class<? extends Throwable> exception)
throws Exception {
setEppInput("domain_create_sunrise_signed_mark_uppercase.xml");

View file

@ -23,7 +23,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.MemcacheHelper.clearMemcache;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
@ -332,9 +331,8 @@ public class DomainApplicationInfoFlowTest
@Test
public void testBatchLoadingOfReferences() throws Exception {
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
// Clear out memcache and session cache so that we count actual Datastore calls.
// Clear out the session cache so that we count actual Datastore calls.
ofy().clearSessionCache();
clearMemcache();
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
doSuccessfulTest("domain_info_sunrise_response.xml", HostsState.HOSTS_EXIST);
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.

View file

@ -30,7 +30,6 @@ import static google.registry.testing.DatastoreHelper.deleteTld;
import static google.registry.testing.DatastoreHelper.getHistoryEntries;
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;
@ -892,7 +891,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
@Test
public void testFailure_alreadyExists_triggersFailfast() throws Exception {
public void testFailure_alreadyExists() throws Exception {
persistContactsAndHosts();
persistActiveDomain(getUniqueIdFromCommand());
try {
@ -902,43 +901,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
+ "Object with given ID (%s) already exists",
getUniqueIdFromCommand());
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isTrue();
assertAboutEppExceptions().that(e).marshalsToXml().and().hasMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
}
/**
* There is special logic that disallows a failfast for domains in add grace period and sunrush
* add grace period, so make sure that they fail anyways in the actual flow.
*/
private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus)
throws Exception {
// This doesn't fail fast, so it throws the regular ResourceAlreadyExistsException from run().
persistContactsAndHosts();
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null))
.build());
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
try {
runFlow();
} catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isFalse();
throw e;
}
}
@Test
public void testFailure_alreadyExists_addGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.ADD);
}
@Test
public void testFailure_alreadyExists_sunrushAddGracePeriod() throws Exception {
doNonFailFastAlreadyExistsTest(GracePeriodStatus.SUNRUSH_ADD);
}
@Test
public void testFailure_reserved() throws Exception {

View file

@ -24,7 +24,6 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.MemcacheHelper.clearMemcache;
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
@ -637,9 +636,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
@Test
public void testBatchLoadingOfReferences() throws Exception {
persistTestEntities(false);
// Clear out memcache and session cache so that we count actual Datastore calls.
// Clear out the session cache so that we count actual Datastore calls.
ofy().clearSessionCache();
clearMemcache();
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
doSuccessfulTest("domain_info_response.xml", false);
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.