File: getset.test

package info (click to toggle)
tarantool 1.5.2.20.g5f5d924-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,568 kB
  • ctags: 18,697
  • sloc: ansic: 109,092; sh: 21,312; cpp: 20,633; xml: 9,666; asm: 2,488; python: 2,195; java: 1,759; perl: 1,002; makefile: 679
file content (83 lines) | stat: -rw-r--r-- 2,791 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# encoding: tarantool
print """# set foo (and should get it) """
exec memcached "set foo 0 0 6\r\nfooval\r\n"
exec memcached "get foo\r\n"

print """# add bar (and should get it)"""
exec memcached "set bar 0 0 6\r\nbarval\r\n"
exec memcached "get bar\r\n"

print """# add foo (but shouldn't get new value)"""
exec memcached "add foo 0 0 5\r\nfoov2\r\n"
exec memcached "get foo\r\n"

print """# replace bar (should work)"""
exec memcached "replace bar 0 0 6\r\nbarva2\r\n"
exec memcached "get bar\r\n"

print """# replace notexist (shouldn't work)"""
exec memcached "replace notexist 0 0 6\r\nbarva2\r\n"
exec memcached "get notexist\r\n"

print """# delete foo"""
exec memcached "delete foo\r\n"
exec memcached "get foo\r\n"

print """# delete foo again. not found this time."""
exec memcached "delete foo\r\n"
exec memcached "get foo\r\n"

print """# add moo"""
exec memcached "add moo 0 0 6\r\nmooval\r\n"
exec memcached "get moo\r\n"

print """# check-and-set (cas) failure case, try to set value with incorrect cas unique val"""
exec memcached "cas moo 0 0 6 0\r\nMOOVAL\r\n"
exec memcached "get moo\r\n"

result = exec memcached silent "gets moo\r\n"
unique_id = int(result.split()[4])

print """# now test that we can store moo with the correct unique id"""
exec memcached silent "cas moo 0 0 6 %d\r\nMOOVAL\r\n" % unique_id
exec memcached "get moo\r\n"

exec memcached "set foo 0 0 6\r\nfooval\r\ndelete foo\r\nset foo 0 0 6\r\nfooval\r\ndelete foo\r\n"

len = 1024
while len < (1024 * 1028):
    val = 'B' * len
    if len > (1024 * 1024):
        print """# Ensure causing a memory overflow doesn't leave stale data."""
        print "# set small data: - should pass"
        exec memcached "set foo_%d 0 0 3\r\nMOO\r\n" % (len)
        exec memcached "get foo_%d\r\n" % (len)
        print "# set big data: - should fail"
        print "set foo_%d 0 0 %d\r\n<big-data>\r\n" % (len, len)
        print exec memcached silent "set foo_%d 0 0 %d\r\n%s\r\n" % (len, len, val)
    else:
        print "# set big data: - should pass"
        print "set foo_%d 0 0 %d\r\n<big-data>\r\n" % (len, len)
        print exec memcached silent "set foo_%d 0 0 %d\r\n%s\r\n" % (len, len, val)
    len += 1024 * 512

print """#
# A test for Bug#898198 memcached protocol isn't case-insensitive"
#"""

exec memcached "SET foo 0 0 6\r\nfooval\r\n"
exec memcached "GET foo\r\n"
exec memcached "ADD foo 0 0 5\r\nfoov2\r\n"
exec memcached "GET foo\r\n"
exec memcached "REPLACE bar 0 0 6\r\nbarva2\r\n"
exec memcached "GET bar\r\n"
exec memcached "DELETE foo\r\n"
exec memcached "GET foo\r\n"
exec memcached "CAS moo 0 0 6 0\r\nMOOVAL\r\n"
exec memcached "GET moo\r\n"
exec memcached "GETS moo\r\n"

# resore default suite config
server.stop()
server.deploy(self.suite_ini["config"])
# vim: syntax=python