| 1 | use strictscip-perl cpan Redis-Fast 0.37 strict/; |
| 2 | use warningsscip-perl cpan Redis-Fast 0.37 warnings/; |
| 3 | use Test::Morescip-perl cpan Redis-Fast 0.37 Test/More/; |
| 4 | use Redis::Fastscip-perl cpan Redis-Fast 0.37 Redis/Fast/; |
| 5 | use libscip-perl cpan Redis-Fast 0.37 lib/ 't/tlib'; |
| 6 | use Test::SpawnRedisServerscip-perl cpan Redis-Fast 0.37 Test/SpawnRedisServer/; |
| 7 | use Test::SharedForkscip-perl cpan Redis-Fast 0.37 Test/SharedFork/; |
| 8 | use Socketscip-perl cpan Redis-Fast 0.37 Socket/; |
| 9 | |
| 10 | use constantscip-perl cpan Redis-Fast 0.37 constant/ SSL_AVAILABLEscip-perl cpan Redis-Fast 0.37 main/SSL_AVAILABLE(). => eval { requirescip-perl cpan Redis-Fast 0.37 main/require(). IO::Socket::SSL }; |
| 11 | |
| 12 | my ($c, $t, $srv) = redisscip-perl cpan Redis-Fast 0.37 main/redis().(); |
| 13 | my $use_ssl = $t ? SSL_AVAILABLE : 0; |
| 14 | |
| 15 | END { |
| 16 | $c->()scip-perl cpan Redis-Fast 0.37 main/`->()`(). if $c; |
| 17 | $t->()scip-perl cpan Redis-Fast 0.37 main/`->()`(). if $t; |
| 18 | } |
| 19 | |
| 20 | use Test::LeakTracescip-perl cpan Redis-Fast 0.37 Test/LeakTrace/; |
| 21 | |
| 22 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 23 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 24 | } 'Redis::Fast->new'; |
| 25 | |
| 26 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 27 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 28 | my $res; |
| 29 | $r->setscip-perl cpan Redis-Fast 0.37 Redis/Fast/set().('hogehoge', 'fugafuga'); |
| 30 | $res = $r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('hogehoge'); |
| 31 | $r->flushdbscip-perl cpan Redis-Fast 0.37 Redis/Fast/flushdb().; |
| 32 | } 'sync get/set'; |
| 33 | |
| 34 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 35 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 36 | my $res; |
| 37 | $r->setscip-perl cpan Redis-Fast 0.37 Redis/Fast/set().('hogehoge', 'fugafuga', sub { }); |
| 38 | $r->getscip-perl cpan Redis-Fast 0.37 Redis/Fast/get().('hogehoge', sub { $res = shiftscip-perl cpan Redis-Fast 0.37 main/shift(). }); |
| 39 | $r->wait_all_responsesscip-perl cpan Redis-Fast 0.37 Redis/Fast/wait_all_responses().; |
| 40 | $r->flushdbscip-perl cpan Redis-Fast 0.37 Redis/Fast/flushdb().; |
| 41 | } 'async get/set'; |
| 42 | |
| 43 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 44 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 45 | my $res; |
| 46 | $r->rpushscip-perl cpan Redis-Fast 0.37 Redis/Fast/rpush().('hogehoge', 'fugafuga') for (1..3); |
| 47 | $res = $r->lrangescip-perl cpan Redis-Fast 0.37 Redis/Fast/lrange().('hogehoge', 0, -1); |
| 48 | $r->flushdbscip-perl cpan Redis-Fast 0.37 Redis/Fast/flushdb().; |
| 49 | } 'sync list operation'; |
| 50 | |
| 51 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 52 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 53 | my $res; |
| 54 | $r->rpushscip-perl cpan Redis-Fast 0.37 Redis/Fast/rpush().('hogehoge', 'fugafuga') for (1..3); |
| 55 | $r->lrangescip-perl cpan Redis-Fast 0.37 Redis/Fast/lrange().('hogehoge', 0, -1, sub { $res = shiftscip-perl cpan Redis-Fast 0.37 main/shift(). }); |
| 56 | $r->wait_all_responsesscip-perl cpan Redis-Fast 0.37 Redis/Fast/wait_all_responses().; |
| 57 | $r->flushdbscip-perl cpan Redis-Fast 0.37 Redis/Fast/flushdb().; |
| 58 | } 'async list operation'; |
| 59 | |
| 60 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 61 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 62 | my $cb = sub {}; |
| 63 | $r->subscribescip-perl cpan Redis-Fast 0.37 Redis/Fast/subscribe().('hogehoge', $cb); |
| 64 | $r->wait_for_messagesscip-perl cpan Redis-Fast 0.37 Redis/Fast/wait_for_messages().(0); |
| 65 | $r->unsubscribescip-perl cpan Redis-Fast 0.37 Redis/Fast/unsubscribe().('hogehoge', $cb); |
| 66 | } 'unsubscribe'; |
| 67 | |
| 68 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 69 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().( |
| 70 | server => $srv, |
| 71 | reconnect => 1, |
| 72 | reconnect_on_error => sub { |
| 73 | my $force_reconnect = 1; |
| 74 | return $force_reconnect; |
| 75 | }, |
| 76 | ssl => $use_ssl, |
| 77 | SSL_verify_mode => 0, |
| 78 | ); |
| 79 | eval { $r->hsetscip-perl cpan Redis-Fast 0.37 Redis/Fast/hset().(1,1) }; |
| 80 | } 'sync reconnect_on_error'; |
| 81 | |
| 82 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 83 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().( |
| 84 | server => $srv, |
| 85 | reconnect => 1, |
| 86 | reconnect_on_error => sub { |
| 87 | my $force_reconnect = 1; |
| 88 | return $force_reconnect; |
| 89 | }, |
| 90 | ssl => $use_ssl, |
| 91 | SSL_verify_mode => 0, |
| 92 | ); |
| 93 | my $cb = sub {}; |
| 94 | $r->hsetscip-perl cpan Redis-Fast 0.37 Redis/Fast/hset().(1,1,$cb); |
| 95 | $r->hsetscip-perl cpan Redis-Fast 0.37 Redis/Fast/hset().(2,2,$cb); |
| 96 | eval { $r->wait_all_responsesscip-perl cpan Redis-Fast 0.37 Redis/Fast/wait_all_responses(). }; |
| 97 | } 'async reconnect_on_error'; |
| 98 | |
| 99 | no_leaks_okscip-perl cpan Redis-Fast 0.37 main/no_leaks_ok(). { |
| 100 | my $r = Redis::Fast->newscip-perl cpan Redis-Fast 0.37 Redis/Fast/new().(server => $srv, ssl => $use_ssl, SSL_verify_mode => 0); |
| 101 | $r->infoscip-perl cpan Redis-Fast 0.37 Redis/Fast/info().(); |
| 102 | } 'info'; |
| 103 | |
| 104 | done_testing; |