# encoding: tarantool
from lib.memcached_connection import MemcachedConnection

buf_size = 256 * 1024
buf = "0123456789abcdef" * (buf_size / 16)
buf_upper = buf.upper()

memcached1 = server.memcached
memcached2 = MemcachedConnection('localhost', server.memcached_port)

print """# Store big in lower case via first memcached client """
print "set big 0 0 %d\r\n<big-value-lower-case>" % buf_size
print memcached1.execute("set big 0 0 %d\r\n%s" % (buf_size, buf), silent = True)

print """# send command 'get big' to firs memcached client """
memcached1.send_commands("get big", silent = False)

print """# send command 'delete big' to second client """
memcached2.execute("delete big")

print """# Store big in lower case via first memcached client """
print "set big 0 0 %d\r\n<big-value-upper-case>" % buf_size
print memcached2.execute("set big 0 0 %d\r\n%s" % (buf_size, buf_upper), silent = True)

print """# recv reply 'get big' from firs memcached client """
reply = memcached1.recv_reply(silent = True).split('\r\n')[1]
if buf == reply:
    print "succes: buf == reply"
else:
    print "fail: buf != reply"

# resore default suite config
server.stop()
server.deploy(self.suite_ini["config"])
server.start()
# check that we print clear memcached stats
exec admin "show stat"
# vim: syntax=python
