"Fossies" - the Fresh Open Source Software Archive 
Member "memcached-1.6.15/t/shutdown.t" (21 Feb 2022, 1356 Bytes) of package /linux/www/memcached-1.6.15.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use FindBin qw($Bin);
7 use lib "$Bin/lib";
8 use MemcachedTest;
9
10 # Disabled shutdown (default)
11 {
12 my $server = new_memcached();
13 my $sock = $server->sock;
14 print $sock "shutdown\r\n";
15 is(scalar <$sock>, "ERROR: shutdown not enabled\r\n",
16 "error when shutdown is not enabled");
17 }
18
19 # Shutdown command error
20 {
21 my$server = new_memcached("-A");
22 my $sock = $server->sock;
23 print $sock "shutdown foo\r\n";
24 like(scalar <$sock>, qr/CLIENT_ERROR/, "rejected invalid shutdown mode");
25 }
26
27 # Normal shutdown
28 {
29 my $server = new_memcached("-A");
30 my $sock = $server->sock;
31 print $sock "version\r\n";
32 like(scalar <$sock>, qr/VERSION/, "server is initially alive");
33 print $sock "shutdown\r\n";
34 still_going($server);
35 }
36
37 # Graceful shutdown
38 {
39 my $server = new_memcached("-A");
40 my $sock = $server->sock;
41 print $sock "version\r\n";
42 like(scalar <$sock>, qr/VERSION/, "server is initially alive");
43 print $sock "shutdown graceful\r\n";
44 still_going($server);
45 }
46
47 sub still_going {
48 my $server = shift;
49 for (1..10) {
50 if ($server->is_running) {
51 sleep 1;
52 } else {
53 ok(!$server->is_running, "server stopped");
54 return;
55 }
56 }
57
58 ok(0, "server failed to stop");
59 }
60
61 done_testing();