summaryrefslogtreecommitdiff
path: root/t/proxyconfig.t
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-04-17 18:32:11 -0700
committerdormando <dormando@rydia.net>2023-04-17 18:32:11 -0700
commit375869286af2c11137b050f80a45e4b4852a2723 (patch)
treed7ef9691627f8738fd213b5721981b7f68e11186 /t/proxyconfig.t
parent294e0d9fe6922642655504bec4d1845f6603a03c (diff)
downloadmemcached-375869286af2c11137b050f80a45e4b4852a2723.tar.gz
proxy: fix flaky test in proxyconfig.t
The connect timeout won't fire when blocking a backend from connecting in these tests; it will connect, send a version command to validate, then time out on read. With the read timeout set to 0.1 it would sometimes fail before the restart finished, clogging log lines and causing test failures. Now we wait for the watcher and remove a sleep, with a longer read timeout.
Diffstat (limited to 't/proxyconfig.t')
-rw-r--r--t/proxyconfig.t11
1 files changed, 6 insertions, 5 deletions
diff --git a/t/proxyconfig.t b/t/proxyconfig.t
index e839bd8..5ea8d48 100644
--- a/t/proxyconfig.t
+++ b/t/proxyconfig.t
@@ -123,7 +123,7 @@ my $keycount = 100;
my $cmd = "mg foo v\r\n";
print $ps $cmd;
my @readable = $s->can_read(0.25);
- is(scalar @readable, 1, "only one backend became readable");
+ is(scalar @readable, 1, "only one backend became readable after mg");
my $be = shift @readable;
is(scalar <$be>, $cmd, "metaget passthrough");
print $be "EN\r\n";
@@ -133,7 +133,7 @@ my $keycount = 100;
for my $key (0 .. $keycount) {
print $ps "mg /test/$key\r\n";
my @readable = $s->can_read(0.25);
- is(scalar @readable, 1, "only one backend became readable");
+ is(scalar @readable, 1, "only one backend became readable for this key");
my $be = shift @readable;
for (0 .. 2) {
if ($be == $mbe[$_]) {
@@ -154,9 +154,8 @@ my @holdbe = (); # avoid having the backends immediately disconnect and pollute
$p_srv->reload();
wait_reload($watcher);
- # sleep a short time; b1 should have a very short timeout and the
- # others are long.
- select(undef, undef, undef, 0.5);
+ my $watch_s = IO::Select->new();
+ $watch_s->add($watcher);
my $s = IO::Select->new();
for my $msrv (@mocksrvs) {
@@ -167,6 +166,8 @@ my @holdbe = (); # avoid having the backends immediately disconnect and pollute
# host, and port arguments.
is(scalar @readable, 3, "all listeners became readable");
+ my @watchable = $watch_s->can_read(5);
+ is(scalar @watchable, 1, "got new watcher log lines");
like(<$watcher>, qr/ts=(\S+) gid=\d+ type=proxy_backend error=conntimeout name=\S+ port=11511/, "one backend timed out connecting");
like(<$watcher>, qr/ts=(\S+) gid=\d+ type=proxy_backend error=markedbad name=\S+ port=11511/, "backend was marked bad");