[memcached] bradfitz, r345: add partially-failing flush_all test,
an...
commits at code.sixapart.com
commits at code.sixapart.com
Mon Sep 4 06:16:24 UTC 2006
add partially-failing flush_all test, and make mem_get_is function
able to recover and move on when expecting nothing and getting
something.
A trunk/server/test/flush-all.t
U trunk/server/test/lib/MemcachedTest.pm
Added: trunk/server/test/flush-all.t
===================================================================
--- trunk/server/test/flush-all.t 2006-09-04 06:11:16 UTC (rev 344)
+++ trunk/server/test/flush-all.t 2006-09-04 06:16:24 UTC (rev 345)
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 8;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+my $expire;
+
+print $sock "set foo 0 1 6\r\nfooval\r\n";
+is(scalar <$sock>, "STORED\r\n", "stored foo");
+
+mem_get_is($sock, "foo", "fooval");
+print $sock "flush_all\r\n";
+is(scalar <$sock>, "OK\r\n", "did flush_all");
+
+mem_get_is($sock, "foo", undef);
+sleep 2;
+mem_get_is($sock, "foo", undef);
+
Property changes on: trunk/server/test/flush-all.t
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/server/test/lib/MemcachedTest.pm
===================================================================
--- trunk/server/test/lib/MemcachedTest.pm 2006-09-04 06:11:16 UTC (rev 344)
+++ trunk/server/test/lib/MemcachedTest.pm 2006-09-04 06:16:24 UTC (rev 345)
@@ -25,7 +25,11 @@
print $sock "get $key\r\n";
if (! defined $val) {
- Test::More::is(scalar <$sock>, "END\r\n", $msg);
+ my $line = scalar <$sock>;
+ if ($line =~ /^VALUE/) {
+ $line .= scalar(<$sock>) . scalar(<$sock>);
+ }
+ Test::More::is($line, "END\r\n", $msg);
} else {
my $len = length($val);
my $body = scalar(<$sock>);
More information about the memcached-commits
mailing list