def test_against(host, port, timeout = 600): with memcached_workload_common.make_memcache_connection({"address": (host, port), "mclib": "pylibmc", "protocol": "text"}) as mc: temp = 0 time_limit = time.time() + timeout while not temp and time.time() < time_limit: try: temp = mc.set("test", "test") print temp except Exception, e: print e pass time.sleep(1) goodsets = 0 goodgets = 0 for i in range(num_keys): try: if mc.set(str(i), str(i)): goodsets += 1 except: pass for i in range(num_keys): try: if mc.get(str(i)) == str(i): goodgets += 1 except: pass return goodsets, goodgets
def test_against(host, port, timeout = 600): with memcached_workload_common.make_memcache_connection({"address": (host, port), "mclib": "pylibmc", "protocol": "text"}) as mc: temp = 0 time_limit = time.time() + timeout while not temp and time.time() < time_limit: try: temp = mc.set("test", "test") print temp except Exception, e: print e pass time.sleep(1) goodsets = 0 goodgets = 0 for i in range(num_keys): try: if mc.set(str(i), str(i)): goodsets += 1 except: pass for i in range(num_keys): try: if mc.get(str(i)) == str(i): goodgets += 1 except: pass return goodsets, goodgets
def child(opts, log_path, load, save): # This is run in a separate process import sys sys.stdout = sys.stderr = file(log_path, "w") if load is None: clone, deleted = {}, set() else: print "Loading from %r..." % load with open(load) as f: clone, deleted = pickle.load(f) print "Starting test against server at %s:%d..." % opts["address"] with memcached_workload_common.make_memcache_connection(opts) as mc: serial_mix.test(opts, mc, clone, deleted) if save is not None: print "Saving to %r..." % save with open(save, "w") as f: pickle.dump((clone, deleted), f) print "Done with test."
def child(opts, log_path, load, save): # This is run in a separate process import sys sys.stdout = sys.stderr = file(log_path, "w") if load is None: clone, deleted = {}, set() else: print "Loading from %r..." % load with open(load) as f: clone, deleted = pickle.load(f) print "Starting test against server at %s:%d..." % opts["address"] with memcached_workload_common.make_memcache_connection(opts) as mc: serial_mix.test(opts, mc, clone, deleted) if save is not None: print "Saving to %r..." % save with open(save, "w") as f: pickle.dump((clone, deleted), f) print "Done with test."
# Copyright 2010-2012 RethinkDB, all rights reserved. from random import shuffle import sys, os sys.path.append( os.path.abspath( os.path.join(os.path.dirname(__file__), os.path.pardir, 'common'))) import memcached_workload_common from vcoptparse import * op = memcached_workload_common.option_parser_for_memcache() del op["mclib"] # No longer optional; we only work with memcache. op["num_ints"] = IntFlag("--num-ints", 10) opts = op.parse(sys.argv) opts["mclib"] = "memcache" with memcached_workload_common.make_memcache_connection(opts) as mc: print "Shuffling numbers" ints = range(0, opts["num_ints"]) shuffle(ints) # flag values are: # - 0 for strings # - 2 for ints print "Testing with flags" for i in ints: print "Inserting %d" % i if i % 2: val = str(i) else: val = i
typical_test(mc, "b", t, 1, 4) print " Done absolute_test." # Tests a relative timestamp 5 seconds from now. def basic_test(mc): print "basic_test..." typical_test(mc, "a", 5, 1, 4) print " Done basic_test." # Tests an expiration time that's already in the past. def past_test(mc): print "past_test..." expect(mc.set("p", "aaa", time=int(time.time()) - 5) == 1, "Set failed") print " Make sure we can't get the element back." expect(mc.get("p") == None, "Wait, we got a value?!") print " Done past_test." op = memcached_workload_common.option_parser_for_memcache() opts = op.parse(sys.argv) with memcached_workload_common.make_memcache_connection(opts) as mc: zero_test(mc) basic_test(mc) absolute_test(mc) past_test(mc) print "Done"