Changeset 18451
- Timestamp:
- Jul 9, 2008, 1:32:35 PM (18 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 6 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Keys.pm (modified) (4 diffs)
-
lib/Nebulous/Server.pm (modified) (28 diffs)
-
t/07_server_find_instances.t (modified) (3 diffs)
-
t/14_server_xattr.t (modified) (2 diffs)
-
t/75_parse_neb_key.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r18434 r18451 2 2 3 3 0.13 4 - create a Nebulous::Keys object to represent a parsed neb key and 5 impliment other changes to abstract out the handling of keys in order to 6 support "soft" volume requests and the "any" volume 4 7 - change find_objects_with_unavailable_instances query to only count 5 8 volumes marked as 'available' -
trunk/Nebulous-Server/lib/Nebulous/Keys.pm
r17072 r18451 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Keys.pm,v 1. 1 2008-03-20 21:13:28jhoblitt Exp $3 # $Id: Keys.pm,v 1.2 2008-07-09 23:32:35 jhoblitt Exp $ 4 4 5 5 package Nebulous::Keys; … … 10 10 our $VERSION = '0.01'; 11 11 12 use base qw( Exporter );13 14 use File::Spec ::Functions;12 use base qw( Exporter Class::Accessor::Fast ); 13 14 use File::Spec; 15 15 use URI::file; 16 16 use URI; 17 18 our @EXPORT_OK = qw( parse_neb_key ); 17 use overload '""' => \&_stringify_key; 18 19 our @EXPORT_OK = qw( 20 parse_neb_key 21 parse_neb_volume 22 ); 23 24 __PACKAGE__->mk_ro_accessors(qw( path volume soft_volume )); 19 25 20 26 sub parse_neb_key 21 27 { 22 my $text = shift;23 return unless defined $ text;28 my ($key, $volume) = @_; 29 return unless defined $key; 24 30 25 31 # white space is not allowed 26 if ($ text=~ qr/\s+/) {32 if ($key =~ qr/\s+/) { 27 33 die "keys and URIs may not contain whitespace"; 28 34 } 29 35 30 my $uri = URI->new($ text);36 my $uri = URI->new($key); 31 37 my $scheme = $uri->scheme; 32 38 my $path = $uri->opaque; 33 39 34 my $volume; 40 my $volume_name; 41 my $soft_volume; 35 42 # if this is a valid uri 36 43 if (defined $scheme) { … … 47 54 # strip off volume component if it exists 48 55 $path =~ s|^//([^/]+)||; 49 $volume = $1; 56 57 # ignore key supplied volume name if one is passed as a parameter 58 $volume ||= $1; 59 my $volume_info = parse_neb_volume($volume); 60 61 # magically eat the "any" volume 62 if (defined $volume_info->{volume} and $volume_info->{volume} ne 'any') { 63 $volume_name = $volume_info->{volume}; 64 $soft_volume = $volume_info->{soft_volume}; 65 } 50 66 51 67 # require a leading slash if there is no volume name 52 if ((not defined $volume ) and (not $path =~ m|^/|)) {68 if ((not defined $volume_name) and (not $path =~ m|^/|)) { 53 69 die "neb URI scheme requires a leading slash, eg. neb:/"; 54 70 } 71 } else { 72 my $volume_info = parse_neb_volume($volume); 73 74 # magically eat the "any" volume 75 if (defined $volume_info->{volume} and $volume_info->{volume} ne 'any') { 76 $volume_name = $volume_info->{volume}; 77 $soft_volume = $volume_info->{soft_volume}; 78 } 55 79 } 56 80 … … 59 83 60 84 # remove multiple /'s and trailing slashes 61 $path = canonpath($path); 62 63 return ($volume, $path); 85 $path = File::Spec->canonpath($path); 86 87 return __PACKAGE__->new({ 88 volume => $volume_name, 89 soft_volume => $soft_volume, 90 path => $path, 91 }); 92 } 93 94 sub parse_neb_volume 95 { 96 my $volume = shift; 97 return unless defined $volume; 98 99 my $soft_volume; 100 # check to see if there is a tilde and remove it if found 101 if (defined $volume and $volume =~ s/^~//) { 102 $soft_volume = 1; 103 } 104 105 return({ volume => $volume, soft_volume => $soft_volume }); 106 } 107 108 sub _stringify_key 109 { 110 my $self = shift; 111 112 my $path = $self->path; 113 my $volume = $self->volume || ""; 114 my $soft_volume = $self->soft_volume ? '~' : ""; 115 116 return "neb://${soft_volume}${volume}/$path"; 64 117 } 65 118 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r18400 r18451 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1. 79 2008-07-02 03:40:10jhoblitt Exp $3 # $Id: Server.pm,v 1.80 2008-07-09 23:32:35 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 22 22 use Nebulous::Server::Log; 23 23 use Nebulous::Server::SQL; 24 use Nebulous::Keys qw( parse_neb_key );24 use Nebulous::Keys qw( parse_neb_key parse_neb_volume ); 25 25 use Params::Validate qw( validate_pos SCALAR SCALARREF UNDEF ); 26 26 use URI::file; … … 167 167 $log->debug( "entered - @_" ); 168 168 169 { 170 my $volume; 171 ($volume, $key) = parse_neb_key($key); 172 # vol_name overrides the key implied volume 173 $vol_name ||= $volume; 174 } 175 176 if (defined $vol_name and !$self->_is_valid_volume_name($vol_name)) { 177 die "$vol_name is not a valid volume name" 169 $key = parse_neb_key($key, $vol_name); 170 # vol_name overrides the key implied volume 171 $vol_name = $key->volume; 172 173 # the key isn't validiated on input for this method so we have to check it 174 # again after parsing the key 175 if (defined $vol_name and not $self->_is_valid_volume_name($vol_name)) { 176 $log->logdie("$vol_name is not a valid volume name"); 178 177 } 179 178 180 my ($vol_id, $vol_host, $vol_path, $vol_xattr) = $self->_get_storage_volume($vol_name); 179 if (defined $key->soft_volume) { 180 $vol_name = undef; 181 } 182 183 my ($vol_id, $vol_host, $vol_path, $vol_xattr) 184 = $self->_get_storage_volume($vol_name); 181 185 182 186 my $uri; … … 185 189 # create storage_object 186 190 my $query = $db->prepare_cached( $sql->new_object ); 187 $query->execute('NULL', $key );191 $query->execute('NULL', $key->path); 188 192 } 189 193 … … 231 235 232 236 # TODO add some stuff here to retry if unsucessful 233 $uri = $self->_create_empty_instance_file($key , $so_id, $ins_id, $vol_path, $vol_xattr);237 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr); 234 238 $log->debug("created $uri on volume ID: $vol_id"); 235 239 … … 289 293 my $query = $db->prepare_cached($sql->rename_object); 290 294 # this SQL statment takes the new key name as the first param 291 my $rows = $query->execute($newkey , $key);295 my $rows = $query->execute($newkey->path, $key->path); 292 296 293 297 # if we affected more then one row something very bad has happened. … … 351 355 $log->debug("entered - @_"); 352 356 353 { 354 my $volume; 355 ($volume, $key) = parse_neb_key($key); 356 # vol_name overrides the key implied volume 357 $vol_name ||= $volume; 357 $key = parse_neb_key($key, $vol_name); 358 # vol_name overrides the key implied volume 359 $vol_name = $key->volume; 360 361 if (defined $key->soft_volume) { 362 $vol_name = undef; 358 363 } 359 364 … … 377 382 # verify that at least one instance is currently available 378 383 my $query = $db->prepare_cached( $sql->get_object_instances ); 379 my $rows = $query->execute($key , 1);384 my $rows = $query->execute($key->path, 1); 380 385 381 386 unless ( $rows > 0 ) { … … 409 414 410 415 # TODO add some stuff here to retry if unsucessful 411 $uri = $self->_create_empty_instance_file($key , $so_id, $ins_id, $vol_path, $vol_xattr);416 $uri = $self->_create_empty_instance_file($key->path, $so_id, $ins_id, $vol_path, $vol_xattr); 412 417 413 418 { … … 467 472 # this will set update locks 468 473 my $query = $db->prepare_cached( $sql->get_object_locks ); 469 my $rows = $query->execute( $key );474 my $rows = $query->execute( $key->path ); 470 475 unless ( $rows == 1 ) { 471 476 $query->finish; … … 494 499 { 495 500 my $query = $db->prepare_cached( $sql->set_write_lock ); 496 my $rows = $query->execute($key );501 my $rows = $query->execute($key->path); 497 502 498 503 # if we affected more then one row something very bad has happened. … … 510 515 { 511 516 my $query = $db->prepare_cached( $sql->increment_read_lock ); 512 my $rows = $query->execute($key );517 my $rows = $query->execute($key->path); 513 518 514 519 # if we affected more then one row something very bad has happened. … … 569 574 # this will set update locks 570 575 my $query = $db->prepare_cached( $sql->get_object_locks ); 571 my $rows = $query->execute($key );576 my $rows = $query->execute($key->path); 572 577 unless ($rows == 1) { 573 578 $query->finish; … … 595 600 { 596 601 my $query = $db->prepare_cached( $sql->delete_write_lock ); 597 my $rows = $query->execute($key );602 my $rows = $query->execute($key->path); 598 603 599 604 # if we affected more then one row something very bad has happened. … … 615 620 { 616 621 my $query = $db->prepare_cached( $sql->decrement_read_lock ); 617 my $rows = $query->execute($key );622 my $rows = $query->execute($key->path); 618 623 619 624 # if we affected more then one row something very bad has happened. … … 684 689 685 690 # name, value, ext_id 686 my $rows = $query->execute($name, $value, $key );691 my $rows = $query->execute($name, $value, $key->path); 687 692 $query->finish; 688 693 … … 744 749 my $query = $db->prepare_cached( $sql->get_object_xattr ); 745 750 # ext_id, name 746 my $rows = $query->execute($key , $name);751 my $rows = $query->execute($key->path, $name); 747 752 748 753 # no rows returned means that the xattr does not exist … … 797 802 my $query = $db->prepare_cached( $sql->list_object_xattr ); 798 803 # ext_id 799 my $rows = $query->execute($key );804 my $rows = $query->execute($key->path); 800 805 801 806 while (my $row = $query->fetchrow_hashref) { … … 839 844 my $query = $db->prepare_cached( $sql->remove_object_xattr ); 840 845 # ext_id, name 841 my $rows = $query->execute($key , $name);846 my $rows = $query->execute($key->path, $name); 842 847 $query->finish; 843 848 … … 885 890 886 891 # attempt to strip off neb:// if it exists 887 if ($pattern =~ m|^neb:|) { 888 $pattern = parse_neb_key($pattern); 889 } 892 $pattern =~ s|^neb:||; 890 893 891 894 my @keys; … … 939 942 $log->debug("entered - @_"); 940 943 941 { 942 my $volume; 943 ($volume, $key) = parse_neb_key($key); 944 if (defined $volume) { 945 die "$volume is not a valid volume name" 946 unless $self->_is_valid_volume_name($volume); 947 } 948 $vol_name ||= $volume; 949 } 950 951 # handle :any volume 952 if ($vol_name eq ':any') { 944 $key = parse_neb_key($key, $vol_name); 945 # vol_name overrides the key implied volume 946 $vol_name = $key->volume; 947 948 # handle soft volumes 949 if (defined $key->soft_volume) { 953 950 $vol_name = undef; 954 951 } … … 960 957 $query = $db->prepare_cached( $sql->get_object_instances_by_vol_name ); 961 958 # ext_id, name, available 962 my $rows = $query->execute($key , $vol_name, 1);959 my $rows = $query->execute($key->path, $vol_name, 1); 963 960 unless ($rows > 0) { 964 961 $query->finish; … … 968 965 $query = $db->prepare_cached( $sql->get_object_instances ); 969 966 # ext_id, available 970 my $rows = $query->execute($key , 1);967 my $rows = $query->execute($key->path, 1); 971 968 unless ($rows > 0) { 972 969 $query->finish; … … 1102 1099 eval { 1103 1100 my $query = $db->prepare_cached( $sql->stat_object ); 1104 my $rows = $query->execute($key );1101 my $rows = $query->execute($key->path); 1105 1102 1106 1103 unless ($rows == 1) { … … 1228 1225 my $key = shift; 1229 1226 1230 my $volume; 1231 ($volume, $key) = parse_neb_key($key); 1227 $key = parse_neb_key($key); 1232 1228 1233 1229 my ($vol_id, $vol_host, $vol_path, $xattr); … … 1236 1232 my $query = $db->prepare_cached( $sql->get_replication_volume_for_ext_id ); 1237 1233 # ext_id, %free, avaiable, allocate 1238 $rows = $query->execute($key , 0.95, 1, 1);1234 $rows = $query->execute($key->path, 0.95, 1, 1); 1239 1235 # XXX destinguish between non-existant and unaviable 1240 1236 unless ($rows > 0) { … … 1271 1267 my $db =$self->db; 1272 1268 1273 my $volume; 1274 ($volume, $key) = parse_neb_key($key); 1269 $key = parse_neb_key($key); 1275 1270 1276 1271 my $ext_id; 1277 1272 eval { 1278 1273 my $query = $db->prepare_cached( $sql->get_object ); 1279 $query->execute($key );1274 $query->execute($key->path); 1280 1275 ($ext_id) = $query->fetchrow_array; 1281 1276 $query->finish; … … 1303 1298 my $db =$self->db; 1304 1299 1305 # handle ":any" volume 1306 if ($vol_name eq ':any') { 1300 my $volume_info = parse_neb_volume($vol_name); 1301 1302 $vol_name = $volume_info->{volume}; 1303 1304 # handle "any" volume 1305 if ($vol_name eq 'any') { 1307 1306 return 1; 1308 1307 } -
trunk/Nebulous-Server/t/07_server_find_instances.t
r18400 r18451 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 07_server_find_instances.t,v 1.1 3 2008-07-02 03:40:10jhoblitt Exp $5 # $Id: 07_server_find_instances.t,v 1.14 2008-07-09 23:32:35 jhoblitt Exp $ 6 6 7 7 use strict; … … 78 78 my $uri = $neb->create_object('foo', 'node01'); 79 79 80 my $locations = $neb->find_instances('neb://node02/foo', " :any");80 my $locations = $neb->find_instances('neb://node02/foo', "~any"); 81 81 82 82 uri_scheme_ok($locations->[0], 'file'); … … 91 91 my $uri2 = $neb->replicate_object("foo"); 92 92 93 my $locations = $neb->find_instances("foo", " :any");93 my $locations = $neb->find_instances("foo", "~any"); 94 94 95 95 uri_scheme_ok($locations->[0], 'file'); -
trunk/Nebulous-Server/t/14_server_xattr.t
r17697 r18451 3 3 # Copryight (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: 14_server_xattr.t,v 1. 7 2008-05-15 03:28:05 jhoblitt Exp $5 # $Id: 14_server_xattr.t,v 1.8 2008-07-09 23:32:35 jhoblitt Exp $ 6 6 7 7 use strict; … … 164 164 $neb->getxattr_object('foo', 'bar'); 165 165 }; 166 like($@, qr /xattr foo:bar does not exist/,166 like($@, qr|xattr neb:///foo:bar does not exist|, 167 167 "get xattr from non-existant xattr key"); 168 168 -
trunk/Nebulous-Server/t/75_parse_neb_key.t
r17076 r18451 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 75_parse_neb_key.t,v 1. 3 2008-03-21 01:23:45 jhoblitt Exp $5 # $Id: 75_parse_neb_key.t,v 1.4 2008-07-09 23:32:35 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use Test::More; 11 11 12 plan tests => 36;12 plan tests => 80; 13 13 14 14 use lib qw( ./t ./lib ); … … 24 24 # key 25 25 { 26 my ($volume, $path) = parse_neb_key('foo/bar/baz/quix'); 27 28 is($path, 'foo/bar/baz/quix', 'path'); 29 is($volume, undef, 'volume name'); 30 } 31 32 { 33 my ($volume, $path) = parse_neb_key('/foo/bar/baz/quix'); 34 35 is($path, 'foo/bar/baz/quix', 'path'); 36 is($volume, undef, 'volume name'); 37 } 38 39 { 40 my ($volume, $path) = parse_neb_key('//foo/bar/baz/quix'); 41 42 is($path, 'foo/bar/baz/quix', 'path'); 43 is($volume, undef, 'volume name'); 44 } 45 46 { 47 my ($volume, $path) = parse_neb_key('///foo/bar/baz/quix'); 48 49 is($path, 'foo/bar/baz/quix', 'path'); 50 is($volume, undef, 'volume name'); 51 } 52 53 { 54 my ($volume, $path) = parse_neb_key('foo////bar/baz/quix'); 55 56 is($path, 'foo/bar/baz/quix', 'path'); 57 is($volume, undef, 'volume name'); 58 } 59 60 { 61 my ($volume, $path) = parse_neb_key('foo/bar/baz/quix/'); 62 63 is($path, 'foo/bar/baz/quix', 'path'); 64 is($volume, undef, 'volume name'); 65 } 66 26 my $key = parse_neb_key('foo/bar/baz/quix'); 27 28 is($key->path, 'foo/bar/baz/quix', 'path'); 29 is($key->volume, undef, 'volume name'); 30 is($key->soft_volume, undef, 'soft volume name'); 31 } 32 33 { 34 my $key = parse_neb_key('/foo/bar/baz/quix'); 35 36 is($key->path, 'foo/bar/baz/quix', 'path'); 37 is($key->volume, undef, 'volume name'); 38 is($key->soft_volume, undef, 'soft volume name'); 39 } 40 41 { 42 my $key = parse_neb_key('//foo/bar/baz/quix'); 43 44 is($key->path, 'foo/bar/baz/quix', 'path'); 45 is($key->volume, undef, 'volume name'); 46 is($key->soft_volume, undef, 'soft volume name'); 47 } 48 49 { 50 my $key = parse_neb_key('///foo/bar/baz/quix'); 51 52 is($key->path, 'foo/bar/baz/quix', 'path'); 53 is($key->volume, undef, 'volume name'); 54 is($key->soft_volume, undef, 'soft volume name'); 55 } 56 57 { 58 my $key = parse_neb_key('foo////bar/baz/quix'); 59 60 is($key->path, 'foo/bar/baz/quix', 'path'); 61 is($key->volume, undef, 'volume name'); 62 is($key->soft_volume, undef, 'soft volume name'); 63 } 64 65 { 66 my $key = parse_neb_key('foo/bar/baz/quix/'); 67 68 is($key->path, 'foo/bar/baz/quix', 'path'); 69 is($key->volume, undef, 'volume name'); 70 is($key->soft_volume, undef, 'soft volume name'); 71 } 72 73 # key w/ volume argument 74 { 75 my $key = parse_neb_key('foo/bar/baz/quix', 'boing'); 76 77 is($key->path, 'foo/bar/baz/quix', 'path'); 78 is($key->volume, 'boing', 'volume name'); 79 is($key->soft_volume, undef, 'soft volume name'); 80 } 81 82 { 83 my $key = parse_neb_key('foo/bar/baz/quix', '~boing'); 84 85 is($key->path, 'foo/bar/baz/quix', 'path'); 86 is($key->volume, 'boing', 'volume name'); 87 is($key->soft_volume, 1, 'soft volume name'); 88 } 67 89 68 90 # URI w/ volume name 69 91 { 70 my ($volume, $path) = parse_neb_key('neb://foo/bar/baz/quix'); 71 72 is($path, 'bar/baz/quix', 'path'); 73 is($volume, 'foo', 'volume name'); 74 } 75 76 { 77 my ($volume, $path) = parse_neb_key('neb://foo//bar/baz/quix'); 78 79 is($path, 'bar/baz/quix', 'path'); 80 is($volume, 'foo', 'volume name'); 81 } 82 83 { 84 my ($volume, $path) = parse_neb_key('neb://foo///bar/baz/quix'); 85 86 is($path, 'bar/baz/quix', 'path'); 87 is($volume, 'foo', 'volume name'); 88 } 89 90 { 91 my ($volume, $path) = parse_neb_key('neb://foo/bar///baz/quix'); 92 93 is($path, 'bar/baz/quix', 'path'); 94 is($volume, 'foo', 'volume name'); 95 } 96 97 { 98 my ($volume, $path) = parse_neb_key('neb://foo/bar/baz/quix/'); 99 100 is($path, 'bar/baz/quix', 'path'); 101 is($volume, 'foo', 'volume name'); 102 } 103 92 my $key = parse_neb_key('neb://foo/bar/baz/quix'); 93 94 is($key->path, 'bar/baz/quix', 'path'); 95 is($key->volume, 'foo', 'volume name'); 96 is($key->soft_volume, undef, 'soft volume name'); 97 } 98 99 { 100 my $key = parse_neb_key('neb://foo//bar/baz/quix'); 101 102 is($key->path, 'bar/baz/quix', 'path'); 103 is($key->volume, 'foo', 'volume name'); 104 is($key->soft_volume, undef, 'soft volume name'); 105 } 106 107 { 108 my $key = parse_neb_key('neb://foo///bar/baz/quix'); 109 110 is($key->path, 'bar/baz/quix', 'path'); 111 is($key->volume, 'foo', 'volume name'); 112 is($key->soft_volume, undef, 'soft volume name'); 113 } 114 115 { 116 my $key = parse_neb_key('neb://foo/bar///baz/quix'); 117 118 is($key->path, 'bar/baz/quix', 'path'); 119 is($key->volume, 'foo', 'volume name'); 120 is($key->soft_volume, undef, 'soft volume name'); 121 } 122 123 { 124 my $key = parse_neb_key('neb://foo/bar/baz/quix/'); 125 126 is($key->path, 'bar/baz/quix', 'path'); 127 is($key->volume, 'foo', 'volume name'); 128 is($key->soft_volume, undef, 'soft volume name'); 129 } 130 131 # URI w/ soft volume name 132 { 133 my $key = parse_neb_key('neb://~foo/bar/baz/quix/'); 134 135 is($key->path, 'bar/baz/quix', 'path'); 136 is($key->volume, 'foo', 'volume name'); 137 is($key->soft_volume, 1, 'soft volume name'); 138 } 139 140 # URI w/ volume name and volume argument 141 { 142 my $key = parse_neb_key('neb://foo/bar/baz/quix', 'boing'); 143 144 is($key->path, 'bar/baz/quix', 'path'); 145 is($key->volume, 'boing', 'volume name'); 146 is($key->soft_volume, undef, 'soft volume name'); 147 } 148 149 { 150 my $key = parse_neb_key('neb://foo/bar/baz/quix', '~boing'); 151 152 is($key->path, 'bar/baz/quix', 'path'); 153 is($key->volume, 'boing', 'volume name'); 154 is($key->soft_volume, 1, 'soft volume name'); 155 } 156 157 { 158 my $key = parse_neb_key('neb://foo/bar/baz/quix', undef); 159 160 is($key->path, 'bar/baz/quix', 'path'); 161 is($key->volume, 'foo', 'volume name'); 162 is($key->soft_volume, undef, 'soft volume name'); 163 } 164 165 # URI w/ ~any volume name 166 { 167 my $key = parse_neb_key('neb://~any/bar/baz/quix/'); 168 169 is($key->path, 'bar/baz/quix', 'path'); 170 is($key->volume, undef, 'volume name'); 171 is($key->soft_volume, undef, 'soft volume name'); 172 } 173 174 # URI w/ any volume argument 175 { 176 my $key = parse_neb_key('neb://boing/bar/baz/quix/', 'any'); 177 178 is($key->path, 'bar/baz/quix', 'path'); 179 is($key->volume, undef, 'volume name'); 180 is($key->soft_volume, undef, 'soft volume name'); 181 } 182 183 { 184 my $key = parse_neb_key('neb://boing/bar/baz/quix/', '~any'); 185 186 is($key->path, 'bar/baz/quix', 'path'); 187 is($key->volume, undef, 'volume name'); 188 is($key->soft_volume, undef, 'soft volume name'); 189 } 190 191 # URI w/ soft volume name 192 { 193 my $key = parse_neb_key('neb://~foo/bar/baz/quix/'); 194 195 is($key->path, 'bar/baz/quix', 'path'); 196 is($key->volume, 'foo', 'volume name'); 197 is($key->soft_volume, 1, 'soft volume name'); 198 } 104 199 105 200 # URI w/o volume name 106 201 107 202 { 108 my ($volume, $path) = parse_neb_key('neb:/foo/bar/baz/quix'); 109 110 is($path, 'foo/bar/baz/quix', 'path'); 111 is($volume, undef, 'volume name'); 112 } 113 114 { 115 my ($volume, $path) = parse_neb_key('neb:///foo/bar/baz/quix'); 116 117 is($volume, undef, 'volume name'); 118 is($path, 'foo/bar/baz/quix', 'path'); 119 } 120 121 { 122 my ($volume, $path) = parse_neb_key('neb://///foo/bar/baz/quix'); 123 124 is($path, 'foo/bar/baz/quix', 'path'); 125 is($volume, undef, 'volume name'); 203 my $key = parse_neb_key('neb:/foo/bar/baz/quix'); 204 205 is($key->path, 'foo/bar/baz/quix', 'path'); 206 is($key->volume, undef, 'volume name'); 207 is($key->soft_volume, undef, 'soft volume name'); 208 } 209 210 { 211 my $key = parse_neb_key('neb:///foo/bar/baz/quix'); 212 213 is($key->volume, undef, 'volume name'); 214 is($key->path, 'foo/bar/baz/quix', 'path'); 215 is($key->soft_volume, undef, 'soft volume name'); 216 } 217 218 { 219 my $key = parse_neb_key('neb://///foo/bar/baz/quix'); 220 221 is($key->path, 'foo/bar/baz/quix', 'path'); 222 is($key->volume, undef, 'volume name'); 223 is($key->soft_volume, undef, 'soft volume name'); 126 224 } 127 225 … … 166 264 # URI w/o volume requires leading slash 167 265 eval { 168 my ($volume, $path)= parse_neb_key('neb:foo/bar/baz/quix');266 my $key = parse_neb_key('neb:foo/bar/baz/quix'); 169 267 }; 170 268 like( $@, qr/requires a leading slash/, "leading slash" );
Note:
See TracChangeset
for help on using the changeset viewer.
