Changeset 13203
- Timestamp:
- May 3, 2007, 12:10:14 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (18 diffs)
-
Nebulous-Server/t/05_server_lock_object.t (modified) (6 diffs)
-
Nebulous-Server/t/06_server_unlock_object.t (modified) (6 diffs)
-
Nebulous-Server/t/13_server_rename_object.t (modified) (3 diffs)
-
Nebulous-Server/t/14_server_xattr.t (modified) (8 diffs)
-
Nebulous/lib/Nebulous/Server.pm (modified) (18 diffs)
-
Nebulous/t/05_server_lock_object.t (modified) (6 diffs)
-
Nebulous/t/06_server_unlock_object.t (modified) (6 diffs)
-
Nebulous/t/13_server_rename_object.t (modified) (3 diffs)
-
Nebulous/t/14_server_xattr.t (modified) (8 diffs)
-
Nebulous/t/63_client_stat.t (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r13180 r13203 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.3 3 2007-05-03 03:21:28jhoblitt Exp $3 # $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 244 244 { 245 245 type => SCALAR, 246 }, 247 { 248 type => SCALAR, 246 callbacks => { 247 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 248 }, 249 }, 250 # make sure the "newkey" doesn't already exist 251 { 252 type => SCALAR, 253 callbacks => { 254 'is not valid object key' => sub { not $self->_is_valid_object_key($_[0]) }, 255 }, 249 256 }, 250 257 ); … … 382 389 } 383 390 384 sub lock_object { 391 sub lock_object 392 { 385 393 my $self = shift; 386 394 … … 388 396 { 389 397 type => SCALAR, 398 callbacks => { 399 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 400 }, 390 401 }, 391 402 { … … 501 512 } 502 513 503 sub unlock_object { 514 sub unlock_object 515 { 504 516 my $self = shift; 505 517 … … 507 519 { 508 520 type => SCALAR, 521 callbacks => { 522 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 523 }, 509 524 }, 510 525 { … … 635 650 { 636 651 type => SCALAR, 652 callbacks => { 653 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 654 }, 637 655 }, 638 656 { … … 706 724 { 707 725 type => SCALAR, 726 callbacks => { 727 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 728 }, 708 729 }, 709 730 { … … 751 772 { 752 773 type => SCALAR, 774 callbacks => { 775 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 776 }, 753 777 }, 754 778 ); … … 789 813 { 790 814 type => SCALAR, 815 callbacks => { 816 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 817 }, 791 818 }, 792 819 { … … 831 858 832 859 833 sub find_objects { 860 sub find_objects 861 { 834 862 my $self = shift; 835 863 … … 870 898 871 899 872 sub find_instances { 900 sub find_instances 901 { 873 902 my $self = shift; 874 903 … … 939 968 } 940 969 941 sub delete_instance { 970 971 sub delete_instance 972 { 942 973 my $self = shift; 943 974 … … 983 1014 my $rows = $query->execute( $uri ); 984 1015 985 # if we affected something other then one row something very bad has happened 1016 # if we affected something other then one row something very bad 1017 # has happened 986 1018 unless ( $rows == 1 ) { 987 1019 $log->logdie( "affected row count is $rows instead of 1" ); … … 1016 1048 } 1017 1049 1018 sub stat_object { 1050 1051 sub stat_object 1052 { 1019 1053 my $self = shift; 1020 1054 … … 1123 1157 } 1124 1158 1125 sub _is_valid_object_key { 1159 1160 sub _is_valid_object_key 1161 { 1126 1162 my ($self, $key) = @_; 1127 1163 … … 1149 1185 } 1150 1186 1151 sub _is_valid_volume_name { 1187 1188 sub _is_valid_volume_name 1189 { 1152 1190 my ($self, $vol_name) = @_; 1153 1191 … … 1176 1214 } 1177 1215 1178 sub DESTROY { 1216 1217 sub DESTROY 1218 { 1179 1219 my $self = shift; 1180 1220 -
trunk/Nebulous-Server/t/05_server_lock_object.t
r12640 r13203 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 05_server_lock_object.t,v 1. 7 2007-03-28 21:32:54 jhoblitt Exp $5 # $Id: 05_server_lock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 52 52 $neb->lock_object("foo", "read"); 53 53 }; 54 like($@, qr/ storage object does not exist/, "storage object does not exist");54 like($@, qr/is valid object key/, "storage object does not exist"); 55 55 56 56 Test::Nebulous->setup; … … 59 59 $neb->lock_object("foo", "write"); 60 60 }; 61 like($@, qr/ storage object does not exist/, "storage object does not exist");61 like($@, qr/is valid object key/, "storage object does not exist"); 62 62 63 63 Test::Nebulous->setup; … … 101 101 102 102 eval { 103 $neb->create_object("foo"); 104 103 105 $neb->lock_object("foo"); 104 106 }; … … 108 110 109 111 eval { 112 $neb->create_object("foo"); 113 110 114 $neb->lock_object("foo", "both"); 111 115 }; … … 115 119 116 120 eval { 121 $neb->create_object("foo"); 122 117 123 $neb->lock_object("foo", 'read', 3); 118 124 }; -
trunk/Nebulous-Server/t/06_server_unlock_object.t
r12641 r13203 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 06_server_unlock_object.t,v 1. 7 2007-03-28 21:41:11jhoblitt Exp $5 # $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 59 59 $neb->unlock_object("foo", "read"); 60 60 }; 61 like($@, qr/ storage object does not exist/, "storage object does not exist");61 like($@, qr/is valid object key/, "storage object does not exist"); 62 62 63 63 Test::Nebulous->setup; … … 66 66 $neb->unlock_object("foo", "write"); 67 67 }; 68 like($@, qr/ storage object does not exist/, "storage object does not exist");68 like($@, qr/is valid object key/, "storage object does not exist"); 69 69 70 70 Test::Nebulous->setup; … … 116 116 117 117 eval { 118 $neb->create_object("foo"); 119 118 120 $neb->unlock_object("foo"); 119 121 }; … … 123 125 124 126 eval { 127 $neb->create_object("foo"); 128 125 129 $neb->unlock_object("foo", "both"); 126 130 }; … … 130 134 131 135 eval { 136 $neb->create_object("foo"); 137 132 138 $neb->unlock_object("foo", 'read', 3); 133 139 }; -
trunk/Nebulous-Server/t/13_server_rename_object.t
r13071 r13203 3 3 # Copryight (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: 13_server_rename_object.t,v 1. 1 2007-04-28 00:44:58jhoblitt Exp $5 # $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 5;10 use Test::More tests => 6; 11 11 12 12 use lib qw( ./t ./lib ); … … 37 37 Test::Nebulous->setup; 38 38 39 # destination key exists 40 eval { 41 $neb->create_object('foo'); 42 $neb->create_object('bar'); 43 44 $neb->rename_object('foo', 'bar'); 45 }; 46 like($@, qr/is not valid object key/, "too few params"); 47 48 Test::Nebulous->setup; 49 39 50 eval { 40 51 $neb->rename_object(); … … 42 53 like($@, qr/2 were expected/, "no params"); 43 54 44 Test::Nebulous-> cleanup;55 Test::Nebulous->setup; 45 56 46 57 eval { 58 $neb->create_object("foo"); 59 47 60 $neb->rename_object("foo"); 48 61 }; 49 62 like($@, qr/2 were expected/, "too few params"); 50 63 51 Test::Nebulous-> cleanup;64 Test::Nebulous->setup; 52 65 53 66 eval { 67 $neb->create_object("foo"); 68 54 69 $neb->rename_object("foo", "bar", "baz"); 55 70 }; -
trunk/Nebulous-Server/t/14_server_xattr.t
r13087 r13203 3 3 # Copryight (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: 14_server_xattr.t,v 1. 1 2007-05-01 02:00:07jhoblitt Exp $5 # $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 114 114 115 115 eval { 116 $neb->create_object('foo'); 117 116 118 $neb->setxattr_object('foo', 'bar'); 117 119 }; … … 121 123 122 124 eval { 125 $neb->create_object('foo'); 126 123 127 $neb->setxattr_object('foo', 'bar', 'baz'); 124 128 }; … … 128 132 129 133 eval { 134 $neb->create_object('foo'); 135 130 136 $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix'); 131 137 }; … … 137 143 138 144 eval { 145 $neb->create_object('foo'); 146 139 147 $neb->listxattr_object(); 140 148 }; … … 144 152 145 153 eval { 154 $neb->create_object('foo'); 155 146 156 $neb->listxattr_object('foo', 'bar'); 147 157 }; … … 160 170 161 171 eval { 172 $neb->create_object('foo'); 173 162 174 $neb->getxattr_object('foo'); 163 175 }; … … 167 179 168 180 eval { 181 $neb->create_object('foo'); 182 169 183 $neb->getxattr_object('foo', 'bar', 'baz'); 170 184 }; -
trunk/Nebulous/lib/Nebulous/Server.pm
r13180 r13203 1 1 # Copyright (c) 2004 Joshua Hoblitt 2 2 # 3 # $Id: Server.pm,v 1.3 3 2007-05-03 03:21:28jhoblitt Exp $3 # $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $ 4 4 5 5 package Nebulous::Server; … … 244 244 { 245 245 type => SCALAR, 246 }, 247 { 248 type => SCALAR, 246 callbacks => { 247 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 248 }, 249 }, 250 # make sure the "newkey" doesn't already exist 251 { 252 type => SCALAR, 253 callbacks => { 254 'is not valid object key' => sub { not $self->_is_valid_object_key($_[0]) }, 255 }, 249 256 }, 250 257 ); … … 382 389 } 383 390 384 sub lock_object { 391 sub lock_object 392 { 385 393 my $self = shift; 386 394 … … 388 396 { 389 397 type => SCALAR, 398 callbacks => { 399 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 400 }, 390 401 }, 391 402 { … … 501 512 } 502 513 503 sub unlock_object { 514 sub unlock_object 515 { 504 516 my $self = shift; 505 517 … … 507 519 { 508 520 type => SCALAR, 521 callbacks => { 522 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 523 }, 509 524 }, 510 525 { … … 635 650 { 636 651 type => SCALAR, 652 callbacks => { 653 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 654 }, 637 655 }, 638 656 { … … 706 724 { 707 725 type => SCALAR, 726 callbacks => { 727 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 728 }, 708 729 }, 709 730 { … … 751 772 { 752 773 type => SCALAR, 774 callbacks => { 775 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 776 }, 753 777 }, 754 778 ); … … 789 813 { 790 814 type => SCALAR, 815 callbacks => { 816 'is valid object key' => sub { $self->_is_valid_object_key($_[0]) }, 817 }, 791 818 }, 792 819 { … … 831 858 832 859 833 sub find_objects { 860 sub find_objects 861 { 834 862 my $self = shift; 835 863 … … 870 898 871 899 872 sub find_instances { 900 sub find_instances 901 { 873 902 my $self = shift; 874 903 … … 939 968 } 940 969 941 sub delete_instance { 970 971 sub delete_instance 972 { 942 973 my $self = shift; 943 974 … … 983 1014 my $rows = $query->execute( $uri ); 984 1015 985 # if we affected something other then one row something very bad has happened 1016 # if we affected something other then one row something very bad 1017 # has happened 986 1018 unless ( $rows == 1 ) { 987 1019 $log->logdie( "affected row count is $rows instead of 1" ); … … 1016 1048 } 1017 1049 1018 sub stat_object { 1050 1051 sub stat_object 1052 { 1019 1053 my $self = shift; 1020 1054 … … 1123 1157 } 1124 1158 1125 sub _is_valid_object_key { 1159 1160 sub _is_valid_object_key 1161 { 1126 1162 my ($self, $key) = @_; 1127 1163 … … 1149 1185 } 1150 1186 1151 sub _is_valid_volume_name { 1187 1188 sub _is_valid_volume_name 1189 { 1152 1190 my ($self, $vol_name) = @_; 1153 1191 … … 1176 1214 } 1177 1215 1178 sub DESTROY { 1216 1217 sub DESTROY 1218 { 1179 1219 my $self = shift; 1180 1220 -
trunk/Nebulous/t/05_server_lock_object.t
r12640 r13203 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 05_server_lock_object.t,v 1. 7 2007-03-28 21:32:54 jhoblitt Exp $5 # $Id: 05_server_lock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 52 52 $neb->lock_object("foo", "read"); 53 53 }; 54 like($@, qr/ storage object does not exist/, "storage object does not exist");54 like($@, qr/is valid object key/, "storage object does not exist"); 55 55 56 56 Test::Nebulous->setup; … … 59 59 $neb->lock_object("foo", "write"); 60 60 }; 61 like($@, qr/ storage object does not exist/, "storage object does not exist");61 like($@, qr/is valid object key/, "storage object does not exist"); 62 62 63 63 Test::Nebulous->setup; … … 101 101 102 102 eval { 103 $neb->create_object("foo"); 104 103 105 $neb->lock_object("foo"); 104 106 }; … … 108 110 109 111 eval { 112 $neb->create_object("foo"); 113 110 114 $neb->lock_object("foo", "both"); 111 115 }; … … 115 119 116 120 eval { 121 $neb->create_object("foo"); 122 117 123 $neb->lock_object("foo", 'read', 3); 118 124 }; -
trunk/Nebulous/t/06_server_unlock_object.t
r12641 r13203 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 06_server_unlock_object.t,v 1. 7 2007-03-28 21:41:11jhoblitt Exp $5 # $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 59 59 $neb->unlock_object("foo", "read"); 60 60 }; 61 like($@, qr/ storage object does not exist/, "storage object does not exist");61 like($@, qr/is valid object key/, "storage object does not exist"); 62 62 63 63 Test::Nebulous->setup; … … 66 66 $neb->unlock_object("foo", "write"); 67 67 }; 68 like($@, qr/ storage object does not exist/, "storage object does not exist");68 like($@, qr/is valid object key/, "storage object does not exist"); 69 69 70 70 Test::Nebulous->setup; … … 116 116 117 117 eval { 118 $neb->create_object("foo"); 119 118 120 $neb->unlock_object("foo"); 119 121 }; … … 123 125 124 126 eval { 127 $neb->create_object("foo"); 128 125 129 $neb->unlock_object("foo", "both"); 126 130 }; … … 130 134 131 135 eval { 136 $neb->create_object("foo"); 137 132 138 $neb->unlock_object("foo", 'read', 3); 133 139 }; -
trunk/Nebulous/t/13_server_rename_object.t
r13071 r13203 3 3 # Copryight (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: 13_server_rename_object.t,v 1. 1 2007-04-28 00:44:58jhoblitt Exp $5 # $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 5;10 use Test::More tests => 6; 11 11 12 12 use lib qw( ./t ./lib ); … … 37 37 Test::Nebulous->setup; 38 38 39 # destination key exists 40 eval { 41 $neb->create_object('foo'); 42 $neb->create_object('bar'); 43 44 $neb->rename_object('foo', 'bar'); 45 }; 46 like($@, qr/is not valid object key/, "too few params"); 47 48 Test::Nebulous->setup; 49 39 50 eval { 40 51 $neb->rename_object(); … … 42 53 like($@, qr/2 were expected/, "no params"); 43 54 44 Test::Nebulous-> cleanup;55 Test::Nebulous->setup; 45 56 46 57 eval { 58 $neb->create_object("foo"); 59 47 60 $neb->rename_object("foo"); 48 61 }; 49 62 like($@, qr/2 were expected/, "too few params"); 50 63 51 Test::Nebulous-> cleanup;64 Test::Nebulous->setup; 52 65 53 66 eval { 67 $neb->create_object("foo"); 68 54 69 $neb->rename_object("foo", "bar", "baz"); 55 70 }; -
trunk/Nebulous/t/14_server_xattr.t
r13087 r13203 3 3 # Copryight (C) 2007 Joshua Hoblitt 4 4 # 5 # $Id: 14_server_xattr.t,v 1. 1 2007-05-01 02:00:07jhoblitt Exp $5 # $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 114 114 115 115 eval { 116 $neb->create_object('foo'); 117 116 118 $neb->setxattr_object('foo', 'bar'); 117 119 }; … … 121 123 122 124 eval { 125 $neb->create_object('foo'); 126 123 127 $neb->setxattr_object('foo', 'bar', 'baz'); 124 128 }; … … 128 132 129 133 eval { 134 $neb->create_object('foo'); 135 130 136 $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix'); 131 137 }; … … 137 143 138 144 eval { 145 $neb->create_object('foo'); 146 139 147 $neb->listxattr_object(); 140 148 }; … … 144 152 145 153 eval { 154 $neb->create_object('foo'); 155 146 156 $neb->listxattr_object('foo', 'bar'); 147 157 }; … … 160 170 161 171 eval { 172 $neb->create_object('foo'); 173 162 174 $neb->getxattr_object('foo'); 163 175 }; … … 167 179 168 180 eval { 181 $neb->create_object('foo'); 182 169 183 $neb->getxattr_object('foo', 'bar', 'baz'); 170 184 }; -
trunk/Nebulous/t/63_client_stat.t
r13092 r13203 3 3 # Copryight (C) 2004-2005 Joshua Hoblitt 4 4 # 5 # $Id: 63_client_stat.t,v 1. 2 2007-05-01 02:52:04 jhoblitt Exp $5 # $Id: 63_client_stat.t,v 1.3 2007-05-03 22:10:14 jhoblitt Exp $ 6 6 7 7 use strict; … … 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 1 1;12 plan tests => 12; 13 13 14 14 use lib qw( ./t ./lib ); … … 30 30 my $info = $neb->stat( "foo" ); 31 31 32 is( scalar @$info, 6, "number of columns" );32 is( scalar @$info, 7, "number of columns" ); 33 33 } 34 34 … … 43 43 my $info = $neb->stat( "foo" ); 44 44 45 is( scalar @$info, 6, "number of columns" );45 is( scalar @$info, 7, "number of columns" ); 46 46 is( @$info[0], 1, "so_id" ); 47 47 is( @$info[1], "foo", "ext_id" ); … … 50 50 like( @$info[4], qr/....-..-.. ..:..:../, "epoch" ); 51 51 like( @$info[5], qr/....-..-.. ..:..:../, "mtime" ); 52 is( @$info[6], 1, "instances" ); 52 53 } 53 54
Note:
See TracChangeset
for help on using the changeset viewer.
