| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CHI::Driver::Memcached::t::CHIDriverTests::Base; |
|
2
|
|
|
|
|
|
|
$CHI::Driver::Memcached::t::CHIDriverTests::Base::VERSION = '0.16'; |
|
3
|
3
|
|
|
3
|
|
17
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
88
|
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
77
|
|
|
5
|
3
|
|
|
3
|
|
5754
|
use CHI::Test; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use base qw(CHI::t::Driver); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->SKIP_CLASS("abstract base class"); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $testaddr = "127.0.0.1:11211"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub required_modules { |
|
13
|
|
|
|
|
|
|
my $class = shift; |
|
14
|
|
|
|
|
|
|
return { |
|
15
|
|
|
|
|
|
|
$class->testing_driver_class => undef, |
|
16
|
|
|
|
|
|
|
$class->memcached_class => undef, |
|
17
|
|
|
|
|
|
|
'IO::Socket::INET' => undef |
|
18
|
|
|
|
|
|
|
}; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub supports_get_namespaces { 0 } |
|
22
|
|
|
|
|
|
|
sub supports_expires_on_backend { 1 } |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub connect_to_memcached : Test(startup) { |
|
25
|
|
|
|
|
|
|
my $self = shift; |
|
26
|
|
|
|
|
|
|
require IO::Socket::INET; |
|
27
|
|
|
|
|
|
|
my $msock = IO::Socket::INET->new( |
|
28
|
|
|
|
|
|
|
PeerAddr => $testaddr, |
|
29
|
|
|
|
|
|
|
Timeout => 3 |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
if ( !$msock ) { |
|
32
|
|
|
|
|
|
|
$self->SKIP_ALL("No memcached instance running at $testaddr"); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub clear_memcached : Test(setup) { |
|
37
|
|
|
|
|
|
|
my ($self) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $cache = $self->new_cache(); |
|
40
|
|
|
|
|
|
|
$cache->memd->flush_all(); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new_cache_options { |
|
44
|
|
|
|
|
|
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# CHI::Driver::Memcached::Test::Driver defines get_keys for testing purposes |
|
47
|
|
|
|
|
|
|
return ( |
|
48
|
|
|
|
|
|
|
$self->SUPER::new_cache_options(), |
|
49
|
|
|
|
|
|
|
driver => undef, |
|
50
|
|
|
|
|
|
|
driver_class => $self->test_driver_class(), |
|
51
|
|
|
|
|
|
|
servers => [$testaddr] |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub set_standard_keys_and_values { |
|
56
|
|
|
|
|
|
|
my ($self) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my ( $keys, $values ) = $self->SUPER::set_standard_keys_and_values(); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# memcached keys have max length of 250, plus we're adding namespace |
|
61
|
|
|
|
|
|
|
$keys->{'large'} = scalar( 'ab' x 100 ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# memcached keys must not include control characters or whitespace |
|
64
|
|
|
|
|
|
|
foreach my $key (qw(space mixed binary newline arrayref hashref utf8)) { |
|
65
|
|
|
|
|
|
|
$keys->{$key} = $key if defined( $keys->{$key} ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return ( $keys, $values ); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# TODO - Not working right now - fix later |
|
72
|
|
|
|
|
|
|
sub test_size_awareness_with_subcaches { } |
|
73
|
|
|
|
|
|
|
sub test_max_size_with_l1_cache { } |
|
74
|
|
|
|
|
|
|
sub test_encode { } |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub test_get_keys : Test(1) { |
|
77
|
|
|
|
|
|
|
my $self = shift; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Make sure we get a 'not supported' error with regular memcached driver |
|
80
|
|
|
|
|
|
|
my $cache = $self->SUPER::new_cache( |
|
81
|
|
|
|
|
|
|
driver_class => $self->testing_driver_class(), |
|
82
|
|
|
|
|
|
|
servers => [$testaddr] |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
throws_ok( |
|
85
|
|
|
|
|
|
|
sub { $cache->get_keys() }, |
|
86
|
|
|
|
|
|
|
qr/not supported/, |
|
87
|
|
|
|
|
|
|
"get_keys not supported" |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub test_namespaces : Test(1) { |
|
92
|
|
|
|
|
|
|
my $self = shift; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Make sure we get a 'not supported' error with regular memcached driver |
|
95
|
|
|
|
|
|
|
my $cache = $self->SUPER::new_cache( |
|
96
|
|
|
|
|
|
|
driver_class => $self->testing_driver_class(), |
|
97
|
|
|
|
|
|
|
servers => [$testaddr] |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
throws_ok( |
|
100
|
|
|
|
|
|
|
sub { $cache->get_namespaces() }, |
|
101
|
|
|
|
|
|
|
qr/not supported/, |
|
102
|
|
|
|
|
|
|
"get_keys not supported" |
|
103
|
|
|
|
|
|
|
); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |