Centralize creation of MapreduceRunner in unit tests

This also changes the default number of mapper shards in tests to 2, which is
the number of EppResourceIndex buckets in unit tests. Running more shards than
there are buckets causes unnecessary test load.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135520601
This commit is contained in:
mcilwain 2016-10-07 14:52:40 -07:00 committed by Ben McIlwain
parent ec64f4799c
commit 222ccd912a
14 changed files with 22 additions and 33 deletions

View file

@ -32,6 +32,9 @@ import com.google.appengine.tools.pipeline.impl.servlets.PipelineServlet;
import com.google.appengine.tools.pipeline.impl.servlets.TaskHandler;
import com.google.apphosting.api.ApiProxy;
import com.google.common.base.CharMatcher;
import com.google.common.base.Optional;
import google.registry.config.RegistryEnvironment;
import google.registry.mapreduce.MapreduceRunner;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.testing.ShardableTestCase;
@ -84,6 +87,11 @@ public abstract class MapreduceTestCase<T> extends ShardableTestCase {
proxy.setProperty(LocalBlobstoreService.NO_STORAGE_PROPERTY, "true");
}
protected MapreduceRunner makeDefaultRunner() {
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
return new MapreduceRunner(Optional.<Integer>of(numBuckets), Optional.<Integer>of(1));
}
protected List<QueueStateInfo.TaskStateInfo> getTasks(String queueName) {
return taskQueue.getQueueStateInfo().get(queueName).getTaskInfo();
}