forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshutdown.t
61 lines (53 loc) · 1.33 KB
/
shutdown.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;
# Disabled shutdown (default)
{
my $server = new_memcached();
my $sock = $server->sock;
print $sock "shutdown\r\n";
is(scalar <$sock>, "ERROR: shutdown not enabled\r\n",
"error when shutdown is not enabled");
}
# Shutdown command error
{
my$server = new_memcached("-A");
my $sock = $server->sock;
print $sock "shutdown foo\r\n";
like(scalar <$sock>, qr/CLIENT_ERROR/, "rejected invalid shutdown mode");
}
# Normal shutdown
{
my $server = new_memcached("-A");
my $sock = $server->sock;
print $sock "version\r\n";
like(scalar <$sock>, qr/VERSION/, "server is initially alive");
print $sock "shutdown\r\n";
still_going($server);
}
# Graceful shutdown
{
my $server = new_memcached("-A");
my $sock = $server->sock;
print $sock "version\r\n";
like(scalar <$sock>, qr/VERSION/, "server is initially alive");
print $sock "shutdown graceful\r\n";
still_going($server);
}
sub still_going {
my $server = shift;
for (1..10) {
if ($server->is_running) {
sleep 1;
} else {
ok(!$server->is_running, "server stopped");
return;
}
}
ok(0, "server failed to stop");
}
done_testing();