Created
August 4, 2011 17:58
-
-
Save bretthoerner/1125778 to your computer and use it in GitHub Desktop.
Riak (Python?) sibling question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import riak | |
| import random | |
| r = riak.RiakClient() | |
| b = r.bucket("test") | |
| # allow_mult | |
| b.set_allow_multiples(True) | |
| # new obj per run | |
| key = "obj-%s" % random.randint(0, 1000000) | |
| # brand new obj, ver 0 | |
| new_obj = b.new(key, data={'ver': 0}) | |
| # two new gets, they should share the same vclock | |
| child1 = b.get(key) | |
| child2 = b.get(key) | |
| assert(child1.vclock() == child2.vclock()) | |
| child1.set_data({'ver': 1}) | |
| child1.store() | |
| child2.set_data({'ver': 2}) | |
| child2.store() | |
| # vlocks should now have diverged | |
| assert(child1.vclock() != child2.vclock()) | |
| # a new request should have multiple siblings to deal with | |
| new_request = b.get(key) | |
| print "Siblings: ", new_request.get_sibling_count() | |
| assert(new_request.get_sibling_count() == 2) | |
| data = [] | |
| for sib in new_request.get_siblings(): | |
| data.append(sib.get_data()) | |
| print "Sibling data: ", sib.get_data() | |
| # get_siblings should only return 2 values... | |
| # FIXME: why does it return 3? why does one have a value of None? | |
| assert(len(data) == 2) | |
| # both versions should be represented somewhere in the returned siblings | |
| # FIXME: why do both have a value of {'ver': 1}? | |
| assert({'ver': 1} in data) | |
| assert({'ver': 2} in data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment