| 1 | package Test::Data::Riak::Fast; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 17 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use Test::More; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 17 | ▶ | use Digest::MD5 qw/md5_hex/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 17 | ▶ | use Sub::Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 17 | ▶ | use Data::Riak::Fast::HTTP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 17 | my @exports = qw[ | |||||||||||||||||||||||||||
| 15 | skip_unless_riak | ||||||||||||||||||||||||||||
| 16 | skip_unless_leveldb | ||||||||||||||||||||||||||||
| 17 | remove_test_bucket | ||||||||||||||||||||||||||||
| 18 | create_test_bucket_name | ||||||||||||||||||||||||||||
| 19 | ]; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 17 | Sub::Exporter::setup_exporter({ | |||||||||||||||||||||||||||
| 22 | exports => \@exports, | ||||||||||||||||||||||||||||
| 23 | groups => { default => \@exports } | ||||||||||||||||||||||||||||
| 24 | }); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub create_test_bucket_name { | ||||||||||||||||||||||||||
|
Subroutine
create_test_bucket_name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $prefix = shift || 'data-riak-test'; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'data-riak-test'
MC/DC0%0/1
shift() || 'data-riak-test'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 28 | 0 | return $prefix . '-' . md5_hex(scalar localtime) | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 17 | ▶ | sub skip_unless_riak { | ||||||||||||||||||||||||||
|
Subroutine
skip_unless_riak: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 17 | my $up = Data::Riak::Fast::HTTP->new->ping; | |||||||||||||||||||||||||||
| 33 | 17 | ▶ | unless($up) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 17 | plan skip_all => 'Riak did not answer, skipping tests' | |||||||||||||||||||||||||||
| 35 | }; | ||||||||||||||||||||||||||||
| 36 | 0 | return $up; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub skip_unless_leveldb { | ||||||||||||||||||||||||||
|
Subroutine
skip_unless_leveldb: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $storage_backend = Data::Riak::Fast->new(transport => Data::Riak::Fast::HTTP->new)->stats->{storage_backend}; | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ($storage_backend ne 'riak_kv_eleveldb_backend') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | plan skip_all => 'Only storage_backend => riak_kv_eleveldb_backend' | |||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||
| 44 | 0 | return $storage_backend; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub remove_test_bucket { | ||||||||||||||||||||||||||
|
Subroutine
remove_test_bucket: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | 0 | my $bucket = shift; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 51 | 0 | $bucket->remove_all; | |||||||||||||||||||||||||||
| 52 | 0 | Test::More::diag "Removing test bucket so sleeping for a moment to allow riak to eventually be consistent ..."; | |||||||||||||||||||||||||||
| 53 | 0 | my $keys = $bucket->list_keys; | |||||||||||||||||||||||||||
| 54 | 0 | ▶ | while ( $keys && @$keys ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$keys and @$keys
MC/DC0%0/2
$keys and @$keys
$keys
@$keys
Truth table0%0/3
A and B
A= $keysB= @$keys
| |||||||||||||||||||||||||||||
| 55 | 0 | sleep(1); | |||||||||||||||||||||||||||
| 56 | 0 | $keys = $bucket->list_keys; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 59 | 0 | is($_->value, "not found\n", "Bucket is now empty"); | |||||||||||||||||||||||||||
| 60 | 0 | is($_->code, "404", "Calling list_keys on an empty bucket gives a 404"); | |||||||||||||||||||||||||||
| 61 | 0 | }; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||