summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2021-11-03 12:19:45 -0700
committerdormando <dormando@rydia.net>2021-11-03 12:19:45 -0700
commitbe9a421fb1b217ca844777a75009645df7265e02 (patch)
tree9ac7414bdc3e3da5a1420f18b33cccdee45d1af3
parent7e570c789f4473354461e6eeb8bb7a283df613bf (diff)
downloadmemcached-be9a421fb1b217ca844777a75009645df7265e02.tar.gz
tests: maxconns test when extstore enabled
seems to pass...
-rwxr-xr-xt/maxconns.t66
1 files changed, 42 insertions, 24 deletions
diff --git a/t/maxconns.t b/t/maxconns.t
index 88bbd65..020d7d1 100755
--- a/t/maxconns.t
+++ b/t/maxconns.t
@@ -9,33 +9,51 @@ use lib "$Bin/lib";
use MemcachedTest;
my $server = new_memcached();
+test_maxconns($server);
-my $stat_sock = $server->sock;
-my @sockets = ();
-my $num_sockets;
-my $rejected_conns = 0;
-my $stats;
-for (1 .. 1024) {
- my $sock = $server->new_sock;
- if (defined($sock)) {
- push(@sockets, $sock);
- $stats = mem_stats($stat_sock);
- if ($stats->{rejected_connections} > $rejected_conns) {
- $rejected_conns = $stats->{rejected_connections};
- my $buffer = "";
- my $length = 31;
- my $res = recv($sock, $buffer, $length, 0);
- if (not $buffer eq '') {
- is($buffer, "ERROR Too many open connections", "Got expected response from the server");
+my $ext_path;
+if (supports_extstore()) {
+ $ext_path = "/tmp/extstore.$$";
+
+ my $server = new_memcached("-m 64 -U 0 -o ext_path=$ext_path:64m");
+ test_maxconns($server);
+}
+
+sub test_maxconns {
+ my $server = shift;
+
+ my $stat_sock = $server->sock;
+ my @sockets = ();
+ my $num_sockets;
+ my $rejected_conns = 0;
+ my $stats;
+ for (1 .. 1024) {
+ my $sock = $server->new_sock;
+ if (defined($sock)) {
+ push(@sockets, $sock);
+ $stats = mem_stats($stat_sock);
+ if ($stats->{rejected_connections} > $rejected_conns) {
+ $rejected_conns = $stats->{rejected_connections};
+ my $buffer = "";
+ my $length = 31;
+ my $res = recv($sock, $buffer, $length, 0);
+ if (not $buffer eq '') {
+ is($buffer, "ERROR Too many open connections", "Got expected response from the server");
+ }
+ }
}
}
- }
-}
-for my $s (@sockets) {
- $s->close();
+ for my $s (@sockets) {
+ $s->close();
+ }
+ cmp_ok($stats->{rejected_connections}, '>', '1', 'rejected connections recorded');
+ $server->stop;
+ $stat_sock->close();
}
-cmp_ok($stats->{rejected_connections}, '>', '1', 'rejected connections recorded');
-$server->stop;
-$stat_sock->close();
+
done_testing();
+
+END {
+ unlink $ext_path if $ext_path;
+}