line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Couchbase::Test::Interop; |
2
|
2
|
|
|
2
|
|
1474
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
68
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
10
|
use base qw(Couchbase::Test::Common); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
172
|
|
5
|
2
|
|
|
2
|
|
8
|
use Test::More; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
6
|
2
|
|
|
2
|
|
560
|
use Couchbase::Client::Errors; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
260
|
|
7
|
2
|
|
|
2
|
|
12
|
use Data::Dumper; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
142
|
|
8
|
|
|
|
|
|
|
Log::Fu::set_log_level('Couchbase::Config', 'info'); |
9
|
|
|
|
|
|
|
use Class::XSAccessor { |
10
|
2
|
|
|
|
|
20
|
accessors => [qw(cbo memd)] |
11
|
2
|
|
|
2
|
|
12
|
}; |
|
2
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $MEMD_CLASS; |
14
|
|
|
|
|
|
|
my $have_memcached = |
15
|
|
|
|
|
|
|
eval { |
16
|
|
|
|
|
|
|
require Cache::Memcached::libmemcached; |
17
|
|
|
|
|
|
|
$MEMD_CLASS = "Cache::Memcached::libmemcached"; |
18
|
|
|
|
|
|
|
}; if ($@) { |
19
|
|
|
|
|
|
|
diag "Memcached interop tests will not be available: $@"; |
20
|
|
|
|
|
|
|
__PACKAGE__->SKIP_CLASS("Need Cache::Memcached::libmemcached"); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if($] < 5.010) { |
24
|
|
|
|
|
|
|
__PACKAGE__->SKIP_CLASS("Cache::Memcached::libmemcached ". |
25
|
|
|
|
|
|
|
"segfaults on perls < 5.10"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
eval { |
29
|
|
|
|
|
|
|
require Couchbase::Config::UA; 1; |
30
|
|
|
|
|
|
|
} or __PACKAGE__->SKIP_CLASS( |
31
|
|
|
|
|
|
|
"Need Couchbase::Config for interop tests\n$@"); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _setup_client :Test(startup) { |
35
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
36
|
0
|
|
|
|
|
0
|
$self->mock_init(); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $server = $self->common_options->{server}; |
39
|
0
|
|
|
|
|
0
|
my $username = $self->common_options->{username}; |
40
|
0
|
|
|
|
|
0
|
my $password = $self->common_options->{password}; |
41
|
0
|
|
|
|
|
0
|
my $bucket_name = $self->common_options->{bucket}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $cbo = Couchbase::Client->new({ |
44
|
0
|
|
|
|
|
0
|
%{$self->common_options} |
45
|
|
|
|
|
|
|
}); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
$self->cbo($cbo); |
48
|
0
|
0
|
|
|
|
0
|
unless($self->fetch_config()) { |
49
|
0
|
|
|
|
|
0
|
diag "Skipping Cache::Memcached interop tests"; |
50
|
0
|
|
|
|
|
0
|
$self->SKIP_CLASS("Couldn't fetch buckets"); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
my $buckets = $self->res_buckets(); |
54
|
0
|
0
|
0
|
|
|
0
|
my $bucket = (grep { |
55
|
0
|
|
|
|
|
0
|
$_->name eq $bucket_name && |
56
|
|
|
|
|
|
|
$_->port_proxy || $_->type eq 'memcached' |
57
|
|
|
|
|
|
|
} @$buckets)[0]; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
0
|
if(!$bucket) { |
60
|
0
|
|
|
|
|
0
|
my $msg = |
61
|
|
|
|
|
|
|
"Couldn't find appropriate bucket. Bucket must have an auth-less proxy ". |
62
|
|
|
|
|
|
|
"port, and/or be of memcached type"; |
63
|
0
|
|
|
|
|
0
|
die $msg; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
#print Dumper($bucket); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
my $node = $bucket->nodes->[0]; |
68
|
0
|
|
0
|
|
|
0
|
my $memd_host = sprintf("%s:%d", |
69
|
|
|
|
|
|
|
$node->base_addr, |
70
|
|
|
|
|
|
|
$bucket->port_proxy || |
71
|
|
|
|
|
|
|
$node->port_proxy || |
72
|
|
|
|
|
|
|
$node->port_direct); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
note "Have $memd_host"; |
76
|
0
|
|
|
|
|
0
|
my $memd = $MEMD_CLASS->new({servers => [ $memd_host] , |
77
|
|
|
|
|
|
|
compress_threshold => 100, |
78
|
|
|
|
|
|
|
}); |
79
|
0
|
|
|
|
|
0
|
$self->memd($memd); |
80
|
0
|
0
|
|
|
|
0
|
if($memd->can('set_binary_protocol')) { |
81
|
0
|
|
|
|
|
0
|
$memd->set_binary_protocol(1); |
82
|
|
|
|
|
|
|
} |
83
|
2
|
|
|
2
|
|
1554
|
} |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
16
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub T30_interop_init :Test(no_plan) |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
88
|
0
|
|
|
|
|
0
|
my $memd = $self->memd(); |
89
|
0
|
|
|
|
|
0
|
foreach my $key (qw(foo bar baz)) { |
90
|
0
|
|
|
|
|
0
|
my $value = scalar reverse($key); |
91
|
0
|
|
|
|
|
0
|
ok($memd->set($key, $value), "Set value OK"); |
92
|
0
|
|
|
|
|
0
|
is($memd->get($key), $value, "Got back our value"); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
my $ret = $self->cbo->get($key); |
95
|
0
|
|
|
|
|
0
|
ok($ret->is_ok, "Found value for memcached key"); |
96
|
0
|
|
|
|
|
0
|
is($ret->value, $value, "Got back same value"); |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
ok($self->cbo->set($key,$value)->is_ok, "set via cbc"); |
99
|
0
|
|
|
|
|
0
|
is($memd->get($key), $value, "get via memd"); |
100
|
|
|
|
|
|
|
} |
101
|
2
|
|
|
2
|
|
974
|
} |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
12
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub T31_interop_serialization :Test(no_plan) { |
104
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
105
|
0
|
|
|
|
|
0
|
my $key = "Serialized"; |
106
|
0
|
|
|
|
|
0
|
my $value = [ qw(foo bar baz), { "this is" => "a hash" } ]; |
107
|
0
|
|
|
|
|
0
|
my $memd = $self->memd(); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
ok($memd->set($key, $value), "Set serialized structure"); |
110
|
0
|
|
|
|
|
0
|
my $ret; |
111
|
0
|
|
|
|
|
0
|
$ret = $self->cbo->get($key); |
112
|
0
|
|
|
|
|
0
|
ok($ret->is_ok, "Got ok result"); |
113
|
0
|
|
|
|
|
0
|
is_deeply($ret->value, $value, "Compared identical perl structures"); |
114
|
0
|
|
|
|
|
0
|
is_deeply($memd->get($key), $ret->value,"even deeper comparison"); |
115
|
2
|
|
|
2
|
|
764
|
} |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
10
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub T32_interop_compression :Test(no_plan) { |
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
119
|
0
|
|
|
|
|
|
my $key = "Compressed"; |
120
|
0
|
|
|
|
|
|
my $value = "foobarbaz" x 1000; |
121
|
|
|
|
|
|
|
#return; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$self->memd->set_compress_threshold(100); |
124
|
0
|
|
|
|
|
|
$self->memd->set_compress_enable(1); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
diag "Hacking into unexposed Cache::Memcached::libmemcached methods"; |
127
|
0
|
|
|
|
|
|
$self->memd->{compress_savingsS} = 500; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
ok($self->memd->get_compress_enable, "Compression is enabled via memd"); |
130
|
0
|
|
|
|
|
|
ok($self->memd->get_compress_threshold < length($value), |
131
|
|
|
|
|
|
|
"compression threshold is set to
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
ok($self->memd->set($key, $value), "Set compressed value via memd"); |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
ok($self->cbo->deconversion_settings, "Deconversion enabled"); |
137
|
0
|
|
|
|
|
|
$self->cbo->deconversion_settings(0); |
138
|
0
|
|
|
|
|
|
ok(!$self->cbo->deconversion_settings, "Deconversion now disabled"); |
139
|
0
|
|
|
|
|
|
$self->cbo->enable_compress(0); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
my $ret = $self->cbo->get($key); |
143
|
0
|
|
|
|
|
|
ok($ret->is_ok, "Got value via cbo"); |
144
|
|
|
|
|
|
|
#diag $ret->value; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
ok(length($ret->value) != length($value), |
147
|
|
|
|
|
|
|
"got compressed value (comp_len < real_len)"); |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
$self->cbo->deconversion_settings(1); |
150
|
0
|
|
|
|
|
|
$self->cbo->enable_compress(1); |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$ret = $self->cbo->get($key); |
153
|
0
|
|
|
|
|
|
ok($ret->is_ok, "Re-got value via cbo"); |
154
|
0
|
0
|
|
|
|
|
if(!$ret->is_ok) { |
155
|
0
|
|
|
|
|
|
diag("ERR ", $ret->errstr); |
156
|
0
|
|
|
|
|
|
return; |
157
|
|
|
|
|
|
|
} |
158
|
0
|
|
|
|
|
|
is($ret->value, $value, "Decompressed to same value"); |
159
|
2
|
|
|
2
|
|
1230
|
} |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |