def tearDownModule(): global testrun_search_bucket, testrun_props_bucket, \ testrun_sibs_bucket, testrun_yz_bucket c = RiakClient(host=HTTP_HOST, http_port=HTTP_PORT, pb_port=PB_PORT, credentials=SECURITY_CREDS) c.bucket(testrun_sibs_bucket).clear_properties() c.bucket(testrun_props_bucket).clear_properties() if not SKIP_SEARCH and not RUN_YZ: b = c.bucket(testrun_search_bucket) b.clear_properties() if RUN_YZ: for yz in (testrun_yz, testrun_yz_index, testrun_yz_mr): if yz['btype'] is not None: t = c.bucket_type(yz['btype']) b = t.bucket(yz['bucket']) else: b = c.bucket(yz['bucket']) b.set_property('search_index', '_dont_index_') c.delete_search_index(yz['index']) for keys in b.stream_keys(): for key in keys: b.delete(key)
def tearDownModule(): global testrun_search_bucket, testrun_props_bucket, \ testrun_sibs_bucket, testrun_yz_bucket c = RiakClient(host=HTTP_HOST, http_port=HTTP_PORT, pb_port=PB_PORT, credentials=SECURITY_CREDS) c.bucket(testrun_sibs_bucket).clear_properties() c.bucket(testrun_props_bucket).clear_properties() if not SKIP_SEARCH and not RUN_YZ: b = c.bucket(testrun_search_bucket) b.clear_properties() if RUN_YZ: yzbucket = c.bucket(testrun_yz_bucket) yzbucket.set_property('search_index', '_dont_index_') c.delete_search_index(testrun_yz_bucket) for keys in yzbucket.stream_keys(): for key in keys: yzbucket.delete(key) mrtype = c.bucket_type(testrun_mr_btype) mrbucket = mrtype.bucket(testrun_mr_bucket) mrbucket.set_property('search_index', '_dont_index_') c.delete_search_index(testrun_mr_bucket) for keys in mrbucket.stream_keys(): for key in keys: mrbucket.delete(key)
def setUpModule(): global testrun_search_bucket, testrun_props_bucket, \ testrun_sibs_bucket, testrun_yz, testrun_yz_index, testrun_yz_mr c = RiakClient(host=PB_HOST, http_port=HTTP_PORT, pb_port=PB_PORT, credentials=SECURITY_CREDS) testrun_props_bucket = 'propsbucket' testrun_sibs_bucket = 'sibsbucket' c.bucket(testrun_sibs_bucket).allow_mult = True if (not SKIP_SEARCH and not RUN_YZ): testrun_search_bucket = 'searchbucket' b = c.bucket(testrun_search_bucket) b.enable_search() if RUN_YZ: # YZ index on bucket of the same name testrun_yz = {'btype': None, 'bucket': 'yzbucket', 'index': 'yzbucket'} # YZ index on bucket of a different name testrun_yz_index = { 'btype': None, 'bucket': 'yzindexbucket', 'index': 'yzindex' } # Add bucket and type for Search 2.0 -> MapReduce testrun_yz_mr = { 'btype': 'pytest-mr', 'bucket': 'mrbucket', 'index': 'mrbucket' } for yz in (testrun_yz, testrun_yz_index, testrun_yz_mr): c.create_search_index(yz['index']) if yz['btype'] is not None: t = c.bucket_type(yz['btype']) b = t.bucket(yz['bucket']) else: b = c.bucket(yz['bucket']) # Keep trying to set search bucket property until it succeeds index_set = False while not index_set: try: b.set_property('search_index', yz['index']) index_set = True except RiakError: pass
def setUpModule(): global testrun_search_bucket, testrun_props_bucket, \ testrun_sibs_bucket, testrun_yz, testrun_yz_index, testrun_yz_mr c = RiakClient(host=PB_HOST, http_port=HTTP_PORT, pb_port=PB_PORT, credentials=SECURITY_CREDS) testrun_props_bucket = 'propsbucket' testrun_sibs_bucket = 'sibsbucket' c.bucket(testrun_sibs_bucket).allow_mult = True if (not SKIP_SEARCH and not RUN_YZ): testrun_search_bucket = 'searchbucket' b = c.bucket(testrun_search_bucket) b.enable_search() if RUN_YZ: # YZ index on bucket of the same name testrun_yz = {'btype': None, 'bucket': 'yzbucket', 'index': 'yzbucket'} # YZ index on bucket of a different name testrun_yz_index = {'btype': None, 'bucket': 'yzindexbucket', 'index': 'yzindex'} # Add bucket and type for Search 2.0 -> MapReduce testrun_yz_mr = {'btype': 'pytest-mr', 'bucket': 'mrbucket', 'index': 'mrbucket'} for yz in (testrun_yz, testrun_yz_index, testrun_yz_mr): c.create_search_index(yz['index']) if yz['btype'] is not None: t = c.bucket_type(yz['btype']) b = t.bucket(yz['bucket']) else: b = c.bucket(yz['bucket']) # Keep trying to set search bucket property until it succeeds index_set = False while not index_set: try: b.set_property('search_index', yz['index']) index_set = True except RiakError: pass
def setUpModule(): global testrun_search_bucket, testrun_props_bucket, \ testrun_sibs_bucket, testrun_yz_bucket, testrun_mr_btype, \ testrun_mr_bucket c = RiakClient(protocol='pbc', host=PB_HOST, http_port=HTTP_PORT, pb_port=PB_PORT, credentials=SECURITY_CREDS) testrun_props_bucket = 'propsbucket' testrun_sibs_bucket = 'sibsbucket' c.bucket(testrun_sibs_bucket).allow_mult = True if (not SKIP_SEARCH and not RUN_YZ): testrun_search_bucket = 'searchbucket' b = c.bucket(testrun_search_bucket) b.enable_search() if RUN_YZ: c.protocol = 'pbc' testrun_yz_bucket = 'yzbucket' c.create_search_index(testrun_yz_bucket) b = c.bucket(testrun_yz_bucket) index_set = False while not index_set: try: b.set_property('search_index', testrun_yz_bucket) index_set = True except RiakError: pass # Add bucket and type for Search -> MapReduce testrun_mr_btype = 'pytest-mr' testrun_mr_bucket = 'mrbucket' c.create_search_index(testrun_mr_bucket, '_yz_default') t = c.bucket_type(testrun_mr_btype) b = t.bucket(testrun_mr_bucket) index_set = False while not index_set: try: b.set_property('search_index', testrun_mr_bucket) index_set = True except RiakError: pass
from riak.client import RiakClient import sys import time import datetime import random from checkin import Checkin checkin = Checkin(sys.argv[1], sys.argv[2], sys.argv[3]) checkin_probability = [60, 55, 25, 0, 0, 0, 0, 0, 0, 0, 0, 20, 40, 30, 25, 15, 15, 45, 60, 70, 80, 75, 65, 60] rating_comment = ["", "Lousy", "Ok", "Decent", "Pretty good", "Wow!"] client = RiakClient(host=sys.argv[1], pb_port=8087) bucket_type_default = client.bucket_type("bucket_type_default") location_bucket = bucket_type_default.bucket('location') f = open("users.txt") users = f.read().splitlines() user_set = set(users) # remove dupes user_list = list(user_set) user_count = len(user_list) f.close() f = open("wines.txt") wines = f.read().splitlines() wine_count = len(wines) f.close() f = open("locations.txt") locations = f.read().splitlines() location_count = len(locations)
from riak.riak_error import RiakError from riak.client import RiakClient from riak.datatypes import Map import sys import time import random client = RiakClient(host=sys.argv[1], pb_port=8087) bucket_type_default = client.bucket_type("bucket_type_default") bucket_type_map = client.bucket_type("bucket_type_map") def create_users(user_bucket, friends_bucket): with open("users.txt") as f: users = f.read().splitlines() user_set = set(users) # remove dupes user_list = list(user_set) # Add user for user in user_list: user = user.strip() record = user_bucket.new(user, data={}) print "User " + user + " added... " + str(record.store()) # Add 10 random friends for i in range(10): friend = user_list[random.randint(0, len(user_list) - 1)].strip() if friend != user: