I'm trying to test my app under the worst conditions for eventual consistency. It seems like there are two approaches I can use:
Approach A1: setDefaultHighRepJobPolicyUnappliedJobPercentage(100)
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setDefaultHighRepJobPolicyUnappliedJobPercentage(100));
source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests
Approach A2: CustomHighRepJobPolicy
private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
@Override
public boolean shouldApplyNewJob(Key arg0) {
return false;
}
@Override
public boolean shouldRollForwardExistingJob(Key arg0) {
return false;
}
}
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));
source: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (comment from Broc Seib)
Question A
Both approaches seem to produce the desired effect of never updating any of the indices so that queries without an ancestor never return results. But are there any differences in these two approaches one should be aware of?
Question B
When testing the opposite (no eventual consistency such that indices are updated immediately), there seems to be three approaches...are there any differences one should be are of?
Approach B1: setDefaultHighRepJobPolicyUnappliedJobPercentage(0)
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setDefaultHighRepJobPolicyUnappliedJobPercentage(0));
source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests
Approach B2: CustomHighRepJobPolicy
private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
@Override
public boolean shouldApplyNewJob(Key arg0) {
return true;
}
@Override
public boolean shouldRollForwardExistingJob(Key arg0) {
return true;
}
}
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));
source: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (comment from Broc Seib)
Approach B3: setApplyAllHighRepJobPolicy
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setApplyAllHighRepJobPolicy());
source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests
My recommended approach is to measure each choice under a realistic/pessimistic load-testing simulated workload. That will answer your reasonable doubts much better than any of us might by just pondering on it! "What you don't measure, you can't manage", and "data roolz"!
I am not aware of any substantial difference between these approaches -- that doesn't mean there aren't any (alas, Java's not my strongest area, so there may be Java specific subtleties I'm not aware of!)...
Rather, it means that what I would do in your shoes would be exactly what I recommend here -- hack together some heavy load-testing workloads, and run them through the same bunch of unit tests, varying only the policy, and see what happens in terms of test results and running times.
I'd expect to observe the same test results, and roughly equal running times, and any discrepancy would show me where I need to dig in deeper!-)