def test99_free_pool1(self): p = IpPortResourcePool(POOL1, '1.1.1.10') pool = MemcachePool(['localhost'], p, timeout=10) pool.free_all() p = IpPortResourcePool(POOL2, '1.1.1.10') pool = MemcachePool(['localhost'], p, timeout=10) pool.free_all()
def test03_anon_get(self): p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine1') pool = MemcachePool(['localhost'], p, timeout=10) i = pool.get() pool.free(i) print(("Anonymous item:\n %s\n\n" % i)) self.assertEqual(i.value, (IPAddress('1.1.1.10'), 20003))
def test01_named_get(self): print('Memcached IP/port pool on machine1:\n') p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine1') pool = MemcachePool(['localhost'], p, timeout=10) i = pool.get('bip1') print(("Item by name:\n %s\n" % pool.bip1)) self.assertEqual(i.value, (IPAddress('1.1.1.10'), 20000))
def test04_prefixed_named_get(self): print('Memcached IP/port pool on machine2:') p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine2') pool = MemcachePool(['localhost'], p, timeout=10) pool.sync() i = pool.get('bip1') print((" %s\n" % i)) self.assertEqual(i.value, (IPAddress('1.1.1.10'), 20003))
def test05_named_get(self): """Test that named get returns the cached value in test01""" print('Memcached IP/port pool on machine1, again:') p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine1') pool = MemcachePool(['localhost'], p, timeout=10) pool.sync() i = pool.get('bip1') print((" %s\n" % i)) self.assertEqual(i.value, (IPAddress('1.1.1.10'), 20000))
def test02_named_get_multi(self): print('Memcached IP/port pool on machine1:\n') p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine1') pool = MemcachePool(['localhost'], p, timeout=10) pool.get_multi(2, name="vip_%d") print(("Multiple items by name:\n %s %s\n" % (pool.vip_1.value, pool.vip_2))) self.assertEqual(pool.vip_1.value, (IPAddress('1.1.1.10'), 20001)) self.assertEqual(pool.vip_2.value, (IPAddress('1.1.1.10'), 20002))
def test06_anon_scale(self): """Test the time it takes to get 2000 items""" p = IpPortResourcePool(POOL1, '1.1.1.10', prefix='machine1') pool = MemcachePool(['localhost'], p, timeout=10) items = pool.get_multi(2000) print(("It's fairly scalable too:\n %s\n" % items[-1]))