verify(input, inputReader, output, outputWriter);
}
@Test
public void testDatastoreData() throws Exception {
final DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();
// Datastore restriction: id cannot be zero.
for (long i = 1; i <= 100; ++i) {
datastoreService.put(new Entity(KeyFactory.createKey("Test", i)));
}
runTest(new MapReduceSpecification.Builder<>(new DatastoreInput("Test", 5), new TestMapper(),
new TestReducer(), new InMemoryOutput<KeyValue<String, List<Long>>>())
.setKeyMarshaller(Marshallers.getStringMarshaller())
.setValueMarshaller(Marshallers.getLongMarshaller()).setJobName("Test MR").build(),
new Verifier<List<List<KeyValue<String, List<Long>>>>>() {
@Override
public void verify(MapReduceResult<List<List<KeyValue<String, List<Long>>>>> result)
throws Exception {
Counters counters = result.getCounters();
log.info("counters=" + counters);
assertNotNull(counters);
assertEquals(100, counters.getCounter("map").getValue());
assertEquals(5, counters.getCounter("beginShard").getValue());
assertEquals(5, counters.getCounter("endShard").getValue());
assertEquals(5, counters.getCounter("beginSlice").getValue());
assertEquals(5, counters.getCounter("endSlice").getValue());
assertEquals(100, counters.getCounter(CounterNames.MAPPER_CALLS).getValue());
assertTrue(counters.getCounter(CounterNames.MAPPER_WALLTIME_MILLIS).getValue() > 0);
Query query = new Query("Test");
for (Entity e : datastoreService.prepare(query).asIterable()) {
Object mark = e.getProperty("mark");
assertNotNull(mark);
}
List<KeyValue<String, List<Long>>> output =