Changeset 16221
- Timestamp:
- Jan 24, 2008, 3:54:37 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Nebulous-Server/Changes (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (13 diffs)
-
Nebulous-Server/t/03_server_create_object.t (modified) (15 diffs)
-
Nebulous/Changes (modified) (1 diff)
-
Nebulous/lib/Nebulous/Server.pm (modified) (13 diffs)
-
Nebulous/t/03_server_create_object.t (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r16203 r16221 2 2 3 3 0.06 4 - add Nebulous::Sever:: neb key/uri support 4 5 - add Nebulous::Util::parse_neb_key() 5 6 - change bin/* scripts to conistently use --volume instead of --node, -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r16184 r16221 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.4 6 2008-01-23 00:46:06jhoblitt Exp $3 # $Id: Server.pm,v 1.47 2008-01-25 01:53:28 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 158 158 $log->debug( "entered - @_" ); 159 159 160 { 161 my $volume; 162 ($volume, $key) = parse_neb_key($key); 163 # if (defined $volume) { 164 # die "$volume is not a valid volume name" 165 # unless $self->_is_valid_volume_name($volume); 166 # } 167 $vol_name ||= $volume; 168 169 } 170 160 171 my ($uri, $vol_id); 161 172 eval { … … 257 268 $log->debug("entered - @_"); 258 269 270 # ignore volumes 271 $key = parse_neb_key($key); 272 $newkey = parse_neb_key($newkey); 273 259 274 eval { 260 275 # rename storage_object … … 309 324 310 325 $log->debug("entered - @_"); 326 327 { 328 my $volume; 329 ($volume, $key) = parse_neb_key($key); 330 if (defined $volume) { 331 die "$volume is not a valid volume name" 332 unless $self->_is_valid_volume_name($volume); 333 } 334 $vol_name ||= $volume; 335 } 311 336 312 337 my ($uri, $vol_id); … … 395 420 396 421 $log->debug( "entered - @_" ); 422 423 # ignore volume 424 $key = parse_neb_key($key); 397 425 398 426 my $so_id; … … 495 523 $log->debug( "entered - @_" ); 496 524 525 # ignore volume 526 $key = parse_neb_key($key); 527 497 528 my $so_id; 498 529 my $read_lock; … … 604 635 $log->debug("entered - @_"); 605 636 637 # ignore volume 638 $key = parse_neb_key($key); 639 606 640 eval { 607 641 my $query; … … 672 706 $log->debug("entered - @_"); 673 707 708 # ignore volume 709 $key = parse_neb_key($key); 710 674 711 my $query; 675 712 eval { … … 718 755 $log->debug("entered - @_"); 719 756 757 # ignore volume 758 $key = parse_neb_key($key); 759 720 760 my $query; 721 761 eval { … … 763 803 $log->debug("entered - @_"); 764 804 805 # ignore volume 806 $key = parse_neb_key($key); 807 765 808 my $query; 766 809 eval { … … 862 905 863 906 $log->debug("entered - @_"); 907 908 { 909 my $volume; 910 ($volume, $key) = parse_neb_key($key); 911 if (defined $volume) { 912 die "$volume is not a valid volume name" 913 unless $self->_is_valid_volume_name($volume); 914 } 915 $vol_name ||= $volume; 916 } 864 917 865 918 my $query; … … 1008 1061 $log->debug("entered - @_"); 1009 1062 1063 # ignore volume 1064 $key = parse_neb_key($key); 1065 1010 1066 my $stat; 1011 1067 eval { … … 1055 1111 # %free, name, avaiable, allocate 1056 1112 $rows = $query->execute(0.95, $name, 1, 1); 1113 # XXX destinguish between non-existant and unaviable 1057 1114 unless ($rows > 0) { 1058 1115 $query->finish; -
trunk/Nebulous-Server/t/03_server_create_object.t
r13302 r16221 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1.2 0 2007-05-08 02:27:42jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.21 2008-01-25 01:53:28 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 28;10 use Test::More tests => 64; 11 11 12 12 use lib qw( ./t ./lib ); … … 35 35 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 36 36 ok(-e $path, "file exists"); 37 ok($neb->find_instances("foo"), 'object key exists'); 38 uri_scheme_ok($uri, 'file'); 39 40 SKIP: { 41 skip "requires xattr support", 1 unless $test_xattr; 42 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 43 } 44 } 45 46 Test::Nebulous->setup; 47 48 { 49 # key 50 my $uri = $neb->create_object("neb:/foo"); 51 52 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 53 ok(-e $path, "file exists"); 54 ok($neb->find_instances("foo"), 'object key exists'); 55 uri_scheme_ok($uri, 'file'); 56 57 SKIP: { 58 skip "requires xattr support", 1 unless $test_xattr; 59 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 60 } 61 } 62 63 Test::Nebulous->setup; 64 65 { 66 # key 67 my $uri = $neb->create_object("neb://node01/foo"); 68 69 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 70 ok(-e $path, "file exists"); 71 ok($neb->find_instances("foo"), 'object key exists'); 72 uri_scheme_ok($uri, 'file'); 73 74 SKIP: { 75 skip "requires xattr support", 1 unless $test_xattr; 76 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 77 } 78 } 79 80 Test::Nebulous->setup; 81 82 { 83 # key 84 my $uri = $neb->create_object("neb://node02/foo"); 85 86 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 87 ok(-e $path, "file exists"); 88 ok($neb->find_instances("foo"), 'object key exists'); 37 89 uri_scheme_ok($uri, 'file'); 38 90 … … 51 103 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 52 104 ok(-e $path, "file exists"); 105 ok($neb->find_instances("foo"), 'object key exists'); 53 106 uri_scheme_ok($uri, 'file'); 54 107 … … 60 113 61 114 Test::Nebulous->setup; 115 { 116 # key 117 my $uri = $neb->create_object("neb:///foo"); 118 119 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 120 ok(-e $path, "file exists"); 121 ok($neb->find_instances("foo"), 'object key exists'); 122 uri_scheme_ok($uri, 'file'); 123 124 SKIP: { 125 skip "requires xattr support", 1 unless $test_xattr; 126 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 127 } 128 } 129 130 Test::Nebulous->setup; 62 131 63 132 { … … 67 136 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 68 137 ok(-e $path, "file exists"); 138 ok($neb->find_instances("foo"), 'object key exists'); 69 139 uri_scheme_ok($uri, 'file'); 70 140 … … 79 149 { 80 150 # key 151 my $uri = $neb->create_object("neb:/foo/"); 152 153 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 154 ok(-e $path, "file exists"); 155 ok($neb->find_instances("foo"), 'object key exists'); 156 uri_scheme_ok($uri, 'file'); 157 158 SKIP: { 159 skip "requires xattr support", 1 unless $test_xattr; 160 is(getfattr($path, 'user.nebulous_key'), '/foo/', 'user.nebulous_key xattr'); 161 } 162 } 163 164 Test::Nebulous->setup; 165 166 { 167 # key 81 168 my $uri = $neb->create_object("foo/"); 82 169 83 170 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 84 171 ok(-e $path, "file exists"); 172 ok($neb->find_instances("foo"), 'object key exists'); 85 173 uri_scheme_ok($uri, 'file'); 86 174 … … 99 187 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 100 188 ok(-e $path, "file exists"); 189 ok($neb->find_instances("foo/bar"), 'object key exists'); 101 190 uri_scheme_ok($uri, 'file'); 102 191 … … 115 204 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 116 205 ok(-e $path, "file exists"); 206 ok($neb->find_instances("foo/bar"), 'object key exists'); 117 207 uri_scheme_ok($uri, 'file'); 118 208 … … 131 221 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 132 222 ok(-e $path, "file exists"); 223 ok($neb->find_instances("foo"), 'object key exists'); 224 uri_scheme_ok($uri, 'file'); 225 } 226 227 Test::Nebulous->setup; 228 229 { 230 # volume name override 231 my $uri = $neb->create_object("neb://99/foo", "node01"); 232 233 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 234 ok(-e $path, "file exists"); 235 ok($neb->find_instances("foo"), 'object key exists'); 133 236 uri_scheme_ok($uri, 'file'); 134 237 } … … 145 248 146 249 eval { 250 $neb->create_object("neb:/foo"); 251 $neb->create_object("neb:/foo"); 252 }; 253 like($@, qr/Duplicate entry/, "object already exists"); 254 255 Test::Nebulous->setup; 256 257 eval { 147 258 $neb->create_object("foo", 'node03'); 148 259 }; … … 152 263 153 264 eval { 265 $neb->create_object("neb://node03/foo"); 266 }; 267 like($@, qr/node03 is not available/, "request volume this is full"); 268 269 Test::Nebulous->setup; 270 271 eval { 154 272 $neb->create_object("foo", 'node04'); 155 273 }; … … 159 277 160 278 eval { 279 $neb->create_object("neb://node04/foo"); 280 }; 281 like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE"); 282 283 Test::Nebulous->setup; 284 285 eval { 161 286 $neb->create_object("foo", 'node05'); 162 287 }; … … 166 291 167 292 eval { 293 $neb->create_object("neb://node05/foo"); 294 }; 295 like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE"); 296 297 Test::Nebulous->setup; 298 299 eval { 168 300 $neb->create_object("foo", 'node06'); 169 301 }; … … 173 305 174 306 eval { 307 $neb->create_object("neb://node06/foo"); 308 }; 309 like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE"); 310 311 Test::Nebulous->setup; 312 313 eval { 175 314 $neb->create_object("foo", 99); 176 315 }; … … 180 319 181 320 eval { 321 $neb->create_object("neb://99/foo"); 322 }; 323 like($@, qr/is not available/, "volume name doesn't exist"); 324 325 Test::Nebulous->setup; 326 327 eval { 182 328 $neb->create_object(); 183 329 }; -
trunk/Nebulous/Changes
r16203 r16221 2 2 3 3 0.06 4 - add Nebulous::Sever:: neb key/uri support 4 5 - add Nebulous::Util::parse_neb_key() 5 6 - change bin/* scripts to conistently use --volume instead of --node, -
trunk/Nebulous/lib/Nebulous/Server.pm
r16184 r16221 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.4 6 2008-01-23 00:46:06jhoblitt Exp $3 # $Id: Server.pm,v 1.47 2008-01-25 01:53:28 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 158 158 $log->debug( "entered - @_" ); 159 159 160 { 161 my $volume; 162 ($volume, $key) = parse_neb_key($key); 163 # if (defined $volume) { 164 # die "$volume is not a valid volume name" 165 # unless $self->_is_valid_volume_name($volume); 166 # } 167 $vol_name ||= $volume; 168 169 } 170 160 171 my ($uri, $vol_id); 161 172 eval { … … 257 268 $log->debug("entered - @_"); 258 269 270 # ignore volumes 271 $key = parse_neb_key($key); 272 $newkey = parse_neb_key($newkey); 273 259 274 eval { 260 275 # rename storage_object … … 309 324 310 325 $log->debug("entered - @_"); 326 327 { 328 my $volume; 329 ($volume, $key) = parse_neb_key($key); 330 if (defined $volume) { 331 die "$volume is not a valid volume name" 332 unless $self->_is_valid_volume_name($volume); 333 } 334 $vol_name ||= $volume; 335 } 311 336 312 337 my ($uri, $vol_id); … … 395 420 396 421 $log->debug( "entered - @_" ); 422 423 # ignore volume 424 $key = parse_neb_key($key); 397 425 398 426 my $so_id; … … 495 523 $log->debug( "entered - @_" ); 496 524 525 # ignore volume 526 $key = parse_neb_key($key); 527 497 528 my $so_id; 498 529 my $read_lock; … … 604 635 $log->debug("entered - @_"); 605 636 637 # ignore volume 638 $key = parse_neb_key($key); 639 606 640 eval { 607 641 my $query; … … 672 706 $log->debug("entered - @_"); 673 707 708 # ignore volume 709 $key = parse_neb_key($key); 710 674 711 my $query; 675 712 eval { … … 718 755 $log->debug("entered - @_"); 719 756 757 # ignore volume 758 $key = parse_neb_key($key); 759 720 760 my $query; 721 761 eval { … … 763 803 $log->debug("entered - @_"); 764 804 805 # ignore volume 806 $key = parse_neb_key($key); 807 765 808 my $query; 766 809 eval { … … 862 905 863 906 $log->debug("entered - @_"); 907 908 { 909 my $volume; 910 ($volume, $key) = parse_neb_key($key); 911 if (defined $volume) { 912 die "$volume is not a valid volume name" 913 unless $self->_is_valid_volume_name($volume); 914 } 915 $vol_name ||= $volume; 916 } 864 917 865 918 my $query; … … 1008 1061 $log->debug("entered - @_"); 1009 1062 1063 # ignore volume 1064 $key = parse_neb_key($key); 1065 1010 1066 my $stat; 1011 1067 eval { … … 1055 1111 # %free, name, avaiable, allocate 1056 1112 $rows = $query->execute(0.95, $name, 1, 1); 1113 # XXX destinguish between non-existant and unaviable 1057 1114 unless ($rows > 0) { 1058 1115 $query->finish; -
trunk/Nebulous/t/03_server_create_object.t
r13302 r16221 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1.2 0 2007-05-08 02:27:42jhoblitt Exp $5 # $Id: 03_server_create_object.t,v 1.21 2008-01-25 01:53:28 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 28;10 use Test::More tests => 64; 11 11 12 12 use lib qw( ./t ./lib ); … … 35 35 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 36 36 ok(-e $path, "file exists"); 37 ok($neb->find_instances("foo"), 'object key exists'); 38 uri_scheme_ok($uri, 'file'); 39 40 SKIP: { 41 skip "requires xattr support", 1 unless $test_xattr; 42 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 43 } 44 } 45 46 Test::Nebulous->setup; 47 48 { 49 # key 50 my $uri = $neb->create_object("neb:/foo"); 51 52 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 53 ok(-e $path, "file exists"); 54 ok($neb->find_instances("foo"), 'object key exists'); 55 uri_scheme_ok($uri, 'file'); 56 57 SKIP: { 58 skip "requires xattr support", 1 unless $test_xattr; 59 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 60 } 61 } 62 63 Test::Nebulous->setup; 64 65 { 66 # key 67 my $uri = $neb->create_object("neb://node01/foo"); 68 69 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 70 ok(-e $path, "file exists"); 71 ok($neb->find_instances("foo"), 'object key exists'); 72 uri_scheme_ok($uri, 'file'); 73 74 SKIP: { 75 skip "requires xattr support", 1 unless $test_xattr; 76 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 77 } 78 } 79 80 Test::Nebulous->setup; 81 82 { 83 # key 84 my $uri = $neb->create_object("neb://node02/foo"); 85 86 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 87 ok(-e $path, "file exists"); 88 ok($neb->find_instances("foo"), 'object key exists'); 37 89 uri_scheme_ok($uri, 'file'); 38 90 … … 51 103 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 52 104 ok(-e $path, "file exists"); 105 ok($neb->find_instances("foo"), 'object key exists'); 53 106 uri_scheme_ok($uri, 'file'); 54 107 … … 60 113 61 114 Test::Nebulous->setup; 115 { 116 # key 117 my $uri = $neb->create_object("neb:///foo"); 118 119 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 120 ok(-e $path, "file exists"); 121 ok($neb->find_instances("foo"), 'object key exists'); 122 uri_scheme_ok($uri, 'file'); 123 124 SKIP: { 125 skip "requires xattr support", 1 unless $test_xattr; 126 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 127 } 128 } 129 130 Test::Nebulous->setup; 62 131 63 132 { … … 67 136 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 68 137 ok(-e $path, "file exists"); 138 ok($neb->find_instances("foo"), 'object key exists'); 69 139 uri_scheme_ok($uri, 'file'); 70 140 … … 79 149 { 80 150 # key 151 my $uri = $neb->create_object("neb:/foo/"); 152 153 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 154 ok(-e $path, "file exists"); 155 ok($neb->find_instances("foo"), 'object key exists'); 156 uri_scheme_ok($uri, 'file'); 157 158 SKIP: { 159 skip "requires xattr support", 1 unless $test_xattr; 160 is(getfattr($path, 'user.nebulous_key'), '/foo/', 'user.nebulous_key xattr'); 161 } 162 } 163 164 Test::Nebulous->setup; 165 166 { 167 # key 81 168 my $uri = $neb->create_object("foo/"); 82 169 83 170 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 84 171 ok(-e $path, "file exists"); 172 ok($neb->find_instances("foo"), 'object key exists'); 85 173 uri_scheme_ok($uri, 'file'); 86 174 … … 99 187 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 100 188 ok(-e $path, "file exists"); 189 ok($neb->find_instances("foo/bar"), 'object key exists'); 101 190 uri_scheme_ok($uri, 'file'); 102 191 … … 115 204 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 116 205 ok(-e $path, "file exists"); 206 ok($neb->find_instances("foo/bar"), 'object key exists'); 117 207 uri_scheme_ok($uri, 'file'); 118 208 … … 131 221 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 132 222 ok(-e $path, "file exists"); 223 ok($neb->find_instances("foo"), 'object key exists'); 224 uri_scheme_ok($uri, 'file'); 225 } 226 227 Test::Nebulous->setup; 228 229 { 230 # volume name override 231 my $uri = $neb->create_object("neb://99/foo", "node01"); 232 233 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 234 ok(-e $path, "file exists"); 235 ok($neb->find_instances("foo"), 'object key exists'); 133 236 uri_scheme_ok($uri, 'file'); 134 237 } … … 145 248 146 249 eval { 250 $neb->create_object("neb:/foo"); 251 $neb->create_object("neb:/foo"); 252 }; 253 like($@, qr/Duplicate entry/, "object already exists"); 254 255 Test::Nebulous->setup; 256 257 eval { 147 258 $neb->create_object("foo", 'node03'); 148 259 }; … … 152 263 153 264 eval { 265 $neb->create_object("neb://node03/foo"); 266 }; 267 like($@, qr/node03 is not available/, "request volume this is full"); 268 269 Test::Nebulous->setup; 270 271 eval { 154 272 $neb->create_object("foo", 'node04'); 155 273 }; … … 159 277 160 278 eval { 279 $neb->create_object("neb://node04/foo"); 280 }; 281 like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE"); 282 283 Test::Nebulous->setup; 284 285 eval { 161 286 $neb->create_object("foo", 'node05'); 162 287 }; … … 166 291 167 292 eval { 293 $neb->create_object("neb://node05/foo"); 294 }; 295 like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE"); 296 297 Test::Nebulous->setup; 298 299 eval { 168 300 $neb->create_object("foo", 'node06'); 169 301 }; … … 173 305 174 306 eval { 307 $neb->create_object("neb://node06/foo"); 308 }; 309 like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE"); 310 311 Test::Nebulous->setup; 312 313 eval { 175 314 $neb->create_object("foo", 99); 176 315 }; … … 180 319 181 320 eval { 321 $neb->create_object("neb://99/foo"); 322 }; 323 like($@, qr/is not available/, "volume name doesn't exist"); 324 325 Test::Nebulous->setup; 326 327 eval { 182 328 $neb->create_object(); 183 329 };
Note:
See TracChangeset
for help on using the changeset viewer.
