summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2015-11-19 17:03:03 -0800
committerdormando <dormando@rydia.net>2015-11-19 17:03:03 -0800
commitc8e357f090ec1b037ca91225a6c5565b3b9b50ef (patch)
tree2da1e9c033075762952b1328ccc5aa8a3e7f0220
parentb6bf6df77c7860c42ff35c4a4f6a6b79db472f82 (diff)
downloadmemcached-c8e357f090ec1b037ca91225a6c5565b3b9b50ef.tar.gz
make slab reassign tests more reliable
on 32bit hardware with different pointer/slab class sizes, the tests would fail. made a few adjustments to ensure reassign rescues happen and make items not be near the default slab class borders. This makes the tests pass, but needs further improvements for reliability.. ie: "fill until evicts", count slab pages for reassignment/etc.
-rw-r--r--t/slabs-reassign2.t33
1 files changed, 20 insertions, 13 deletions
diff --git a/t/slabs-reassign2.t b/t/slabs-reassign2.t
index c8e6c1e..4ed43ea 100644
--- a/t/slabs-reassign2.t
+++ b/t/slabs-reassign2.t
@@ -7,28 +7,35 @@ use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
-my $server = new_memcached('-m 64 -o slab_reassign,slab_automove=2,lru_crawler,lru_maintainer');
+my $server = new_memcached('-m 60 -o slab_reassign,slab_automove=2,lru_crawler,lru_maintainer');
my $sock = $server->sock;
-my $value = "B"x10240;
-my $keycount = 6000;
+my $value = "B"x11000;
+my $keycount = 5000;
my $res;
for (1 .. $keycount) {
- print $sock "set nfoo$_ 0 0 10240 noreply\r\n$value\r\n";
+ print $sock "set nfoo$_ 0 0 11000 noreply\r\n$value\r\n";
}
+my $todelete = 0;
{
my $stats = mem_stats($sock);
- is($stats->{curr_items}, $keycount, "stored $keycount 10k items");
+ cmp_ok($stats->{curr_items}, '>', 4000, "stored at least 4000 11k items");
+ $todelete = $stats->{curr_items} / 2;
# for ('evictions', 'reclaimed', 'curr_items', 'cmd_set', 'bytes') {
# print STDERR "$_: ", $stats->{$_}, "\n";
# }
}
-$value = "B"x8096;
+# Make room in old class so rescues can happen when we switch slab classes.
+for (1 .. $todelete) {
+ print $sock "delete nfoo$_ noreply\r\n";
+}
+
+$value = "B"x7000;
for (1 .. $keycount) {
- print $sock "set ifoo$_ 0 0 8096 noreply\r\n$value\r\n";
+ print $sock "set ifoo$_ 0 0 7000 noreply\r\n$value\r\n";
}
my $missing = 0;
@@ -36,7 +43,7 @@ my $hits = 0;
for (1 .. $keycount) {
print $sock "get ifoo$_\r\n";
my $body = scalar(<$sock>);
- my $expected = "VALUE ifoo$_ 0 8096\r\n$value\r\nEND\r\n";
+ my $expected = "VALUE ifoo$_ 0 7000\r\n$value\r\nEND\r\n";
if ($body =~ /^END/) {
$missing++;
} else {
@@ -61,7 +68,7 @@ for (1 .. $keycount) {
cmp_ok($hits, '>', 4000, 'were able to fetch back 2/3rds of 8k keys');
my $stats_done = mem_stats($sock);
cmp_ok($stats_done->{slab_reassign_rescues}, '>', 0, 'some reassign rescues happened');
-cmp_ok($stats_done->{slab_reassign_evictions_nomem}, '>', 0, 'some reassing evictions happened');
+cmp_ok($stats_done->{slab_reassign_evictions_nomem}, '>', 0, 'some reassign evictions happened');
print $sock "flush_all\r\n";
is(scalar <$sock>, "OK\r\n", "did flush_all");
@@ -69,7 +76,7 @@ my $tries;
for ($tries = 20; $tries > 0; $tries--) {
sleep 1;
my $stats = mem_stats($sock);
- if ($stats->{slab_global_page_pool} == 61) {
+ if ($stats->{slab_global_page_pool} == 56) {
last;
}
}
@@ -77,7 +84,7 @@ cmp_ok($tries, '>', 0, 'reclaimed 61 pages before timeout');
{
my $stats = mem_stats($sock, "slabs");
- is($stats->{total_malloced}, 68157440, "total_malloced is what we expect");
+ is($stats->{total_malloced}, 62914560, "total_malloced is what we expect");
}
# Set into an entirely new class. Overload a bit to try to cause problems.
@@ -88,11 +95,11 @@ for (1 .. $keycount * 4) {
{
my $stats = mem_stats($sock);
- is($stats->{curr_items}, 14490, "stored 14490 4k items");
+ cmp_ok($stats->{curr_items}, '>', 10000, "stored at least 10000 4k items");
is($stats->{slab_global_page_pool}, 0, "drained the global page pool");
}
{
my $stats = mem_stats($sock, "slabs");
- is($stats->{total_malloced}, 68157440, "total_malloced is same after re-assignment");
+ is($stats->{total_malloced}, 62914560, "total_malloced is same after re-assignment");
}