Running XG Transactions in GAE Python

76 Views Asked by At

I'm trying to compose automated local unit testing for my app engine application, running on python.

It seems that whenever I'm trying to make a call for a transaction which is cross group ((XG=true)), the transaction simply doesn't work and the values are not stored.

Since I know XG transactions require HRD, I've placed these lines:

self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)

to simulate HRD.

However - still nothing.

Should note all functions work very well both in development and production. Just not in unit testing.

Any ideas?

1

There are 1 best solutions below

0
On BEST ANSWER

probability=0 means that the results won't be consistent ever, you probably want to set it to 1 instead.

This will mean that the behaviour in your tests is different from how it works in the live environment, but if the query is just to verify the code you're testing, then this is fine. (If the query is part of the code you're testing, then the code is probably incorrect, and the tests deserve to be failing.)