Changeset 19493
- Timestamp:
- Sep 11, 2008, 12:35:52 PM (18 years ago)
- Location:
- trunk/Nebulous-Server
- Files:
-
- 7 edited
-
Changes (modified) (1 diff)
-
lib/Nebulous/Server.pm (modified) (9 diffs)
-
lib/Test/Nebulous.pm (modified) (5 diffs)
-
t/03_server_create_object.t (modified) (2 diffs)
-
t/04_server_replicate_object.t (modified) (2 diffs)
-
t/07_server_find_instances.t (modified) (2 diffs)
-
t/15_mounts.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Changes
r19144 r19493 1 1 Revision history for Nebulous 2 3 0.15 4 - invert soft volume semantics 2 5 3 6 0.14 Wed Aug 20 16:25:43 HST 2008 -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r19473 r19493 1 1 # Copyright (c) 2004-2008 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.8 5 2008-09-10 23:55:54 billsExp $3 # $Id: Server.pm,v 1.86 2008-09-11 22:35:52 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 169 169 # vol_name overrides the key implied volume 170 170 $key = parse_neb_key($key, $vol_name); 171 172 if ($vol_name eq "99") { 173 use Data::Dumper; 174 print Dumper($key); 175 } 171 $vol_name = $key->volume; 176 172 177 173 # the key's volume can't be validiated on input for this method so we have 178 174 # to check it after parsing the key 179 if (defined $key->volume 180 and not $key->soft_volume 181 and not $self->_is_valid_volume_name($key->volume) 182 ) { 183 $log->logdie("$vol_name is not a valid volume name"); 175 if (defined $vol_name 176 and not $self->_is_valid_volume_name($key->volume)) { 177 if ($key->soft_volume) { 178 $log->warn( "$vol_name is not a known volume name" ); 179 $vol_name = undef; 180 } else { 181 die "$vol_name is not a valid volume name" 182 } 184 183 } 185 184 186 185 my ($vol_id, $vol_host, $vol_path, $vol_xattr) 187 = $self->_get_storage_volume($ key->volume, $key->soft_volume);186 = $self->_get_storage_volume($vol_name, $key->soft_volume); 188 187 189 188 my $uri; … … 252 251 }; 253 252 if ($@) { 253 # and not $key->soft_volume 254 254 $db->rollback; 255 255 $log->debug("rollback"); … … 358 358 $log->debug("entered - @_"); 359 359 360 # vol_name overrides the key implied volume 360 361 $key = parse_neb_key($key, $vol_name); 361 # vol_name overrides the key implied volume362 362 $vol_name = $key->volume; 363 363 364 if (defined $key->soft_volume) { 365 $vol_name = undef; 366 } 367 368 if (defined $vol_name and !$self->_is_valid_volume_name($vol_name)) { 369 die "$vol_name is not a valid volume name" 364 if (defined $vol_name 365 and not $self->_is_valid_volume_name($key->volume)) { 366 if ($key->soft_volume) { 367 $log->warn( "$vol_name is not a known volume name" ); 368 $vol_name = undef; 369 } else { 370 die "$vol_name is not a valid volume name" 371 } 370 372 } 371 373 … … 430 432 if ($@) { 431 433 $db->rollback; 434 # handle soft volumes 435 if (defined $vol_name and defined $key->soft_volume) { 436 $log->debug("retrying with 'any' volume"); 437 return $self->replicate_object($key->path, 'any'); 438 } 432 439 $log->debug("rollback"); 433 440 $log->logdie("error: $@"); … … 928 935 { 929 936 type => SCALAR|UNDEF, 930 callbacks => {931 # check that the volume name requested is valid932 'is valid volume name' => sub {933 return 1 if not defined $_[0];934 $self->_is_valid_volume_name($_[0])935 },936 },937 # callbacks => { 938 # # check that the volume name requested is valid 939 # 'is valid volume name' => sub { 940 # return 1 if not defined $_[0]; 941 # $self->_is_valid_volume_name($_[0]) 942 # }, 943 # }, 937 944 optional => 1, 938 945 }, … … 945 952 $log->debug("entered - @_"); 946 953 954 # vol_name overrides the key implied volume 947 955 $key = parse_neb_key($key, $vol_name); 948 # vol_name overrides the key implied volume949 956 $vol_name = $key->volume; 950 957 951 # handle soft volumes 952 if (defined $key->soft_volume) { 953 $vol_name = undef; 958 # the key's volume can't be validiated on input for this method so we have 959 # to check it after parsing the key 960 if (defined $vol_name 961 and not $self->_is_valid_volume_name($key->volume)) { 962 if ($key->soft_volume) { 963 $log->warn( "$vol_name is not a known volume name" ); 964 $vol_name = undef; 965 } else { 966 die "$vol_name is not a valid volume name" 967 } 954 968 } 955 969 … … 980 994 } 981 995 }; 982 $log->logdie("database error: $@") if $@; 996 if ($@) { 997 $db->rollback; 998 # handle soft volumes 999 if (defined $vol_name and defined $key->soft_volume) { 1000 $log->debug("retrying with 'any' volume"); 1001 return $self->find_instances($key->path, 'any'); 1002 } 1003 $log->logdie("database error: $@"); 1004 } 983 1005 984 1006 # XXX remove this? … … 1171 1193 my ($vol_id, $vol_host, $vol_path, $xattr); 1172 1194 eval { 1173 # TODO cache this?1174 1195 my $query; 1175 1196 my $rows; -
trunk/Nebulous-Server/lib/Test/Nebulous.pm
r19491 r19493 1 1 # Copyright (C) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Nebulous.pm,v 1. 3 2008-09-11 21:18:35 billsExp $3 # $Id: Nebulous.pm,v 1.4 2008-09-11 22:35:52 jhoblitt Exp $ 4 4 5 5 package Test::Nebulous; … … 32 32 my $dir5 = ""; 33 33 my $dir6 = ""; 34 my $dir7 = ""; 34 35 35 36 sub setup { … … 45 46 $dir5 = tempdir( CLEANUP => 0 ); 46 47 $dir6 = tempdir( CLEANUP => 0 ); 48 $dir7 = tempdir( CLEANUP => 0 ); 47 49 48 50 foreach my $statement (@{ $sql->get_db_schema }) { … … 70 72 71 73 # node06: allocate = TRUE, available = FALSE 72 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir 4);74 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (6, 'node06', 'node06', ?, TRUE, FALSE) }, undef, $dir6); 73 75 $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir6); 76 77 # node07: full 78 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, allocate, available) VALUES (7, 'node07', 'node07', ?, TRUE, TRUE) }, undef, $dir7); 79 $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e10) }, undef, $dir7); 74 80 75 81 $dbh->do(qq{ call getmountedvol() }); … … 88 94 rmtree([$dir5], 0, 1) if -e $dir5; 89 95 rmtree([$dir6], 0, 1) if -e $dir6; 96 rmtree([$dir7], 0, 1) if -e $dir7; 90 97 } 91 98 -
trunk/Nebulous-Server/t/03_server_create_object.t
r19470 r19493 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 03_server_create_object.t,v 1. 29 2008-09-10 23:53:23 billsExp $5 # $Id: 03_server_create_object.t,v 1.30 2008-09-11 22:35:52 jhoblitt Exp $ 6 6 7 7 use strict; … … 353 353 354 354 eval { 355 $neb->create_object("foo", '~node0 3');356 }; 357 like($@, qr/node0 3is not available/, "request volume this is full");358 359 Test::Nebulous->setup; 360 361 eval { 362 $neb->create_object("neb://~node0 3/foo");363 }; 364 like($@, qr/node0 3is not available/, "request volume this is full");355 $neb->create_object("foo", '~node07'); 356 }; 357 like($@, qr/node07 is not available/, "request volume this is full"); 358 359 Test::Nebulous->setup; 360 361 eval { 362 $neb->create_object("neb://~node07/foo"); 363 }; 364 like($@, qr/node07 is not available/, "request volume this is full"); 365 365 366 366 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/04_server_replicate_object.t
r19431 r19493 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 04_server_replicate_object.t,v 1.1 5 2008-09-09 02:18:47jhoblitt Exp $5 # $Id: 04_server_replicate_object.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $ 6 6 7 7 use strict; … … 155 155 Test::Nebulous->setup; 156 156 157 {157 eval { 158 158 $neb->create_object('foo'); 159 159 ok($neb->replicate_object('foo', 'bar'),'soft fake storage volume'); 160 } 160 }; 161 161 162 162 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/07_server_find_instances.t
r19471 r19493 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 07_server_find_instances.t,v 1.1 5 2008-09-10 23:54:22 billsExp $5 # $Id: 07_server_find_instances.t,v 1.16 2008-09-11 22:35:52 jhoblitt Exp $ 6 6 7 7 use strict; … … 121 121 eval { 122 122 $neb->create_object('foo'); 123 $neb->find_instances('foo', ' bar');123 $neb->find_instances('foo', '~bar'); 124 124 }; 125 like($@, qr/is valid volume name/, "storage volume does not exist");125 like($@, qr/is not a valid volume name/, "storage volume does not exist"); 126 126 127 127 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/15_mounts.t
r18389 r19493 3 3 # Copryight (C) 2008 Joshua Hoblitt 4 4 # 5 # $Id: 15_mounts.t,v 1. 2 2008-07-01 00:28:07jhoblitt Exp $5 # $Id: 15_mounts.t,v 1.3 2008-09-11 22:35:52 jhoblitt Exp $ 6 6 7 7 use strict; … … 28 28 my $mounts = $neb->mounts(); 29 29 30 is(scalar @$mounts, 6, "number of rows");30 is(scalar @$mounts, 7, "number of rows"); 31 31 32 32 my %row;
Note:
See TracChangeset
for help on using the changeset viewer.
