diff options
author | Kevin Lin <developer@kevinlin.info> | 2020-11-16 15:26:49 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-11-20 12:30:33 -0800 |
commit | 1332f52df4dc9084325d348ac12a8fdc44811d17 (patch) | |
tree | 70ee6328088a4a42fdf3df736d000d1ff867854a /t | |
parent | 2d118d43d4607d86f2312f0dd44815833da39a59 (diff) | |
download | memcached-1332f52df4dc9084325d348ac12a8fdc44811d17.tar.gz |
'shutdown graceful' command for raising SIGUSR1
Diffstat (limited to 't')
-rw-r--r-- | t/shutdown.t | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/t/shutdown.t b/t/shutdown.t new file mode 100644 index 0000000..6dfbd77 --- /dev/null +++ b/t/shutdown.t @@ -0,0 +1,49 @@ +#!/usr/bin/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"; + print $sock "version\r\n"; + is(scalar <$sock>, undef, "server has been normally shut down"); +} + +# 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"; + print $sock "version\r\n"; + is(scalar <$sock>, undef, "server has been gracefully shut down"); +} + +done_testing(); |