diff options
author | minkikim89 <minkikim89@gmail.com> | 2020-12-27 15:33:15 +0900 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2021-06-07 21:54:21 -0700 |
commit | 5ad7a83a77c36a6a57d856c0296af45897896753 (patch) | |
tree | 365cc9ba140a28fe3924937bbe7a17afa0eaa46d | |
parent | 02305885e3d9d82fb1cd00a5869ce1fb49cfb62a (diff) | |
download | memcached-5ad7a83a77c36a6a57d856c0296af45897896753.tar.gz |
Fix expiration test to use debugtime command
-rw-r--r-- | proto_text.c | 4 | ||||
-rwxr-xr-x | t/expirations.t | 11 | ||||
-rw-r--r-- | t/lib/MemcachedTest.pm | 9 |
3 files changed, 13 insertions, 11 deletions
diff --git a/proto_text.c b/proto_text.c index f173020..d060b17 100644 --- a/proto_text.c +++ b/proto_text.c @@ -2069,15 +2069,11 @@ static void process_misbehave_command(conn *c) { } static void process_debugtime_command(conn *c, token_t *tokens, const size_t ntokens) { - struct timeval tv; - if (strcmp(tokens[1].value, "p") == 0) { - gettimeofday(&tv, NULL); if (!is_paused) { is_paused = true; } } else if (strcmp(tokens[1].value, "r") == 0) { - gettimeofday(&tv, NULL); if (is_paused) { is_paused = false; } diff --git a/t/expirations.t b/t/expirations.t index 82b07ca..f796bd1 100755 --- a/t/expirations.t +++ b/t/expirations.t @@ -33,7 +33,7 @@ print $sock "set foo 0 3 6\r\nfooval\r\n"; is(scalar <$sock>, "STORED\r\n", "stored foo"); mem_get_is($sock, "foo", "fooval"); -sleep(4); +mem_move_time($sock, 3); mem_get_is($sock, "foo", undef); $expire = time() - 1; @@ -41,12 +41,11 @@ print $sock "set foo 0 $expire 6\r\nfooval\r\n"; is(scalar <$sock>, "STORED\r\n", "stored foo"); mem_get_is($sock, "foo", undef, "already expired"); -# TODO: These suck. We really need a time travel command like 1.5 had. $expire = time() + 4; print $sock "set foo 0 $expire 6\r\nfoov+1\r\n"; is(scalar <$sock>, "STORED\r\n", "stored foo"); mem_get_is($sock, "foo", "foov+1"); -sleep(8); +mem_move_time($sock, 4); mem_get_is($sock, "foo", undef, "now expired"); $expire = time() - 20; @@ -65,7 +64,7 @@ mem_get_is($sock, "add", "addval"); print $sock "add add 0 2 7\r\naddval2\r\n"; is(scalar <$sock>, "NOT_STORED\r\n", "add failure"); -sleep(5); +mem_move_time($sock, 2); print $sock "add add 0 2 7\r\naddval3\r\n"; is(scalar <$sock>, "STORED\r\n", "stored add again"); @@ -86,7 +85,7 @@ is(scalar <$sock>, "STORED\r\n", "stored tch"); $expire = time() + 1; print $sock "touch tch $expire\r\n"; is(scalar <$sock>, "TOUCHED\r\n", "touched tch"); -sleep(3); +mem_move_time($sock, 1); mem_get_is($sock, "touch", undef, "now expired"); print $sock "set tch 0 0 8\r\ntouchval\r\n"; @@ -116,7 +115,7 @@ print $sock "gat $expire gat\r\n"; is(scalar <$sock>, "VALUE gat 0 6\r\n","get and touch gat"); is(scalar <$sock>, "gatval\r\n","value"); is(scalar <$sock>, "END\r\n", "end"); -sleep(3); +mem_move_time($sock, 1); mem_get_is($sock, "gat", undef, "now expired"); diff --git a/t/lib/MemcachedTest.pm b/t/lib/MemcachedTest.pm index b39271d..2a0fcb7 100644 --- a/t/lib/MemcachedTest.pm +++ b/t/lib/MemcachedTest.pm @@ -14,7 +14,8 @@ my $builddir = getcwd; my @unixsockets = (); -@EXPORT = qw(new_memcached sleep mem_get_is mem_gets mem_gets_is mem_stats +@EXPORT = qw(new_memcached sleep + mem_get_is mem_gets mem_gets_is mem_stats mem_move_time supports_sasl free_port supports_drop_priv supports_extstore wait_ext_flush supports_tls enabled_tls_testing run_help supports_unix_socket); @@ -72,6 +73,12 @@ sub mem_stats { return $stats; } +sub mem_move_time { + my ($sock, $move) = @_; + print $sock "debugtime $move\r\n"; + <$sock>; +} + sub mem_get_is { # works on single-line values only. no newlines in value. my ($sock_opts, $key, $val, $msg) = @_; |