Skip to content

Commit 3824603

Browse files
committed
tests: make slabs-reassign2 test more resilient
Ran into issues on 32bit vs 64bit since the items take different amounts of space. Adjusted the test to fill past capacity instead of more precise values.
1 parent 2c04bc8 commit 3824603

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

t/slabs-reassign2.t

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings;
5-
use Test::More tests => 11;
5+
use Test::More tests => 12;
66
use FindBin qw($Bin);
77
use lib "$Bin/lib";
88
use MemcachedTest;
@@ -12,25 +12,23 @@ my $server = new_memcached('-m 60 -o slab_reassign,slab_automove,lru_crawler,lru
1212
my $sock = $server->sock;
1313

1414
my $value = "B"x11000;
15-
my $keycount = 5750;
15+
my $keycount = 6000;
1616

1717
my $res;
1818
for (1 .. $keycount) {
1919
print $sock "set nfoo$_ 0 0 11000 noreply\r\n$value\r\n";
2020
}
2121

22-
my $todelete = 0;
2322
{
2423
my $stats = mem_stats($sock);
2524
cmp_ok($stats->{curr_items}, '>', 4000, "stored at least 4000 11k items");
26-
$todelete = $stats->{curr_items};
27-
# for ('evictions', 'reclaimed', 'curr_items', 'cmd_set', 'bytes') {
28-
# print STDERR "$_: ", $stats->{$_}, "\n";
29-
# }
25+
#for ('evictions', 'reclaimed', 'curr_items', 'cmd_set', 'bytes') {
26+
# diag "$_: ", $stats->{$_}, "\n";
27+
#}
3028
}
3129

3230
# Make room in old class so rescues can happen when we switch slab classes.
33-
for (1 .. $todelete) {
31+
for (1 .. $keycount) {
3432
next unless $_ % 2 == 0;
3533
print $sock "delete nfoo$_ noreply\r\n";
3634
}
@@ -47,17 +45,21 @@ for (1 .. $todelete) {
4745
cmp_ok($tries, '>', 0, 'some pages moved back to global pool');
4846
}
4947

50-
$value = "B"x7000;
48+
my $stats_before = mem_stats($sock);
49+
50+
# Ensure we can set data into a different slab class.
51+
52+
$value = "B"x6000;
5153
for (1 .. $keycount) {
52-
print $sock "set ifoo$_ 0 0 7000 noreply\r\n$value\r\n";
54+
print $sock "set ifoo$_ 0 0 6000 noreply\r\n$value\r\n";
5355
}
5456

5557
my $missing = 0;
5658
my $hits = 0;
5759
for (1 .. $keycount) {
5860
print $sock "get ifoo$_\r\n";
5961
my $body = scalar(<$sock>);
60-
my $expected = "VALUE ifoo$_ 0 7000\r\n$value\r\nEND\r\n";
62+
my $expected = "VALUE ifoo$_ 0 6000\r\n$value\r\nEND\r\n";
6163
if ($body =~ /^END/) {
6264
$missing++;
6365
} else {
@@ -73,7 +75,8 @@ for (1 .. $keycount) {
7375

7476
{
7577
my $stats = mem_stats($sock);
76-
cmp_ok($stats->{evictions}, '<', 2000, 'evictions were less than 2000');
78+
cmp_ok($stats->{evictions} - $stats_before->{evictions}, '>', 0, 'evictions were greater than 0');
79+
cmp_ok($stats->{evictions} - $stats_before->{evictions}, '<', 2200, 'evictions were less than 2200');
7780
# for ('evictions', 'reclaimed', 'curr_items', 'cmd_set', 'bytes') {
7881
# print STDERR "$_: ", $stats->{$_}, "\n";
7982
# }

0 commit comments

Comments
 (0)