java - appengine unit test fetches only 10 entities -
java - appengine unit test fetches only 10 entities -
i have written unit test appengine needs fetch 250 entities after populating 1000. see of time fetches 10 entities. few times have seen has fetched 250 of them. pretty sure temporary datastore have 1000 entities because printing them while saving.
in @before method
system.out.println( "adding "+players.size()+ " entries" ); ofy().save().entities(players);
prints 1000 expected
in @test method
list<player> players = ofy().load().type( player.class ).order("-score").limit( 250 ).list(); system.out.println( "fetched "+players.size()+" top players" );
it may due fact test datastore service simulates eventual consistency behaviour. check unapplied job percentage configuration.
by setting unapplied job percentage 100, instructing local datastore operate maximum amount of eventual consistency. maximum eventual consistency means writes commit fail apply, global (non-ancestor) queries consistently fail see changes. of course of study not representative of amount of eventual consistency application see when running in production, testing purposes, it's useful able configure local datastore behave way every time.
try if helps.
@beforeclass public static void setupclass() throws exception { localservicetesthelper = new localservicetesthelper( new localdatastoreservicetestconfig().setdefaulthighrepjobpolicyunappliedjobpercentage(0)); }
however, aware of below fact.
note setdefaulthighrepjobpolicyunappliedjobpercentage(0)
switch local datastore service master/slave mode.
you can find more details here.
java google-app-engine unit-testing junit objectify
Comments
Post a Comment