mirror of
https://github.com/google/nomulus
synced 2026-09-20 15:04:24 +00:00
Make DomainInfoFlow (and application info) explicitly hit memcache
TESTED=For all tests, I added @Cache to DomainBase because otherwise the tests will
fail. We aren't ready to do this in prod yet, which is why the tests have a TODO
in them. The new tests fail if you change line 134 in Ofy to not use memcache
and either use the unchanged original flow code, or use the new
inlined code and change loadWithMemcache() to load(). They pass with the new
inlined code that calls loadWithMemcache(), as long as the @Cache is added to
DomainResource.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154457655
This commit is contained in:
@@ -24,6 +24,7 @@ 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.MemcacheHelper.setMemcacheContents;
|
||||
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
|
||||
|
||||
@@ -52,6 +53,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
||||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.DomainApplicationIndex;
|
||||
import google.registry.model.ofy.RequestCapturingAsyncDatastoreService;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.smd.EncodedSignedMark;
|
||||
@@ -328,6 +330,28 @@ public class DomainApplicationInfoFlowTest
|
||||
runFlow();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadsComeFromMemcache() throws Exception {
|
||||
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
|
||||
setMemcacheContents(
|
||||
Key.create(application),
|
||||
DomainApplicationIndex.createKey(application),
|
||||
Key.create(registrant),
|
||||
Key.create(contact),
|
||||
Key.create(host1),
|
||||
Key.create(host2));
|
||||
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
|
||||
doSuccessfulTest("domain_info_sunrise_response.xml", HostsState.HOSTS_EXIST);
|
||||
|
||||
// Everything should be in memcache so nothing should hit datastore.
|
||||
int numReadsInFlow = RequestCapturingAsyncDatastoreService.getReads().size() - numPreviousReads;
|
||||
// TODO(b/27424173): This is 1 because there is no @Cache annotation on DomainBase, and we
|
||||
// don't want to blindly add it because that's a production change that adds potentially
|
||||
// dangerous caching. When the recommendations from the audit in b/27424173 are done and we've
|
||||
// tested the new safer caching this should be set to 0.
|
||||
assertThat(numReadsInFlow).isEqualTo(1);
|
||||
}
|
||||
|
||||
/** Test that we load contacts and hosts as a batch rather than individually. */
|
||||
@Test
|
||||
public void testBatchLoadingOfReferences() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user