summaryrefslogtreecommitdiff
path: root/t/lru-maintainer.t
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2018-05-25 13:29:43 -0700
committerdormando <dormando@rydia.net>2018-05-25 13:31:07 -0700
commit99910511cbce5d2aa1df5534af9582129b6d7652 (patch)
treec48ffcf151eb78f214bfa7cc2b699a9d34262fc3 /t/lru-maintainer.t
parent3b11d16b3f92c51bfedbb092147e1c2b225945ff (diff)
downloadmemcached-99910511cbce5d2aa1df5534af9582129b6d7652.tar.gz
fix flaky lru-maintainer test
OS X test runs seem to run the maintainer thread either at a low priority, or take long enough to bootstrap that it gets into a high sleep backoff... and the test has some racy bits. now, wait for some juggles to happen to ensure the canary value gets rescued. fixes #380
Diffstat (limited to 't/lru-maintainer.t')
-rw-r--r--t/lru-maintainer.t12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/lru-maintainer.t b/t/lru-maintainer.t
index ac2ba7b..04fa76a 100644
--- a/t/lru-maintainer.t
+++ b/t/lru-maintainer.t
@@ -56,6 +56,18 @@ for (my $key = 0; $key < 100; $key++) {
# Items need two fetches to become active
mem_get_is($sock, "canary", $value);
mem_get_is($sock, "canary", $value);
+ $stats = mem_stats($sock);
+ # The maintainer thread needs to juggle a bit to actually rescue an
+ # item. If it's slow we could evict after resuming setting.
+ sleep 1;
+ for (0..4) {
+ my $s2 = mem_stats($sock);
+ if ($s2->{lru_maintainer_juggles} - $stats->{lru_maintainer_juggles} < 5) {
+ sleep 1;
+ next;
+ }
+ last;
+ }
}
print $sock "set key$key 0 0 66560\r\n$value\r\n";
is(scalar <$sock>, "STORED\r\n", "stored key$key");