mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Turn on memcache in flow tests.
No tests break because of this, but some tests that were previously intentionally clearing memcache (for example, the test in DomainInfoFlow that counts datastore calls) are now doing something that is not a no-op anymore. Also fix an incorrect comment about memcache in DatastoreHelper. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154087182
This commit is contained in:
parent
b15d715dc0
commit
b6e50f0467
3 changed files with 16 additions and 2 deletions
|
@ -83,6 +83,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.withMemcache()
|
||||
.withTaskQueue()
|
||||
.build();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import static org.json.XML.toJSONObject;
|
||||
|
||||
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalModulesServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
|
||||
|
@ -95,6 +96,7 @@ public final class AppEngineRule extends ExternalResource {
|
|||
|
||||
private boolean withDatastore;
|
||||
private boolean withLocalModules;
|
||||
private boolean withMemcache;
|
||||
private boolean withTaskQueue;
|
||||
private boolean withUserService;
|
||||
private boolean withUrlFetch;
|
||||
|
@ -120,6 +122,12 @@ public final class AppEngineRule extends ExternalResource {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Turn on the use of local modules. */
|
||||
public Builder withMemcache() {
|
||||
rule.withMemcache = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/** Turn on the task queue service. */
|
||||
public Builder withTaskQueue() {
|
||||
|
@ -273,6 +281,9 @@ public final class AppEngineRule extends ExternalResource {
|
|||
.addBasicScalingModuleVersion("tools", "1", 1)
|
||||
.addBasicScalingModuleVersion("backend", "1", 1));
|
||||
}
|
||||
if (withMemcache) {
|
||||
configs.add(new LocalMemcacheServiceTestConfig());
|
||||
}
|
||||
if (withTaskQueue) {
|
||||
File queueFile = temporaryFolder.newFile("queue.xml");
|
||||
Files.asCharSink(queueFile, UTF_8).write(taskQueueXml);
|
||||
|
|
|
@ -819,8 +819,10 @@ public class DatastoreHelper {
|
|||
public void vrun() {
|
||||
saveResource(resource, wantBackup);
|
||||
}});
|
||||
// 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 cache to be cleared so that when we read the resource back, we read from
|
||||
// Datastore (or memcache) and not from the session cache. This is needed to trigger Objectify's
|
||||
// load process (unmarshalling entity protos to POJOs, nulling out empty collections, calling
|
||||
// @OnLoad methods, etc.) which is bypassed for entities loaded from the session cache.
|
||||
ofy().clearSessionCache();
|
||||
return ofy().load().entity(resource).now();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue