IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13203


Ignore:
Timestamp:
May 3, 2007, 12:10:14 PM (19 years ago)
Author:
jhoblitt
Message:

valid that $key arguments are valid

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/lib/Nebulous/Server.pm

    r13180 r13203  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.33 2007-05-03 03:21:28 jhoblitt Exp $
     3# $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    244244        {
    245245            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            },
    249256        },
    250257    );
     
    382389}
    383390
    384 sub lock_object {
     391sub lock_object
     392{
    385393    my $self = shift;
    386394
     
    388396        {
    389397            type        => SCALAR,
     398            callbacks   => {
     399                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     400            },
    390401        },
    391402        {
     
    501512}
    502513
    503 sub unlock_object {
     514sub unlock_object
     515{
    504516    my $self = shift;
    505517
     
    507519        {
    508520            type        => SCALAR,
     521            callbacks   => {
     522                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     523            },
    509524        },
    510525        {
     
    635650        {
    636651            type        => SCALAR,
     652            callbacks   => {
     653                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     654            },
    637655        },
    638656        {
     
    706724        {
    707725            type        => SCALAR,
     726            callbacks   => {
     727                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     728            },
    708729        },
    709730        {
     
    751772        {
    752773            type        => SCALAR,
     774            callbacks   => {
     775                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     776            },
    753777        },
    754778    );
     
    789813        {
    790814            type        => SCALAR,
     815            callbacks   => {
     816                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     817            },
    791818        },
    792819        {
     
    831858
    832859
    833 sub find_objects {
     860sub find_objects
     861{
    834862    my $self = shift;
    835863
     
    870898
    871899
    872 sub find_instances {
     900sub find_instances
     901{
    873902    my $self = shift;
    874903
     
    939968}
    940969
    941 sub delete_instance {
     970
     971sub delete_instance
     972{
    942973    my $self = shift;
    943974
     
    9831014            my $rows = $query->execute( $uri );
    9841015           
    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
    9861018            unless ( $rows == 1 ) {
    9871019                $log->logdie( "affected row count is $rows instead of 1" );
     
    10161048}
    10171049
    1018 sub stat_object {
     1050
     1051sub stat_object
     1052{
    10191053    my $self = shift;
    10201054
     
    11231157}
    11241158
    1125 sub _is_valid_object_key  {
     1159
     1160sub _is_valid_object_key
     1161{
    11261162    my ($self, $key) = @_;
    11271163
     
    11491185}
    11501186
    1151 sub _is_valid_volume_name  {
     1187
     1188sub _is_valid_volume_name
     1189{
    11521190    my ($self, $vol_name) = @_;
    11531191
     
    11761214}
    11771215
    1178 sub DESTROY {
     1216
     1217sub DESTROY
     1218{
    11791219    my $self = shift;
    11801220
  • trunk/Nebulous-Server/t/05_server_lock_object.t

    r12640 r13203  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    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 $
    66
    77use strict;
     
    5252    $neb->lock_object("foo", "read");
    5353};
    54 like($@, qr/storage object does not exist/, "storage object does not exist");
     54like($@, qr/is valid object key/, "storage object does not exist");
    5555
    5656Test::Nebulous->setup;
     
    5959    $neb->lock_object("foo", "write");
    6060};
    61 like($@, qr/storage object does not exist/, "storage object does not exist");
     61like($@, qr/is valid object key/, "storage object does not exist");
    6262
    6363Test::Nebulous->setup;
     
    101101
    102102eval {
     103    $neb->create_object("foo");
     104
    103105    $neb->lock_object("foo");
    104106};
     
    108110
    109111eval {
     112    $neb->create_object("foo");
     113
    110114    $neb->lock_object("foo", "both");
    111115};
     
    115119
    116120eval {
     121    $neb->create_object("foo");
     122
    117123    $neb->lock_object("foo", 'read', 3);
    118124};
  • trunk/Nebulous-Server/t/06_server_unlock_object.t

    r12641 r13203  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 06_server_unlock_object.t,v 1.7 2007-03-28 21:41:11 jhoblitt Exp $
     5# $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
     
    5959    $neb->unlock_object("foo", "read");
    6060};
    61 like($@, qr/storage object does not exist/, "storage object does not exist");
     61like($@, qr/is valid object key/, "storage object does not exist");
    6262
    6363Test::Nebulous->setup;
     
    6666    $neb->unlock_object("foo", "write");
    6767};
    68 like($@, qr/storage object does not exist/, "storage object does not exist");
     68like($@, qr/is valid object key/, "storage object does not exist");
    6969
    7070Test::Nebulous->setup;
     
    116116
    117117eval {
     118    $neb->create_object("foo");
     119
    118120    $neb->unlock_object("foo");
    119121};
     
    123125
    124126eval {
     127    $neb->create_object("foo");
     128
    125129    $neb->unlock_object("foo", "both");
    126130};
     
    130134
    131135eval {
     136    $neb->create_object("foo");
     137
    132138    $neb->unlock_object("foo", 'read', 3);
    133139};
  • trunk/Nebulous-Server/t/13_server_rename_object.t

    r13071 r13203  
    33# Copryight (C) 2007  Joshua Hoblitt
    44#
    5 # $Id: 13_server_rename_object.t,v 1.1 2007-04-28 00:44:58 jhoblitt Exp $
     5# $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 5;
     10use Test::More tests => 6;
    1111
    1212use lib qw( ./t ./lib );
     
    3737Test::Nebulous->setup;
    3838
     39# destination key exists
     40eval {
     41    $neb->create_object('foo');
     42    $neb->create_object('bar');
     43
     44    $neb->rename_object('foo', 'bar');
     45};
     46like($@, qr/is not valid object key/, "too few params");
     47
     48Test::Nebulous->setup;
     49
    3950eval {
    4051    $neb->rename_object();
     
    4253like($@, qr/2 were expected/, "no params");
    4354
    44 Test::Nebulous->cleanup;
     55Test::Nebulous->setup;
    4556
    4657eval {
     58    $neb->create_object("foo");
     59
    4760    $neb->rename_object("foo");
    4861};
    4962like($@, qr/2 were expected/, "too few params");
    5063
    51 Test::Nebulous->cleanup;
     64Test::Nebulous->setup;
    5265
    5366eval {
     67    $neb->create_object("foo");
     68
    5469    $neb->rename_object("foo", "bar", "baz");
    5570};
  • trunk/Nebulous-Server/t/14_server_xattr.t

    r13087 r13203  
    33# Copryight (C) 2007  Joshua Hoblitt
    44#
    5 # $Id: 14_server_xattr.t,v 1.1 2007-05-01 02:00:07 jhoblitt Exp $
     5# $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
     
    114114
    115115eval {
     116    $neb->create_object('foo');
     117
    116118    $neb->setxattr_object('foo', 'bar');
    117119};
     
    121123
    122124eval {
     125    $neb->create_object('foo');
     126
    123127    $neb->setxattr_object('foo', 'bar', 'baz');
    124128};
     
    128132
    129133eval {
     134    $neb->create_object('foo');
     135
    130136    $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix');
    131137};
     
    137143
    138144eval {
     145    $neb->create_object('foo');
     146
    139147    $neb->listxattr_object();
    140148};
     
    144152
    145153eval {
     154    $neb->create_object('foo');
     155
    146156    $neb->listxattr_object('foo', 'bar');
    147157};
     
    160170
    161171eval {
     172    $neb->create_object('foo');
     173
    162174    $neb->getxattr_object('foo');
    163175};
     
    167179
    168180eval {
     181    $neb->create_object('foo');
     182
    169183    $neb->getxattr_object('foo', 'bar', 'baz');
    170184};
  • trunk/Nebulous/lib/Nebulous/Server.pm

    r13180 r13203  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Server.pm,v 1.33 2007-05-03 03:21:28 jhoblitt Exp $
     3# $Id: Server.pm,v 1.34 2007-05-03 22:10:13 jhoblitt Exp $
    44
    55package Nebulous::Server;
     
    244244        {
    245245            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            },
    249256        },
    250257    );
     
    382389}
    383390
    384 sub lock_object {
     391sub lock_object
     392{
    385393    my $self = shift;
    386394
     
    388396        {
    389397            type        => SCALAR,
     398            callbacks   => {
     399                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     400            },
    390401        },
    391402        {
     
    501512}
    502513
    503 sub unlock_object {
     514sub unlock_object
     515{
    504516    my $self = shift;
    505517
     
    507519        {
    508520            type        => SCALAR,
     521            callbacks   => {
     522                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     523            },
    509524        },
    510525        {
     
    635650        {
    636651            type        => SCALAR,
     652            callbacks   => {
     653                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     654            },
    637655        },
    638656        {
     
    706724        {
    707725            type        => SCALAR,
     726            callbacks   => {
     727                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     728            },
    708729        },
    709730        {
     
    751772        {
    752773            type        => SCALAR,
     774            callbacks   => {
     775                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     776            },
    753777        },
    754778    );
     
    789813        {
    790814            type        => SCALAR,
     815            callbacks   => {
     816                'is valid object key' => sub { $self->_is_valid_object_key($_[0]) },
     817            },
    791818        },
    792819        {
     
    831858
    832859
    833 sub find_objects {
     860sub find_objects
     861{
    834862    my $self = shift;
    835863
     
    870898
    871899
    872 sub find_instances {
     900sub find_instances
     901{
    873902    my $self = shift;
    874903
     
    939968}
    940969
    941 sub delete_instance {
     970
     971sub delete_instance
     972{
    942973    my $self = shift;
    943974
     
    9831014            my $rows = $query->execute( $uri );
    9841015           
    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
    9861018            unless ( $rows == 1 ) {
    9871019                $log->logdie( "affected row count is $rows instead of 1" );
     
    10161048}
    10171049
    1018 sub stat_object {
     1050
     1051sub stat_object
     1052{
    10191053    my $self = shift;
    10201054
     
    11231157}
    11241158
    1125 sub _is_valid_object_key  {
     1159
     1160sub _is_valid_object_key
     1161{
    11261162    my ($self, $key) = @_;
    11271163
     
    11491185}
    11501186
    1151 sub _is_valid_volume_name  {
     1187
     1188sub _is_valid_volume_name
     1189{
    11521190    my ($self, $vol_name) = @_;
    11531191
     
    11761214}
    11771215
    1178 sub DESTROY {
     1216
     1217sub DESTROY
     1218{
    11791219    my $self = shift;
    11801220
  • trunk/Nebulous/t/05_server_lock_object.t

    r12640 r13203  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    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 $
    66
    77use strict;
     
    5252    $neb->lock_object("foo", "read");
    5353};
    54 like($@, qr/storage object does not exist/, "storage object does not exist");
     54like($@, qr/is valid object key/, "storage object does not exist");
    5555
    5656Test::Nebulous->setup;
     
    5959    $neb->lock_object("foo", "write");
    6060};
    61 like($@, qr/storage object does not exist/, "storage object does not exist");
     61like($@, qr/is valid object key/, "storage object does not exist");
    6262
    6363Test::Nebulous->setup;
     
    101101
    102102eval {
     103    $neb->create_object("foo");
     104
    103105    $neb->lock_object("foo");
    104106};
     
    108110
    109111eval {
     112    $neb->create_object("foo");
     113
    110114    $neb->lock_object("foo", "both");
    111115};
     
    115119
    116120eval {
     121    $neb->create_object("foo");
     122
    117123    $neb->lock_object("foo", 'read', 3);
    118124};
  • trunk/Nebulous/t/06_server_unlock_object.t

    r12641 r13203  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    5 # $Id: 06_server_unlock_object.t,v 1.7 2007-03-28 21:41:11 jhoblitt Exp $
     5# $Id: 06_server_unlock_object.t,v 1.8 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
     
    5959    $neb->unlock_object("foo", "read");
    6060};
    61 like($@, qr/storage object does not exist/, "storage object does not exist");
     61like($@, qr/is valid object key/, "storage object does not exist");
    6262
    6363Test::Nebulous->setup;
     
    6666    $neb->unlock_object("foo", "write");
    6767};
    68 like($@, qr/storage object does not exist/, "storage object does not exist");
     68like($@, qr/is valid object key/, "storage object does not exist");
    6969
    7070Test::Nebulous->setup;
     
    116116
    117117eval {
     118    $neb->create_object("foo");
     119
    118120    $neb->unlock_object("foo");
    119121};
     
    123125
    124126eval {
     127    $neb->create_object("foo");
     128
    125129    $neb->unlock_object("foo", "both");
    126130};
     
    130134
    131135eval {
     136    $neb->create_object("foo");
     137
    132138    $neb->unlock_object("foo", 'read', 3);
    133139};
  • trunk/Nebulous/t/13_server_rename_object.t

    r13071 r13203  
    33# Copryight (C) 2007  Joshua Hoblitt
    44#
    5 # $Id: 13_server_rename_object.t,v 1.1 2007-04-28 00:44:58 jhoblitt Exp $
     5# $Id: 13_server_rename_object.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
    88use warnings FATAL => qw( all );
    99
    10 use Test::More tests => 5;
     10use Test::More tests => 6;
    1111
    1212use lib qw( ./t ./lib );
     
    3737Test::Nebulous->setup;
    3838
     39# destination key exists
     40eval {
     41    $neb->create_object('foo');
     42    $neb->create_object('bar');
     43
     44    $neb->rename_object('foo', 'bar');
     45};
     46like($@, qr/is not valid object key/, "too few params");
     47
     48Test::Nebulous->setup;
     49
    3950eval {
    4051    $neb->rename_object();
     
    4253like($@, qr/2 were expected/, "no params");
    4354
    44 Test::Nebulous->cleanup;
     55Test::Nebulous->setup;
    4556
    4657eval {
     58    $neb->create_object("foo");
     59
    4760    $neb->rename_object("foo");
    4861};
    4962like($@, qr/2 were expected/, "too few params");
    5063
    51 Test::Nebulous->cleanup;
     64Test::Nebulous->setup;
    5265
    5366eval {
     67    $neb->create_object("foo");
     68
    5469    $neb->rename_object("foo", "bar", "baz");
    5570};
  • trunk/Nebulous/t/14_server_xattr.t

    r13087 r13203  
    33# Copryight (C) 2007  Joshua Hoblitt
    44#
    5 # $Id: 14_server_xattr.t,v 1.1 2007-05-01 02:00:07 jhoblitt Exp $
     5# $Id: 14_server_xattr.t,v 1.2 2007-05-03 22:10:14 jhoblitt Exp $
    66
    77use strict;
     
    114114
    115115eval {
     116    $neb->create_object('foo');
     117
    116118    $neb->setxattr_object('foo', 'bar');
    117119};
     
    121123
    122124eval {
     125    $neb->create_object('foo');
     126
    123127    $neb->setxattr_object('foo', 'bar', 'baz');
    124128};
     
    128132
    129133eval {
     134    $neb->create_object('foo');
     135
    130136    $neb->setxattr_object('foo', 'bar', 'baz', 'create', 'quix');
    131137};
     
    137143
    138144eval {
     145    $neb->create_object('foo');
     146
    139147    $neb->listxattr_object();
    140148};
     
    144152
    145153eval {
     154    $neb->create_object('foo');
     155
    146156    $neb->listxattr_object('foo', 'bar');
    147157};
     
    160170
    161171eval {
     172    $neb->create_object('foo');
     173
    162174    $neb->getxattr_object('foo');
    163175};
     
    167179
    168180eval {
     181    $neb->create_object('foo');
     182
    169183    $neb->getxattr_object('foo', 'bar', 'baz');
    170184};
  • trunk/Nebulous/t/63_client_stat.t

    r13092 r13203  
    33# Copryight (C) 2004-2005  Joshua Hoblitt
    44#
    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 $
    66
    77use strict;
     
    1010use Apache::Test qw( -withtestmore );
    1111
    12 plan tests => 11;
     12plan tests => 12;
    1313
    1414use lib qw( ./t ./lib );
     
    3030    my $info = $neb->stat( "foo" );
    3131
    32     is( scalar @$info, 6, "number of columns" );
     32    is( scalar @$info, 7, "number of columns" );
    3333}
    3434
     
    4343    my $info = $neb->stat( "foo" );
    4444
    45     is( scalar @$info, 6,                       "number of columns" );
     45    is( scalar @$info, 7,                       "number of columns" );
    4646    is( @$info[0], 1,                           "so_id" );
    4747    is( @$info[1], "foo",                       "ext_id" );
     
    5050    like( @$info[4], qr/....-..-.. ..:..:../,   "epoch" );
    5151    like( @$info[5], qr/....-..-.. ..:..:../,   "mtime" );
     52    is( @$info[6], 1,                           "instances" );
    5253}
    5354
Note: See TracChangeset for help on using the changeset viewer.