~dave-terei/libmemcached/sasl-fixes

« back to all changes in this revision

Viewing changes to memcached/t/flush-all.t

Merging bzr://gaz.tangent.org/libmemcached/build/ to Build branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use Test::More tests => 21;
 
5
use FindBin qw($Bin);
 
6
use lib "$Bin/lib";
 
7
use MemcachedTest;
 
8
 
 
9
my $server = new_memcached();
 
10
my $sock = $server->sock;
 
11
my $expire;
 
12
 
 
13
print $sock "set foo 0 0 6\r\nfooval\r\n";
 
14
is(scalar <$sock>, "STORED\r\n", "stored foo");
 
15
 
 
16
mem_get_is($sock, "foo", "fooval");
 
17
print $sock "flush_all\r\n";
 
18
is(scalar <$sock>, "OK\r\n", "did flush_all");
 
19
mem_get_is($sock, "foo", undef);
 
20
 
 
21
# Test flush_all with zero delay.
 
22
print $sock "set foo 0 0 6\r\nfooval\r\n";
 
23
is(scalar <$sock>, "STORED\r\n", "stored foo");
 
24
 
 
25
mem_get_is($sock, "foo", "fooval");
 
26
print $sock "flush_all 0\r\n";
 
27
is(scalar <$sock>, "OK\r\n", "did flush_all");
 
28
mem_get_is($sock, "foo", undef);
 
29
 
 
30
# check that flush_all doesn't blow away items that immediately get set
 
31
print $sock "set foo 0 0 3\r\nnew\r\n";
 
32
is(scalar <$sock>, "STORED\r\n", "stored foo = 'new'");
 
33
mem_get_is($sock, "foo", 'new');
 
34
 
 
35
# and the other form, specifying a flush_all time...
 
36
my $expire = time() + 2;
 
37
print $sock "flush_all $expire\r\n";
 
38
is(scalar <$sock>, "OK\r\n", "did flush_all in future");
 
39
 
 
40
print $sock "set foo 0 0 4\r\n1234\r\n";
 
41
is(scalar <$sock>, "STORED\r\n", "stored foo = '1234'");
 
42
mem_get_is($sock, "foo", '1234');
 
43
sleep(3);
 
44
mem_get_is($sock, "foo", undef);
 
45
 
 
46
print $sock "set foo 0 0 5\r\n12345\r\n";
 
47
is(scalar <$sock>, "STORED\r\n", "stored foo = '12345'");
 
48
mem_get_is($sock, "foo", '12345');
 
49
print $sock "flush_all 86400\r\n";
 
50
is(scalar <$sock>, "OK\r\n", "did flush_all for far future");
 
51
# Check foo still exists.
 
52
mem_get_is($sock, "foo", '12345');
 
53
print $sock "set foo2 0 0 5\r\n54321\r\n";
 
54
is(scalar <$sock>, "STORED\r\n", "stored foo2 = '54321'");
 
55
mem_get_is($sock, "foo", '12345');
 
56
mem_get_is($sock, "foo2", '54321');