Changeset 41172
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 45 edited
- 5 copied
-
Nebulous-Server/Build.PL (modified) (2 diffs)
-
Nebulous-Server/MANIFEST (modified) (1 diff)
-
Nebulous-Server/bin/neb-voladd (modified) (1 diff)
-
Nebulous-Server/docs/apache2-mod_perl-startup.pl (modified) (1 diff)
-
Nebulous-Server/docs/install.txt (modified) (1 diff)
-
Nebulous-Server/lib/Nebulous/Server.pm (modified) (60 diffs)
-
Nebulous-Server/lib/Nebulous/Server/SQL.pm (modified) (1 diff)
-
Nebulous-Server/lib/Test/Nebulous.pm (modified) (6 diffs)
-
Nebulous-Server/scripts/mkdirs.mana (copied) (copied from branches/eam_branches/ipp-20191011/Nebulous-Server/scripts/mkdirs.mana )
-
Nebulous-Server/scripts/stest.sh (copied) (copied from branches/eam_branches/ipp-20191011/Nebulous-Server/scripts/stest.sh )
-
Nebulous-Server/t/03_server_setup.t (modified) (1 diff)
-
Nebulous-Server/t/04_server_create_object.t (modified) (5 diffs)
-
Nebulous-Server/t/05_server_replicate_object.t (modified) (6 diffs)
-
Nebulous-Server/t/08_server_find_instances.t (modified) (10 diffs)
-
Nebulous-Server/t/11_server_is_valid_volume_name.t (modified) (2 diffs)
-
Nebulous-Server/t/15_server_xattr.t (modified) (1 diff)
-
Nebulous-Server/t/16_mounts.t (modified) (3 diffs)
-
Nebulous-Server/t/18_server_chmod_object.t (modified) (3 diffs)
-
Nebulous-Server/t/20_server_find_objects_wildcard.t (copied) (copied from branches/eam_branches/ipp-20191011/Nebulous-Server/t/20_server_find_objects_wildcard.t )
-
Nebulous/Build.PL (modified) (1 diff)
-
Nebulous/bin/neb-cat (modified) (3 diffs)
-
Nebulous/bin/neb-cp (modified) (2 diffs)
-
Nebulous/bin/neb-cull (modified) (3 diffs)
-
Nebulous/bin/neb-insert (modified) (1 diff)
-
Nebulous/bin/neb-ls (modified) (5 diffs)
-
Nebulous/bin/neb-migrate (modified) (1 diff)
-
Nebulous/bin/neb-repair (modified) (7 diffs)
-
Nebulous/bin/neb-replicate (modified) (2 diffs)
-
Nebulous/bin/neb-shift (modified) (1 diff)
-
Nebulous/bin/neb-stat (modified) (8 diffs)
-
Nebulous/lib/Nebulous/Client.pm (modified) (22 diffs)
-
Nebulous/lib/Nebulous/Util.pm (modified) (2 diffs)
-
Nebulous/nebclient (modified) (1 prop)
-
Nebulous/nebclient/tests/tap (modified) (1 prop)
-
Nebulous/nebclient/tests/tap/INSTALL (deleted)
-
Nebulous/nebclient/tests/tap/INSTALL.txt (copied) (copied from branches/eam_branches/ipp-20191011/Nebulous/nebclient/tests/tap/INSTALL.txt )
-
Nebulous/nebclient/tests/tests.c (modified) (4 diffs)
-
Nebulous/scripts/cmdtests.sh (copied) (copied from branches/eam_branches/ipp-20191011/Nebulous/scripts/cmdtests.sh )
-
Nebulous/t/50_client_create.t (modified) (6 diffs)
-
Nebulous/t/53_client_cull.t (modified) (6 diffs)
-
Nebulous/t/56_client_find_instances.t (modified) (10 diffs)
-
Nebulous/t/59_client_delete.t (modified) (7 diffs)
-
Nebulous/t/64_client_find_objects.t (modified) (1 diff)
-
Nebulous/t/65_client_mounts.t (modified) (1 diff)
-
Nebulous/t/66_client_xattr.t (modified) (4 diffs)
-
Nebulous/t/68_client_chmod.t (modified) (3 diffs)
-
Nebulous/t/70_neb-ls.t (modified) (11 diffs)
-
Nebulous/t/71_client_there_can_be_only_one.t (modified) (5 diffs)
-
Nebulous/t/72_neb-cull.t (modified) (6 diffs)
-
Nebulous/t/conf/extra.conf.in (modified) (1 diff)
-
Nebulous/t/conf/startup.pl.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/Build.PL
r39926 r41172 43 43 }, 44 44 script_files => [qw( 45 bin/neb-admin46 bin/neb-fsck47 45 bin/neb-cabadd 48 46 bin/neb-voladd … … 54 52 )], 55 53 )->create_build_script; 54 55 # these scripts are no longer installed (2019.10.31) 56 # bin/neb-admin 57 # bin/neb-fsck -
trunk/Nebulous-Server/MANIFEST
r32383 r41172 4 4 MANIFEST 5 5 README 6 bin/neb-admin7 bin/neb-fsck8 bin/neb-initdb9 6 bin/neb-voladd 10 7 bin/neb-cabadd -
trunk/Nebulous-Server/bin/neb-voladd
r28492 r41172 43 43 44 44 my $dbh = DBI->connect( 45 # if you want to work with the localhost database but get socket path errors, 46 # you should set the server host as 127.0.0.1 (not localhost) 47 48 # the following tells DBI to read the mysql/my.cnf files 49 # "DBI:mysql:database=$db:host=$dbhost:mysql_read_default_group=dbd_mysql", 50 45 51 "DBI:mysql:database=$db:host=$dbhost", 46 52 $dbuser, -
trunk/Nebulous-Server/docs/apache2-mod_perl-startup.pl
r23687 r41172 28 28 use Nebulous::Server; 29 29 30 my $dsn = 'DBI:mysql:database=nebulous:host= ipp019.ifa.hawaii.edu';30 my $dsn = 'DBI:mysql:database=nebulous:host=nebulous.ipp.ifa.hawaii.edu'; 31 31 my $dbuser = 'nebulous'; 32 my $dbpasswd = ' @neb@';32 my $dbpasswd = 'XXXX'; 33 33 34 34 #$Apache::DBI::DEBUG = 1; 35 35 #Apache::DBI->connect_on_init( $dsn, $dbuser, $dbpasswd ); 36 36 Apache::DBI->setPingTimeOut($dsn, 10); 37 Nebulous::Server::SOAP->new_on_init( 37 38 my $config = Nebulous::Server::Config->new( 39 trace => 'warn', 40 ); 41 $config->add_db( 42 dbindex => 0, 38 43 dsn => $dsn, 39 44 dbuser => $dbuser, 40 45 dbpasswd => $dbpasswd, 41 log_level => 'all', 42 ); 46 ); 47 48 Nebulous::Server::SOAP->new_on_init($config); 49 43 50 44 51 1; -
trunk/Nebulous-Server/docs/install.txt
r23687 r41172 55 55 export NEB_PASS=@neb@ 56 56 57 *** this is very dangerous and should only be run in test examples: 57 58 neb-initdb 58 59 59 neb-voladd --vhost ipp000 --vname ipp000.0 --uri file:///data/ipp000.0/nebulous 60 neb-voladd --vhost ipp001 --vname ipp000.1 --uri file:///data/ipp000.1/nebulous 61 neb-voladd --vhost ipp002 --vname ipp002.0 --uri file:///data/ipp002.0/nebulous 62 neb-voladd --vhost ipp003 --vname ipp003.0 --uri file:///data/ipp003.0/nebulous 63 neb-voladd --vhost ipp022 --vname ipp022.0 --uri file:///data/ipp022.0/nebulous 60 neb-voladd --vhost ipp000 --vname ipp000.0 --uri file:///data/ipp000.0/nebulous --mountpoint /data/ipp000.0/nebulous 61 neb-voladd --vhost ipp001 --vname ipp000.1 --uri file:///data/ipp000.1/nebulous --mountpoint /data/ipp000.1/nebulous 62 neb-voladd --vhost ipp002 --vname ipp002.0 --uri file:///data/ipp002.0/nebulous --mountpoint /data/ipp002.0/nebulous 63 neb-voladd --vhost ipp003 --vname ipp003.0 --uri file:///data/ipp003.0/nebulous --mountpoint /data/ipp003.0/nebulous 64 neb-voladd --vhost ipp022 --vname ipp022.0 --uri file:///data/ipp022.0/nebulous --mountpoint /data/ipp022.0/nebulous 64 65 65 66 # or in bulk: -
trunk/Nebulous-Server/lib/Nebulous/Server.pm
r39926 r41172 13 13 use base qw( Class::Accessor::Fast ); 14 14 15 use Carp; 16 15 17 use Cache::Memcached; 16 18 use DBI; 19 20 ## for gentoo: 17 21 use Digest::SHA1 qw( sha1_hex ); 22 23 ## for ubuntu: 24 # use Digest::SHA qw( sha1_hex ); 25 18 26 use Fcntl ':mode'; 19 27 use File::Basename qw( basename dirname fileparse ); … … 77 85 Cache::Memcached->new({ 78 86 servers => $config->memcached_servers, 79 })80 );87 }) 88 ); 81 89 # $self->cache->set("foo", "bar") or die "set failed"; 82 90 # $self->cache->get("foo") or die "get failed"; … … 215 223 } 216 224 225 my $get_storage_volume_calls = 0; 226 217 227 sub create_object 218 228 { … … 252 262 # the key's volume can't be validiated on input for this method so we have 253 263 # to check it after parsing the key 254 if (defined $vol_name 255 and not $self->_is_valid_volume_name($key, $key->volume)) { 264 if (defined $vol_name and not $self->_is_valid_volume_name($key, $key->volume)) { 256 265 unless ($key->hard_volume) { 257 266 $log->warn( "$vol_name is not a known volume name" ); … … 262 271 } 263 272 273 $get_storage_volume_calls = 0; 274 264 275 my ($vol_id, $vol_host, $vol_path, $vol_xattr) 265 276 = $self->_get_storage_volume($key, $vol_name, $key->hard_volume); … … 273 284 # create storage_object 274 285 my $query = $db->prepare_cached( $sql->new_object ); 275 $query->execute('NULL', $key->path, basename($key->path), $parent_id); 286 # bad syntax $query->execute('NULL', $key->path, basename($key->path), $parent_id); 287 $query->execute(0, $key->path, basename($key->path), $parent_id); 288 $query->finish; 276 289 } 277 290 … … 292 305 my $query = $db->prepare_cached( $sql->new_object_attr ); 293 306 $query->execute($so_id); 307 $query->finish; 294 308 } 295 309 … … 300 314 my $query = $db->prepare_cached( $sql->new_object_instance ); 301 315 $query->execute($vol_id); 316 $query->finish; 302 317 } 303 318 … … 327 342 # vol_id, uri, ins_id 328 343 $query->execute($vol_id, "$uri", $ins_id); 344 $query->finish; 329 345 } 330 346 … … 421 437 } 422 438 $query->finish; 439 $db->commit; 423 440 } 424 441 … … 441 458 my $query = $db->prepare_cached($sql->new_directory); 442 459 $query->execute($dir, $parent_id); 460 $query->finish; 461 $db->commit; 443 462 } 444 463 … … 452 471 ($parent_id) = $query->fetchrow_array; 453 472 $query->finish; 473 $db->commit; 454 474 } 455 475 die("failed to get LAST_INSERT_ID()") 456 476 unless $parent_id; 457 458 $db->commit;459 477 } 460 478 }; … … 712 730 { 713 731 type => SCALAR|UNDEF, 714 # callbacks => {715 # # check that the volume name requested is valid716 # 'is valid volume name' => sub {717 # return 1 if not defined $_[0];718 # $self->_is_valid_volume_name($_[0])719 # },720 # },721 732 optional => 1, 722 733 }, … … 726 737 727 738 # if a volume name is explicity specified then we should make the 728 # replication onto that volume (even if there is alread an instance on that739 # replication onto that volume (even if there is already an instance on that 729 740 # volume) if at all possible and throw an error if we can not. 741 730 742 # if a volume name IS NOT specified then we should make the replication 731 743 # onto any (hopefully the best) volume that DOES NOT already have an 732 # instance on it. If all av ilable volumealready have an instance on them744 # instance on it. If all available volumes already have an instance on them 733 745 # then we should throw an error 746 734 747 # volume names implied as part of the key are *IGNORED* as the source and 735 748 # *SHOULD NOT* be used as the destination either 736 749 737 750 eval { 738 $key = parse_neb_key($key); 751 # EAM 2019.10.31 : if I supply dest_vol_name here, then 752 # $key->volume will point at that volume and the section below 753 # will correctly be testing the validity of dest_vol_name 754 $key = parse_neb_key($key, $dest_vol_name); 739 755 }; 740 756 $log->logdie("$@") if $@; … … 742 758 my $db = $self->db($key); 743 759 760 ## Old comment: 744 761 # puke if the source volume is bogus, we may want to actually use this as 745 762 # the instance to be copied later 746 if (defined $key->volume 747 and not $self->_is_valid_volume_name($key, $key->volume)) { 763 764 # EAM 2019.10.31 : in the past, the key-implied volume was 765 # supplied here, which was inconsistent since above it says the 766 # key-implied volume is ignored. By supplying $dest_vol_name to 767 # parse_neb_key above, the key->volume now refers to the 768 # dest_volume 769 if (defined $key->volume and not $self->_is_valid_volume_name($key, $key->volume)) { 748 770 unless ($key->hard_volume) { 749 771 $log->warn($key->volume . " not a known volume name"); … … 752 774 } 753 775 } 754 # puke if the source volume is bogus, we may want to actually use this as 755 # the instance to be copied later 756 if (defined $dest_vol_name 757 and not $self->_is_valid_volume_name($key, $dest_vol_name)) { 758 $log->logdie($key->volume . " is not a valid volume name"); 759 } 760 776 777 # puke if the destination volume is bogus 778 ## XXX if I supply dest_vol_name to parse_neb_key above, this section below is redundant with the above 779 ## if (defined $dest_vol_name 780 ## and not $self->_is_valid_volume_name($key, $dest_vol_name)) { 781 ## $log->logdie($key->volume . " is not a valid volume name"); 782 ## } 783 784 $get_storage_volume_calls = 0; 785 761 786 my ($vol_id, $vol_host, $vol_path, $vol_xattr); 762 787 if (defined $dest_vol_name) { 788 # if we supplied dest_vol_name, then the call to parse_neb_key above 789 # will have set $key->volume to that value and hard_volume to match 763 790 ($vol_id, $vol_host, $vol_path, $vol_xattr) 764 = $self->_get_storage_volume($key, $ dest_vol_name);791 = $self->_get_storage_volume($key, $key->volume, $key->hard_volume); 765 792 } else { 766 793 ($vol_id, $vol_host, $vol_path, $vol_xattr) 767 794 = $self->_get_replication_volume($key); 768 795 } 796 797 # print "selected target: $vol_id, $vol_host\n"; 769 798 770 799 my $uri; … … 784 813 $so_id = $query->fetchrow_hashref->{ 'so_id' }; 785 814 $query->finish; 815 $db->commit; 786 816 } 787 817 … … 800 830 # time LAST_INSERT_ID() is invoked 801 831 $query->finish; 832 $db->commit; 802 833 } 803 834 … … 841 872 eval { 842 873 my $mode = $self->getxattr_object("$key", 'user.mode'); 843 if (defined $mode ) {844 $self->chmod_object("$key", $mode);874 if (defined $mode && $mode ne "") { 875 $self->chmod_object("$key", $mode); 845 876 } 846 877 }; … … 852 883 853 884 $log->debug("leaving"); 854 855 885 return "$uri"; 856 886 } … … 1323 1353 die( "xattr $key:$name does not exist" ); 1324 1354 } 1355 1325 1356 # if we go more then one row bad something very bad has happened. 1326 1357 unless ($rows == 1) { … … 1335 1366 $value = $row->{ 'value' }; 1336 1367 }; 1368 $db->commit; 1369 1337 1370 if ($@) { 1338 1371 if ($@ =~ /user\..*? does not exist/) { 1339 1372 # do not log xattr does not exist messages 1373 # NOTE: the client is using the reported message to interpret the errors 1340 1374 die $@; 1341 1375 } … … 1386 1420 }; 1387 1421 $log->logdie("database error: $@") if $@; 1422 $db->commit; 1388 1423 1389 1424 $log->debug("leaving"); … … 1442 1477 die( "affected row count is $rows instead of 1" ); 1443 1478 } 1444 1445 1479 $db->commit; 1446 1480 $log->debug("commit"); … … 1545 1579 $work_dir = $pattern; 1546 1580 $file_pattern = '%'; 1547 } 1548 else { 1581 } else { 1549 1582 my $dir_plain = dirname($pattern); 1550 1583 if ($dir_plain eq 'neb:') { … … 1575 1608 my $query = $db->prepare_cached( $sql->find_dir_by_parent_id . " AND dirname LIKE ? "); 1576 1609 $query->execute( $dir_id, $file_pattern ); 1610 $db->commit; 1577 1611 1578 1612 while ( my $row = $query->fetchrow_hashref ) { … … 1595 1629 my $query = $db->prepare_cached( $sql->find_object_by_dir_id . " AND ext_id_basename LIKE ? "); 1596 1630 $query->execute( $dir_id , $file_pattern); 1631 $db->commit; 1597 1632 1598 1633 while ( my $row = $query->fetchrow_hashref ) { … … 1624 1659 my $sql = $self->sql; 1625 1660 my $db = $self->_db_for_index($index); 1626 1627 1661 1628 1662 # first check to see if the key is an exact match … … 1645 1679 $log->logdie("database error: $@"); 1646 1680 } 1681 $db->commit; 1647 1682 1648 1683 if (scalar @keys) { … … 1678 1713 }; 1679 1714 $log->logdie("database error: $@") if $@; 1715 $db->commit; 1680 1716 1681 1717 # find files under dir … … 1692 1728 }; 1693 1729 $log->logdie("database error: $@") if $@; 1730 $db->commit; 1694 1731 1695 1732 $log->debug( "leaving" ); … … 1753 1790 } 1754 1791 1792 # sub find_instances 1755 1793 sub find_instances_old 1756 1794 { … … 1769 1807 { 1770 1808 type => SCALAR|UNDEF, 1771 # callbacks => {1772 # # check that the volume name requested is valid1773 # 'is valid volume name' => sub {1774 # return 1 if not defined $_[0];1775 # $self->_is_valid_volume_name($_[0])1776 # },1777 # },1778 1809 optional => 1, 1779 1810 }, … … 1787 1818 my $sql = $self->sql; 1788 1819 1789 # unless ($key) { 1790 # $log->warn("key was undefined after validate_pos(), trying again..."); 1791 # return $self->find_instances(@_); 1792 # } 1820 # default value for find_invalid is false 1821 if (not defined $find_invalid) { $find_invalid = 0; } 1793 1822 1794 1823 # vol_name overrides the key implied volume … … 1828 1857 my $rows; 1829 1858 # ext_id, available 1830 if (defined($find_invalid)) { 1859 if (defined($find_invalid) and $find_invalid) { 1860 # XXX returns instances which are NOT available 1831 1861 $rows = $query->execute($key->path, 0); 1832 1862 } … … 1865 1895 } 1866 1896 1867 # sub find_instances_by_proximity1897 # sub find_instances_by_proximity 1868 1898 sub find_instances 1869 1899 { … … 1882 1912 { 1883 1913 type => SCALAR|UNDEF, 1884 # callbacks => {1885 # # check that the volume name requested is valid1886 # 'is valid volume name' => sub {1887 # return 1 if not defined $_[0];1888 # $self->_is_valid_volume_name($_[0])1889 # },1890 # },1891 1914 optional => 1, 1892 1915 }, … … 1897 1920 }, 1898 1921 ); 1899 1900 1922 my $sql = $self->sql; 1901 1923 1902 # unless ($key) { 1903 # $log->warn("key was undefined after validate_pos(), trying again..."); 1904 # return $self->find_instances(@_); 1905 # } 1924 if (not defined $find_invalid) { $find_invalid = 0; } 1925 1926 if ($find_invalid eq "find them all") { 1927 $log->logdie("old neb-cull --one_only, neb-rm --invalid both disabled by new Server.pm"); 1928 } 1906 1929 1907 1930 # vol_name overrides the key implied volume … … 1932 1955 } 1933 1956 } 1934 1935 1936 1957 } 1937 1958 … … 1972 1993 # ext_id, name, available 1973 1994 # host_vol_id host_cab_id host_site_id ext_id available 1974 my $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 1); 1995 1996 my $rows; 1997 if (defined($find_invalid) and $find_invalid) { 1998 # returns instances which are NOT available (volume not available) 1999 $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 0); 2000 } else { 2001 $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 1); 2002 } 1975 2003 unless ($rows > 0) { 1976 2004 $query->finish; 1977 die("no instances on storage volume or volume is not avai able for key: $key volume: $vol_name");2005 die("no instances on storage volume or volume is not available for key: $key volume: $vol_name"); 1978 2006 } 1979 2007 } else { 1980 2008 $query = $db->prepare_cached( $sql->get_object_instances ); 2009 # ext_id, available 2010 1981 2011 my $rows; 1982 # ext_id, available 1983 if (defined($find_invalid)) {2012 if (defined($find_invalid) and $find_invalid) { 2013 # returns instances which are NOT available (volume not available) 1984 2014 $rows = $query->execute($key->path, 0); 1985 } 1986 else { 2015 } else { 1987 2016 $rows = $query->execute($key->path, 1); 1988 2017 } … … 1992 2021 } 1993 2022 } 2023 $db->commit; 2024 ## if we do not call commit here, the transaction stays 2025 ## open blocking some operations below. 1994 2026 1995 2027 while (my $row = $query->fetchrow_hashref) { 1996 2028 my $instance = $row->{ 'uri' }; 1997 2029 push @locations, $instance if $instance; 2030 2031 # Carp::carp ("instance 2: $row->{ 'uri' }, $row->{ 'vol_id' }, $row->{ 'cab_id' }, $row->{ 'vol_idx' }\n"); 1998 2032 } 1999 2033 }; … … 2003 2037 if (defined $vol_name and not defined $key->hard_volume) { 2004 2038 $log->debug("retrying with 'any' volume"); 2005 return $self->find_instances($key->path, 'any' );2039 return $self->find_instances($key->path, 'any', $find_invalid); 2006 2040 } 2007 2041 $log->logdie("database error: $@"); … … 2018 2052 } 2019 2053 2054 # this method returns instances on the specified volume 2055 # or a list of all available instances 2056 # it does NOT choose instances based on proximity 2057 # and it does NOT return invalid instances 2020 2058 sub find_instances_for_cull 2021 2059 { … … 2061 2099 my $db = $self->db($key); 2062 2100 2101 ## XXX this method is missing the alias deference section (see find_instances) 2102 ## if aliases are intended to be compute nodes in the same cabinet / site as 2103 ## the storage nodes, then this is not needed. 2104 2063 2105 # the key's volume can't be validiated on input for this method so we have 2064 2106 # to check it after parsing the key … … 2082 2124 unless ($rows > 0) { 2083 2125 $query->finish; 2084 die("no instances on storage volume or volume is not avai able for key: $key volume: $vol_name");2126 die("no instances on storage volume or volume is not available for key: $key volume: $vol_name"); 2085 2127 } 2086 2128 } else { … … 2105 2147 $db->rollback; 2106 2148 # handle soft volumes 2107 if (defined $vol_name and not defined $key->hard_volume) { 2149 # we need to call find_intances_for_cull here so the returned structure 2150 # is the same (find_instances just returns an array of strings) 2151 if (defined $vol_name and not defined $key->hard_volume and ($vol_name ne "any")) { 2108 2152 $log->debug("retrying with 'any' volume"); 2109 return $self->find_instances ($key->path, 'any');2153 return $self->find_instances_for_cull($key->path, 'any'); 2110 2154 } 2111 2155 $log->logdie("database error: $@"); 2112 2156 } 2157 $db->commit; 2113 2158 2114 2159 # XXX remove this? … … 2222 2267 } 2223 2268 } 2224 2225 2269 $db->commit; 2226 2270 $log->debug("commit"); … … 2282 2326 $stat = $query->fetchrow_arrayref; 2283 2327 $query->finish; 2328 $db->commit; 2284 2329 }; 2285 2330 $log->logdie("database error: $@") if $@; … … 2318 2363 }; 2319 2364 $log->logdie("database error: $@") if $@; 2365 $db->commit; 2320 2366 2321 2367 $log->logdie("no mounted volumes found") unless (scalar @$stats); … … 2415 2461 my ($key, $name, $hard_volume) = @_; 2416 2462 2417 # $log->warn("_g_s_v: key:>$key< name:>$name< hard_vol:>$hard_volume<"); 2463 # track the number of calls to this function and 2464 # give up after 10 attempts 2465 $get_storage_volume_calls ++; 2466 2467 # $log->warn("_g_s_v: key:>$key< name:>$name< hard_vol:>$hard_volume<"); 2418 2468 my $sql = $self->sql; 2419 2469 my $db = $self->db($key); … … 2427 2477 # %free, name, avaiable, allocate 2428 2478 $rows = $query->execute($max_used_space, $name, 1, 1); 2429 # XXX d estinguish between non-existant and unavailable2479 # XXX distinguish between non-existant and unavailable 2430 2480 unless ($rows > 0) { 2431 2481 $query->finish; 2482 $db->commit; 2432 2483 2433 2484 # if a volume name was specified, and is soft, and we failed to … … 2442 2493 if ($rows > 1) { 2443 2494 $query->finish; 2495 $db->commit; 2444 2496 die("affected row count is $rows instead of 1"); 2445 2497 } … … 2449 2501 $rows = $query->execute($max_used_space, 1, 1, $topfew_count); 2450 2502 # $log->warn("Storage_volume: $rows $topfew_count"); 2451 # there has to be at least one storage volume2503 # there has to be at least one storage volume 2452 2504 unless ($rows > 0) { 2453 2505 $query->finish; 2454 die("no storage volume is available for key: $key volume: $name hard_volume: $hard_volume"); 2506 $db->commit; 2507 # prevent failure in the die due to undefined variables 2508 my $hard_volume_str = defined $hard_volume ? $hard_volume : "undefined"; 2509 my $name_str = defined $name ? $name : "undefined"; 2510 die("no storage volume is available for key: $key volume: $name_str hard_volume: $hard_volume_str"); 2455 2511 } 2456 2512 } … … 2465 2521 $log->error($@); 2466 2522 $log->debug("retrying..."); 2467 return $self->_get_storage_volume(@_); 2523 if ($get_storage_volume_calls < 10) { 2524 return $self->_get_storage_volume(@_); 2525 } 2526 # else 2527 $log->logdie("no available storage volume: $@"); 2468 2528 } 2469 2529 # else … … 2502 2562 unless ($rows > 0) { 2503 2563 $query->finish; 2504 die("Requested key $key does not exist ");2564 die("Requested key $key does not exist (or cabinet is undefined)"); 2505 2565 } 2506 2566 if ($rows == 1) { … … 2513 2573 } 2514 2574 $query->finish; 2515 } 2516 else { 2575 } else { 2576 # if instances are spread across multiple cabinets, allow the next instance to go anywhere 2577 # NOTE: this does not prevent the new instance from going to the same volume as one of the existing instances 2517 2578 $forbidden_cabinet = 0; 2518 2579 $forbidden_site = 0; 2519 2580 $query->finish; 2520 2581 } 2521 2582 $db->commit; 2522 2583 2523 2584 $query = $db->prepare_cached( $sql->get_replication_volume_for_ext_id ); 2524 # ext_id, %free, avaiable, allocate 2585 # ext_id, %free, available, allocate 2586 2525 2587 $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, $forbidden_site, $topfew_count); 2526 # XXX d estinguish between non-existant and unaviable2588 # XXX distinguish between non-existant and unavailable 2527 2589 unless ($rows > 0) { 2528 2590 $query->finish; … … 2544 2606 ($vol_id, $vol_host, $vol_path, $xattr, $free) = $query->fetchrow_array; 2545 2607 $query->finish; 2608 $db->commit; 2546 2609 }; 2547 2610 $log->logdie("database error: $@") if $@; … … 2590 2653 ($ext_id) = $query->fetchrow_array; 2591 2654 $query->finish; 2655 $db->commit; 2656 ## if we do not call commit here, the transaction stays open blocking some operations below 2592 2657 }; 2593 2658 if ($@) { … … 2612 2677 } 2613 2678 2614 2679 # in the past, _is_valid_volume_name returned 'undef'. 2680 # now it either returns 1 (success) or 0 (failure) 2615 2681 sub _is_valid_volume_name 2616 2682 { … … 2650 2716 ($vol_id, $vol_path, $free) = $query->fetchrow_array; 2651 2717 $query->finish; 2718 $db->commit; 2652 2719 }; 2653 2720 $log->logdie("database error: $@") if $@; -
trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
r39926 r41172 574 574 DROP TABLE IF EXISTS directory; 575 575 DROP TABLE IF EXISTS deleted; 576 DROP TABLE IF EXISTS cabinet; 577 DROP TABLE IF EXISTS aliasvol; 578 DROP TABLE IF EXISTS lost_instances; 576 579 SET FOREIGN_KEY_CHECKS=1 577 580 END -
trunk/Nebulous-Server/lib/Test/Nebulous.pm
r24540 r41172 19 19 our @EXPORT = qw( $NEB_DB $NEB_USER $NEB_PASS $NEB_MEMCACHED_SERVERS); 20 20 21 our $NEB_DB = $ENV{'NEB_DB'} || "DBI:mysql:database=test:host=localhost"; 22 our $NEB_USER = $ENV{'NEB_USER'} || "test"; 23 our $NEB_PASS = $ENV{'NEB_PASS'} || ''; 21 # require use of the test database server: 22 23 our $NEB_DB = "DBI:mysql:database=test:host=localhost:mysql_socket=/var/run/mysqld/mysqld.sock"; 24 our $NEB_USER = "test"; 25 our $NEB_PASS = ''; 24 26 our $NEB_MEMCACHED_SERVERS = ['127.0.0.1:11211']; 25 27 … … 35 37 my $dir6 = ""; 36 38 my $dir7 = ""; 39 my $dir8 = ""; 40 41 sub show_setup { 42 my $self = shift; 43 44 print "DB: $NEB_DB, USER: $NEB_USER, PASS: $NEB_PASS\n"; 45 } 46 37 47 38 48 sub setup { … … 49 59 $dir6 = tempdir( CLEANUP => 0 ); 50 60 $dir7 = tempdir( CLEANUP => 0 ); 61 $dir8 = tempdir( CLEANUP => 0 ); 51 62 52 63 foreach my $statement (@{ $sql->get_db_schema }) { … … 54 65 } 55 66 56 # node01/node02: allocate = TRUE 57 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (1, 'node01', 'node01', ?, '/', TRUE, TRUE) }, undef, $dir1); 58 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e7 FROM volume WHERE vol_id = ? }, undef, 1); 59 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir1); 67 # generate 2 cabinets so we can replicate to a valid location 68 $dbh->do(qq{ INSERT INTO cabinet (name, site_id, location) values ("cab01", 1, "main") }); 69 $dbh->do(qq{ INSERT INTO cabinet (name, site_id, location) values ("cab02", 1, "main") }); 70 $dbh->do(qq{ INSERT INTO cabinet (name, site_id, location) values ("cab03", 2, "back") }); 71 $dbh->do(qq{ INSERT INTO cabinet (name, site_id, location) values ("cab04", 2, "back") }); 60 72 61 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (2, 'node02', 'node02', ?, '/', TRUE, TRUE) }, undef, $dir2);62 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e8 FROM volume WHERE vol_id = ? }, undef, 2);63 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e8) }, undef, $dir2);73 # node01 : allocate = TRUE (cab01, site 1) 74 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (1, 1, 'node01', 'node01', ?, '/', TRUE, TRUE) }, undef, $dir1); 75 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e7, note FROM volume WHERE vol_id = ? }, undef, 1); 64 76 65 # node03: allocate = TRUE 66 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (3, 'node03', 'node03', ?, '/', TRUE, TRUE) }, undef, $dir3); 67 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e8 FROM volume WHERE vol_id = ? }, undef, 3); 68 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e8) }, undef, $dir3); 77 # node02 : allocate = TRUE (cab02, site 1) 78 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (2, 2, 'node02', 'node02', ?, '/', TRUE, TRUE) }, undef, $dir2); 79 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 2); 80 81 # node03: allocate = TRUE (cab03, site 2) 82 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (3, 3, 'node03', 'node03', ?, '/', TRUE, TRUE) }, undef, $dir3); 83 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 3); 69 84 70 85 # node04: allocate = FALSE, available = FALSE 71 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (4, 'node04', 'node04', ?, '/', FALSE, FALSE) }, undef, $dir4); 72 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e7 FROM volume WHERE vol_id = ? }, undef, 4); 73 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir4); 86 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (4, 1, 'node04', 'node04', ?, '/', FALSE, FALSE) }, undef, $dir4); 87 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 4); 74 88 75 89 # node05: allocate = FALSE, available = TRUE 76 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (5, 'node05', 'node05', ?, '/', FALSE, TRUE) }, undef, $dir5); 77 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e7 FROM volume WHERE vol_id = ? }, undef, 5); 78 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir5); 90 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (5, 1, 'node05', 'node05', ?, '/', FALSE, TRUE) }, undef, $dir5); 91 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 5); 79 92 80 93 # node06: allocate = TRUE, available = FALSE 81 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (6, 'node06', 'node06', ?, '/', TRUE, FALSE) }, undef, $dir6); 82 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e7 FROM volume WHERE vol_id = ? }, undef, 6); 83 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e7) }, undef, $dir6); 94 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (6, 1, 'node06', 'node06', ?, '/', TRUE, FALSE) }, undef, $dir6); 95 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 6); 84 96 85 97 # node07: full 86 $dbh->do(qq{ INSERT INTO volume (vol_id, name, host, path, mountpoint, allocate, available) VALUES (7, 'node07', 'node07', ?, '/', TRUE, TRUE) }, undef, $dir7); 87 $dbh->do(qq{ INSERT INTO mountedvol SELECT *, 10e10, 10e10 FROM volume WHERE vol_id = ? }, undef, 7); 88 # $dbh->do(qq{ INSERT INTO mount VALUES (?, 10e10, 10e10) }, undef, $dir7); 98 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (7, 1, 'node07', 'node07', ?, '/', TRUE, TRUE) }, undef, $dir7); 99 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e10, note FROM volume WHERE vol_id = ? }, undef, 7); 100 101 # node08: allocate = TRUE, (cab04, site 2) 102 $dbh->do(qq{ INSERT INTO volume (vol_id, cab_id, name, host, path, mountpoint, allocate, available) VALUES (8, 4, 'node08', 'node08', ?, '/', TRUE, TRUE) }, undef, $dir8); 103 $dbh->do(qq{ INSERT INTO mountedvol SELECT vol_id,name,host,path,allocate,available,xattr,mountpoint, 10e10, 10e8, note FROM volume WHERE vol_id = ? }, undef, 8); 89 104 90 # $dbh->do(qq{ call getmountedvol() });105 # $dbh->do(qq{ call getmountedvol() }); 91 106 } 92 107 93 108 sub cleanup { 94 109 # memcached needs to be emptied between test runs 95 Cache::Memcached->new(servers => $NEB_MEMCACHED_SERVERS)->flush_all;110 Cache::Memcached->new(servers => $NEB_MEMCACHED_SERVERS)->flush_all; 96 111 # if flush_all() turns out to be useless as feared 97 112 # my $memd = Cache::Memcached->new(servers => $NEB_MEMCACHED_SERVERS); … … 106 121 # $query->finish; 107 122 123 108 124 foreach my $statement (@{ $sql->get_db_clear }) { 109 125 $dbh->do( $statement ); … … 118 134 rmtree([$dir6], 0, 1) if -e $dir6; 119 135 rmtree([$dir7], 0, 1) if -e $dir7; 136 rmtree([$dir8], 0, 1) if -e $dir8; 137 } 138 139 # function to change state of one node for tests: 140 sub switch_node_state { 141 my $self = shift; 142 143 $dbh->do(qq{ UPDATE volume set available = FALSE where name = 'node02'}); 144 $dbh->do(qq{ UPDATE mountedvol set available = FALSE where name = 'node02'}); 145 } 146 147 sub get_node_dirs { 148 my $self = shift; 149 150 return ($dir1, $dir2, $dir3, $dir4, $dir5, $dir6, $dir7, $dir8); 120 151 } 121 152 -
trunk/Nebulous-Server/t/03_server_setup.t
r24546 r41172 14 14 use Nebulous::Server; 15 15 use Test::Nebulous; 16 17 Test::Nebulous->show_setup; 18 die "test"; 16 19 17 20 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/04_server_create_object.t
r24356 r41172 30 30 31 31 Test::Nebulous->setup; 32 33 32 { 34 33 # key … … 40 39 uri_scheme_ok($uri, 'file'); 41 40 42 SKIP: { 43 skip "requires xattr support", 1 unless $test_xattr; 44 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 45 } 46 } 47 48 Test::Nebulous->setup; 49 41 SKIP: { 42 skip "requires xattr support", 1 unless $test_xattr; 43 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 44 } 45 } 46 47 Test::Nebulous->setup; 50 48 { 51 49 # key … … 57 55 uri_scheme_ok($uri, 'file'); 58 56 59 SKIP: {60 skip "requires xattr support", 1 unless $test_xattr;61 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');62 }57 SKIP: { 58 skip "requires xattr support", 1 unless $test_xattr; 59 is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr'); 60 } 63 61 } 64 62 … … 528 526 $neb->create_object("foo", '~node07'); 529 527 }; 530 like($@, qr/node07 is not available/, "request volume thisis full");528 like($@, qr/node07 is not available/, "request volume which is full"); 531 529 532 530 Test::Nebulous->setup; … … 535 533 $neb->create_object("neb://~node07/foo"); 536 534 }; 537 like($@, qr/node07 is not available/, "request volume thisis full");535 like($@, qr/node07 is not available/, "request volume which is full"); 538 536 539 537 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/05_server_replicate_object.t
r24995 r41172 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 25;10 use Test::More tests => 43; 11 11 12 12 use lib qw( ./t ./lib ); … … 28 28 29 29 Test::Nebulous->setup; 30 31 30 { 32 31 # key … … 45 44 46 45 Test::Nebulous->setup; 47 48 46 { 49 47 # key, $volume … … 62 60 63 61 Test::Nebulous->setup; 64 65 62 { 66 63 # key, $volume is undef … … 79 76 80 77 Test::Nebulous->setup; 81 82 78 { 83 79 # key, $volume … … 147 143 } 148 144 145 # hard_volume tests: 146 147 # replication with hard_volume: 148 Test::Nebulous->setup; 149 { 150 my @nodedirs = Test::Nebulous->get_node_dirs(); 151 152 # checking on replicate_object: hard_volume as node target 153 my $uri1 = $neb->create_object("foo", "~node01"); 154 my $uri2 = $neb->replicate_object("foo", "~node02"); 155 156 my $locations = $neb->find_instances("foo"); 157 my $Nloc = @$locations; 158 159 is($Nloc, 2, "found 2 instances"); 160 161 my $loc1 = $locations->[0]; 162 my $loc2 = $locations->[1]; 163 164 like($loc1, qr/$nodedirs[0]/, "instance matches expected node"); 165 like($loc2, qr/$nodedirs[1]/, "instance matches expected node"); 166 } 167 168 # replication to unknown volume: should succeed 169 Test::Nebulous->setup; 170 { 171 my @nodedirs = Test::Nebulous->get_node_dirs(); 172 173 # checking on replicate_object, does this logic make sense? 174 my $uri1 = $neb->create_object("foo", "~node01"); 175 my $uri2 = $neb->replicate_object("foo", "dummy"); 176 177 my $locations = $neb->find_instances("foo"); 178 my $Nloc = @$locations; 179 180 is($Nloc, 2, "found 2 instances"); 181 182 my $loc1 = $locations->[0]; 183 my $loc2 = $locations->[1]; 184 185 like($loc1, qr/$nodedirs[0]/, "instance matches expected node"); 186 uri_scheme_ok($loc2, 'file'); 187 } 188 189 # replication to unknown volume with hard_volume: should fail 190 Test::Nebulous->setup; 191 eval { 192 my @nodedirs = Test::Nebulous->get_node_dirs(); 193 194 # checking on replicate_object, does this logic make sense? 195 my $uri1 = $neb->create_object("foo", "~node01"); 196 my $uri2 = $neb->replicate_object("foo", "~dummy"); 197 198 my $locations = $neb->find_instances("foo"); 199 }; 200 like($@, qr/is not a valid volume name/, "replicate to unknown node with hard_volume should fail"); 201 202 # replication to unavailable volume: should succeed 203 Test::Nebulous->setup; 204 { 205 my @nodedirs = Test::Nebulous->get_node_dirs(); 206 207 # checking on replicate_object, does this logic make sense? 208 my $uri1 = $neb->create_object("foo", "~node01"); 209 my $uri2 = $neb->replicate_object("foo", "node04"); 210 211 my $locations = $neb->find_instances("foo"); 212 my $Nloc = @$locations; 213 214 is($Nloc, 2, "found 2 instances"); 215 216 my $loc1 = $locations->[0]; 217 my $loc2 = $locations->[1]; 218 219 like($loc1, qr/$nodedirs[0]/, "instance matches expected node"); 220 uri_scheme_ok($loc2, 'file'); 221 } 222 223 # replication to unavailable volume with hard_volume: should fail 224 Test::Nebulous->setup; 225 eval { 226 my @nodedirs = Test::Nebulous->get_node_dirs(); 227 228 # checking on replicate_object, does this logic make sense? 229 my $uri1 = $neb->create_object("foo", "~node01"); 230 my $uri2 = $neb->replicate_object("foo", "~node04"); 231 232 my $locations = $neb->find_instances("foo"); 233 }; 234 like($@, qr/is not available/, "replicate to unknown node with hard_volume should fail"); 235 236 ### END hard_volume tests 237 238 ### location-aware tests (do we respect the cab_id / vol_id exclusions?) 239 240 # here are the volume definitions (Test/Nebulous.pm): 241 # name : vol_id : cab_id : site_id : xattr 242 # node01 : 1 : 1 : 1 : 0 243 # node02 : 2 : 2 : 1 : 0 244 # node03 : 3 : 3 : 2 : 0 245 # node04 : 4 : 1 : 1 : 0 246 # node05 : 5 : 1 : 1 : 0 247 # node06 : 6 : 1 : 1 : 0 248 # node07 : 7 : 1 : 1 : 0 249 # node08 : 8 : 4 : 2 : 0 250 251 # replication without volume 252 Test::Nebulous->setup; 253 { 254 my @nodedirs = Test::Nebulous->get_node_dirs(); 255 256 # checking on replicate_object: hard_volume as node target 257 my $uri1 = $neb->create_object("foo", "~node01"); 258 my $uri2 = $neb->replicate_object("foo"); 259 260 my $locations = $neb->find_instances("foo"); 261 my $Nloc = @$locations; 262 263 is($Nloc, 2, "found 2 instances"); 264 265 my $loc1 = $locations->[0]; 266 my $loc2 = $locations->[1]; 267 268 # if the volume is not explicitly specified, then the first copy 269 # should go to a different volume, cabinet, and site 270 # if first is one node01, replication should go to node03 or node08 271 # since those both have different site_id values 272 like($loc1, qr/$nodedirs[0]/, "instance matches expected node"); 273 274 my $isnode03 = $loc2 =~ m/$nodedirs[2]/; 275 my $isnode08 = $loc2 =~ m/$nodedirs[7]/; 276 ok($isnode03 || $isnode08, "instance matches expected node"); 277 } 278 279 # replication without volume 280 Test::Nebulous->setup; 281 { 282 my @nodedirs = Test::Nebulous->get_node_dirs(); 283 284 # checking on replicate_object, does this logic make sense? 285 my $uri1 = $neb->create_object("foo", "~node03"); 286 my $uri2 = $neb->replicate_object("foo"); 287 288 my $locations = $neb->find_instances("foo"); 289 my $Nloc = @$locations; 290 291 is($Nloc, 2, "found 2 instances"); 292 293 my $loc1 = $locations->[0]; 294 my $loc2 = $locations->[1]; 295 296 # if the volume is not explicitly specified, then the first copy 297 # should go to a different volume, cabinet, and site 298 # if first is one node03, replication should go to node01 or node02 299 # since those both have different site_id values 300 like($loc1, qr/$nodedirs[2]/, "instance matches expected node"); 301 302 my $isnode01 = $loc2 =~ m/$nodedirs[0]/; 303 my $isnode02 = $loc2 =~ m/$nodedirs[1]/; 304 ok($isnode01 || $isnode02, "instance matches expected node"); 305 } 306 149 307 Test::Nebulous->setup; 150 308 -
trunk/Nebulous-Server/t/08_server_find_instances.t
r24362 r41172 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 19;10 use Test::More tests => 44; 11 11 12 12 use lib qw( ./t ./lib ); … … 22 22 ); 23 23 24 Test::Nebulous->setup; 25 24 # XXX previously, the logic was: if we request a hard volume location 25 # using ~node, then we would give an error if no data is available except on that node. 26 27 # the code has been modified so that the requested storage object is provided if possible, 28 # even if the apparently "hard" target did not exist. 29 30 Test::Nebulous->setup; 31 Test::Nebulous->cleanup; # make sure the database is reset before running any tests 32 33 # for (my $i = 0; $i < $Nloc; $i++) { 34 # my $loc = $locations->[$i]; 35 # print "location: $loc\n"; 36 #} 37 38 Test::Nebulous->setup; 26 39 { 27 40 # key … … 35 48 36 49 Test::Nebulous->setup; 37 38 50 { 39 51 # key … … 49 61 50 62 Test::Nebulous->setup; 51 52 63 { 53 64 # key, volume … … 61 72 62 73 Test::Nebulous->setup; 63 64 74 { 65 75 # key, volume … … 73 83 74 84 Test::Nebulous->setup; 75 76 85 { 77 86 # key, volume … … 85 94 86 95 Test::Nebulous->setup; 87 88 96 { 89 97 # key … … 98 106 } 99 107 100 # object exists but instance is on a different volume 101 Test::Nebulous->setup; 102 108 # request from a hard_volume returns an instance which is not on the hard volume if available 109 Test::Nebulous->setup; 103 110 eval { 104 111 # key, volume 105 112 my $uri = $neb->create_object('foo', '~node01'); 106 107 113 my $locations = $neb->find_instances('foo', '~node02'); 108 }; 109 like($@, qr/no instances on storage volume/, 'instances on a different volume'); 114 115 uri_scheme_ok($locations->[0], 'file'); 116 is($uri, $locations->[0], "URIs match"); 117 }; 118 is($@, "", "instance on different node (as hard_volume) returned"); 119 120 # request from a hard_volume returns an instance which is not on the hard volume if available 121 Test::Nebulous->setup; 122 eval { 123 # key, volume 124 my $uri = $neb->create_object('foo', '~node01'); 125 my $locations = $neb->find_instances('foo', '~node02'); 126 127 uri_scheme_ok($locations->[0], 'file'); 128 is($uri, $locations->[0], "URIs match"); 129 }; 130 is($@, "", "instance on different node (as hard_volume) returned"); 131 132 ### TESTS FOR INSTANCE ON INVALID NODE 133 diag ("TESTS FOR INSTANCE ON INVALID NODE"); 134 135 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 1) [SOFT, 1] 136 Test::Nebulous->setup; 137 eval { 138 # key, volume 139 my $uri = $neb->create_object('foo', '~node02'); 140 Test::Nebulous->switch_node_state; 141 142 my $locations = $neb->find_instances('foo', 'node02', 1); 143 uri_scheme_ok($locations->[0], 'file'); 144 is($uri, $locations->[0], "URIs match"); 145 }; 146 is($@, "", "instance on invalid node (as soft_volume) returned with find_invalid = 1"); 147 148 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 0) [SOFT, 0] 149 Test::Nebulous->setup; 150 eval { 151 # key, volume 152 my $uri = $neb->create_object('foo', '~node02'); 153 Test::Nebulous->switch_node_state; 154 155 my $locations = $neb->find_instances('foo', 'node02', 0); 156 }; 157 like($@, qr/database error/, "instance on invalid node (as soft_volume) not returned (find_invalid = 0)"); 158 159 # request from a hard_volume for an instance which is on an invalid node (find_instance not supplied) [SOFT, X] 160 Test::Nebulous->setup; 161 eval { 162 # key, volume 163 my $uri = $neb->create_object('foo', '~node02'); 164 Test::Nebulous->switch_node_state; 165 166 my $locations = $neb->find_instances('foo', 'node02'); 167 }; 168 like($@, qr/no instances available for key/, "instance on invalid node (as soft_volume) not returned (find_invalid not set)"); 169 170 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 1) [HARD, 1] 171 Test::Nebulous->setup; 172 eval { 173 # key, volume 174 my $uri = $neb->create_object('foo', '~node02'); 175 Test::Nebulous->switch_node_state; 176 177 my $locations = $neb->find_instances('foo', '~node02', 1); 178 uri_scheme_ok($locations->[0], 'file'); 179 is($uri, $locations->[0], "URIs match"); 180 }; 181 is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid = 1"); 182 183 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 0) [HARD, 0] 184 Test::Nebulous->setup; 185 eval { 186 # key, volume 187 my $uri = $neb->create_object('foo', '~node02'); 188 Test::Nebulous->switch_node_state; 189 190 my $locations = $neb->find_instances('foo', '~node02', 0); 191 }; 192 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned (find_invalid = 0)"); 193 194 # request from a hard_volume for an instance which is on an invalid node [HARD, X] 195 Test::Nebulous->setup; 196 eval { 197 # key, volume 198 my $uri = $neb->create_object('foo', '~node02'); 199 Test::Nebulous->switch_node_state; 200 201 my $locations = $neb->find_instances('foo', '~node02'); 202 }; 203 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned (find_invalid not set)"); 204 205 #### TESTING the instance proximity analysis 206 Test::Nebulous->setup; 207 { 208 my @nodedirs = Test::Nebulous->get_node_dirs(); 209 210 # place 4 instances on specific nodes (hard targets works): 211 my $uri1 = $neb->create_object("foo", "~node01"); 212 my $uri2 = $neb->replicate_object("foo", "~node02"); 213 my $uri3 = $neb->replicate_object("foo", "~node03"); 214 my $uri4 = $neb->replicate_object("foo", "~node08"); 215 216 my $locations = $neb->find_instances("foo", "node01"); 217 my $Nloc = @$locations; 218 219 is($Nloc, 4, "found 4 instances"); 220 221 my $loc1 = $locations->[0]; 222 my $loc2 = $locations->[1]; 223 my $loc3 = $locations->[2]; 224 my $loc4 = $locations->[3]; 225 226 # choosing instance relative to node01 yields: 227 like($loc1, qr/$nodedirs[0]/, "node01 is closest to node01"); 228 like($loc2, qr/$nodedirs[1]/, "node02 is 2nd closest to node01"); 229 like($loc3, qr/$nodedirs[2]/, "node03 is 3rd closest to node01"); 230 like($loc4, qr/$nodedirs[7]/, "node08 is 4th closest to node01"); 231 } 232 233 #### TESTING the instance proximity analysis 234 Test::Nebulous->setup; 235 { 236 my @nodedirs = Test::Nebulous->get_node_dirs(); 237 238 # place 4 instances on specific nodes (hard targets works): 239 my $uri1 = $neb->create_object("foo", "~node01"); 240 my $uri2 = $neb->replicate_object("foo", "~node02"); 241 my $uri3 = $neb->replicate_object("foo", "~node03"); 242 my $uri4 = $neb->replicate_object("foo", "~node08"); 243 244 my $locations = $neb->find_instances("foo", "node03"); 245 my $Nloc = @$locations; 246 247 is($Nloc, 4, "found 4 instances"); 248 249 my $loc1 = $locations->[0]; # 250 my $loc2 = $locations->[1]; # 251 my $loc3 = $locations->[2]; # 252 my $loc4 = $locations->[3]; # 253 254 # choosing instance relative to node01 yields: 255 like($loc1, qr/$nodedirs[2]/, "node03 is closest to node03"); 256 like($loc2, qr/$nodedirs[7]/, "node08 is 2nd closest to node03"); 257 like($loc3, qr/$nodedirs[1]/, "node02 is 3rd closest to node03"); 258 like($loc4, qr/$nodedirs[0]/, "node08 is 4th closest to node03"); 259 } 260 261 ######## 110 262 111 263 Test::Nebulous->setup; … … 125 277 126 278 Test::Nebulous->setup; 127 128 eval { 129 $neb->find_instances();130 };131 like($@, qr/1 - 2 were expected/, "no params"); 279 eval { 280 my $locations = $neb->find_instances(); 281 }; 282 like($@, qr/1 - 3 were expected/, "no params"); 283 # note the new API expects 1-3 parameters 132 284 133 285 Test::Nebulous->setup; … … 135 287 eval { 136 288 $neb->create_object('foo'); 137 $neb->find_instances('foo', 'node01', 3); 138 }; 139 like($@, qr/1 - 2 were expected/, "too many params"); 289 $neb->find_instances('foo', 'node01', 3, 5); 290 }; 291 like($@, qr/1 - 3 were expected/, "too many params"); 292 # note the new API expects 1-3 parameters 140 293 141 294 Test::Nebulous->cleanup; -
trunk/Nebulous-Server/t/11_server_is_valid_volume_name.t
r24356 r41172 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 3;10 use Test::More tests => 5; 11 11 12 12 use lib qw( ./t ./lib ); … … 31 31 Test::Nebulous->setup; 32 32 33 is($neb->_is_valid_volume_name('foo', 'node99'), undef, "invalid volume name"); 33 is($neb->_is_valid_volume_name('foo', 'node99'), 0, "invalid volume name"); 34 35 Test::Nebulous->setup; 36 37 # key does not need to exist (is hashed to select db server) 38 ok($neb->_is_valid_volume_name('bax', 'node01'), "valid volume name"); 39 40 Test::Nebulous->setup; 41 42 # 'any' should always be a valid name 43 ok($neb->_is_valid_volume_name('foo', 'any'), "valid volume name"); 34 44 35 45 Test::Nebulous->cleanup; -
trunk/Nebulous-Server/t/15_server_xattr.t
r24356 r41172 184 184 $neb->getxattr_object('foo', 'user.bar'); 185 185 }; 186 like($@, qr|xattr neb:///foo:user.bar does not exist|, 187 "get xattr from non-existant xattr key"); 186 like($@, qr|xattr neb:///foo:user.bar does not exist|, "get xattr from non-existant xattr key"); 188 187 189 188 Test::Nebulous->setup; -
trunk/Nebulous-Server/t/16_mounts.t
r24356 r41172 28 28 my $mounts = $neb->mounts(); 29 29 30 is(scalar @$mounts, 7, "number of rows");30 is(scalar @$mounts, 8, "number of rows"); 31 31 32 32 my %row; … … 35 35 = @{$mounts->[0]}; 36 36 37 is($row{total}, 100000000000 );38 is($row{used}, 100000000 );39 is($row{vol_id}, 1 );40 is($row{name}, "node01" );41 is($row{host}, "node01" );42 is($row{allocate}, 1 );43 is($row{available}, 1 );44 is($row{xattr}, 0 );37 is($row{total}, 100000000000, "total bytes"); 38 is($row{used}, 100000000, "used bytes"); 39 is($row{vol_id}, 1, "vol id"); 40 is($row{name}, "node01", "name"); 41 is($row{host}, "node01", "host"); 42 is($row{allocate}, 1, "is allocated"); 43 is($row{available}, 1, "is available"); 44 is($row{xattr}, 0, "has no xattr"); 45 45 46 46 # 2nd row … … 48 48 = @{$mounts->[1]}; 49 49 50 is($row{total}, 100000000000 );51 is($row{used}, 1000000000 );52 is($row{vol_id}, 2 );53 is($row{name}, "node02" );54 is($row{host}, "node02" );55 is($row{allocate}, 1 );56 is($row{available}, 1 );57 is($row{xattr}, 0 );50 is($row{total}, 100000000000, "total bytes"); 51 is($row{used}, 1000000000, "used bytes"); 52 is($row{vol_id}, 2, "vol id"); 53 is($row{name}, "node02", "name"); 54 is($row{host}, "node02", "host"); 55 is($row{allocate}, 1, "is allocated"); 56 is($row{available}, 1, "is available"); 57 is($row{xattr}, 0, "has no xattr"); 58 58 } 59 59 -
trunk/Nebulous-Server/t/18_server_chmod_object.t
r24356 r41172 38 38 is($mode, 0440, "returned mode"); 39 39 is($neb->getxattr_object($key, 'user.mode'), 0440, "xattr user.mode"); 40 41 # reset to 600 so the user can delete the file and /tmp entry 42 chmod(0600, $path); 40 43 } 41 44 … … 50 53 my $mode = $neb->chmod_object($key, 0440); 51 54 52 my $st1 = stat(URI->new($uri1)->path); 53 my $st2 = stat(URI->new($uri2)->path); 55 my $path1 = URI->new($uri1)->path; 56 my $path2 = URI->new($uri2)->path; 57 58 my $st1 = stat($path1); 59 my $st2 = stat($path2); 54 60 55 61 is($st1->mode &07777, 0440, "chmod() first instance"); … … 57 63 is($mode, 0440, "returned mode"); 58 64 is($neb->getxattr_object($key, 'user.mode'), 0440, "xattr user.mode"); 65 66 # reset to 600 so the user can delete the file and /tmp entry 67 chmod (0600, $path1); 68 chmod (0600, $path2); 59 69 } 60 70 -
trunk/Nebulous/Build.PL
r32473 r41172 96 96 'Test::Nebulous' => 0, 97 97 'Test::Cmd' => '1.05', 98 'Apache2::SOAP' => 0, 98 # gentoo: 'Apache2::SOAP' => 0, 99 'Apache::SOAP' => 0, # needed instead for ubuntu 18.04 99 100 'Apache::DBI' => '1.05', 100 101 'Apache::Test' => '1.27', # bundles Apache::TestMB -
trunk/Nebulous/bin/neb-cat
r13080 r41172 18 18 use constant CHUNK_SIZE => 1024; 19 19 20 my ($server );20 my ($server, $help); 21 21 22 22 $server = $ENV{'NEB_SERVER'} unless $server; … … 24 24 GetOptions( 25 25 'server|s=s' => \$server, 26 'help|h' => \$help, 26 27 ) || pod2usage( 2 ); 27 28 28 pod2usage( -msg => "Required options: --server <key...>", -exitval => 2 ) 29 unless defined $server; 29 # explicitly defined -h / --help: 30 if ($help) { pod2usage( -verbose => 1 ); } 31 32 pod2usage( -msg => "Required options: --server <key...>", -exitval => 2 ) unless defined $server; 30 33 31 34 my $neb = Nebulous::Client->new( … … 95 98 =over 4 96 99 97 =item *--server|-s <URL>100 =item --server|-s <URL> 98 101 99 102 URL of the Nebulous server to connect to. -
trunk/Nebulous/bin/neb-cp
r16182 r41172 16 16 use Pod::Usage qw( pod2usage ); 17 17 18 my ($volume, $server );18 my ($volume, $server, $help); 19 19 20 20 $server = $ENV{'NEB_SERVER'} unless $server; … … 23 23 'volume=s' => \$volume, 24 24 'server|s=s' => \$server, 25 'help|h' => \$help, 25 26 ) || pod2usage( 2 ); 27 28 # explicitly defined -h / --help: 29 if ($help) { pod2usage( -verbose => 1 ); } 26 30 27 31 my $src = shift; -
trunk/Nebulous/bin/neb-cull
r30236 r41172 17 17 18 18 my ($min_copies, $server, $volume, $one_only); 19 my ($soft_volume );19 my ($soft_volume, $help); 20 20 $server = $ENV{'NEB_SERVER'} unless $server; 21 21 … … 26 26 'one_only|o' => \$one_only, 27 27 'soft_volume' => \$soft_volume, 28 'help|h' => \$help, 28 29 ) || pod2usage( 2 ); 30 31 # explicitly defined -h / --help: 32 if ($help) { pod2usage( -verbose => 1 ); } 29 33 30 34 my $key = shift; … … 59 63 # print "@cull_args\n"; 60 64 61 62 65 if ($one_only) { 63 66 my $status = $neb->there_can_be_only_one(@cull_args); 67 if (not defined $status) { 68 die "not enough instances of Nebulous key: $key"; 69 } 64 70 if ($status == 0) { 65 71 die "not enough instances of Nebulous key: $key"; -
trunk/Nebulous/bin/neb-insert
r25939 r41172 95 95 =head1 SYNOPSIS 96 96 97 neb-insert --server <neb-server><neb-key> <local-file> [--copies <n>] [--destroy]97 neb-insert [--server <neb-server>] <neb-key> <local-file> [--copies <n>] [--destroy] 98 98 99 99 #=head1 DESCRIPTION -
trunk/Nebulous/bin/neb-ls
r28581 r41172 19 19 $ls, 20 20 $column, 21 $help 21 22 ); 22 23 23 24 $server = $ENV{'NEB_SERVER'} unless $server; 24 25 25 26 26 GetOptions( … … 29 29 'l' => \$ls, 30 30 'column|c' => \$column, 31 'help|h' => \$help, 31 32 ) || pod2usage( 2 ); 33 34 # explicitly defined -h / --help: 35 if ($help) { pod2usage( -verbose => 1 ); } 32 36 33 37 # twiddle column so that it does it by default. … … 35 39 $column = not $column; 36 40 41 if ($ls) { $path = 1; } 42 37 43 my $pattern = shift; 38 44 39 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 40 pod2usage( -msg => "Required options: --server", -exitval => 2 ) 41 unless $server; 46 pod2usage( -msg => "Required options: --server", -exitval => 2 ) unless $server; 42 47 43 48 my $neb = Nebulous::Client->new( … … 96 101 =head1 SYNOPSIS 97 102 98 neb-ls [--server <URL>] [-c] [-p] <pattern>103 neb-ls [--server <URL>] [-c] [-p] [-l] <pattern> 99 104 100 105 =head1 DESCRIPTION 101 106 102 107 This program list Nebulous keys matched by C<<pattern>>. Call it with no 103 arguments is equivalent to searching with the pattern C<neb://>. SQL like108 arguments is equivalent to searching with the pattern C<neb://>. SQL-like 104 109 wildcards are supported to select out certain files. 105 110 … … 108 113 =over 4 109 114 110 =item *--path|-p115 =item --path|-p 111 116 112 117 Find the disk files corresponding to the keys found. 113 118 114 =item *--column|-c119 =item --column|-c 115 120 116 121 Disable column formatting, and output results one to a line. 117 122 123 =item --l|-l 124 125 Give disk file information using ls (implies -p). 126 118 127 Optional 119 128 120 =item *--server|-s <URL>129 =item --server|-s <URL> 121 130 122 131 URL of the Nebulous server to connect to. -
trunk/Nebulous/bin/neb-migrate
r28446 r41172 23 23 24 24 $server = $ENV{'NEB_SERVER'} unless $server; 25 26 die "this tool is probably too inefficient unless used very carefully"; 25 27 26 28 GetOptions( -
trunk/Nebulous/bin/neb-repair
r39926 r41172 45 45 ); 46 46 47 die "can't connect edto Nebulous Server: $server"47 die "can't connect to Nebulous Server: $server" 48 48 unless defined $neb; 49 49 50 50 my $stat = $neb->stat($key); 51 51 die "nebulous key: $key not found" unless $stat; 52 52 53 my $instances = $neb->find_instances($key, 'any'); 53 54 die "no instances found" unless $instances; … … 71 72 72 73 for (my $i = 0; $i <= $#files; $i++) { 74 # count existing files and get the MD5 sums 73 75 if (-e $files[$i]) { 74 76 $existance[$i] = 1; … … 89 91 push @{ $md5sum_valid{$md5sums[$i]} }, $files[$i]; 90 92 $last_f = $files[$i]; 91 } 92 else { 93 } else { 93 94 $existance[$i] = 0; 94 95 $md5sums[$i] = 'NON-EXISTANT'; … … 98 99 } 99 100 101 # check number of copies and number of unique MD5 sum values 100 102 my $N_mds = scalar(keys(%md5sum_uniq)); 101 103 my $N_files = scalar(@files); 104 105 # seems like we should not call neb-replicate until *after* we have 106 # removed 0-byte copies 102 107 if ($N_files < $user_copies) { 103 108 print "Insufficient copies ($N_files) of $key, replicating!\n"; 104 109 system("neb-replicate $key"); 105 110 } 111 106 112 if ($N_mds == 1) { 107 113 print "Nebulous key $key is consistent.\n"; 108 } 109 else { 114 } else { 110 115 my $valid_sum = ''; 111 116 my $valid_file = ''; 112 117 my $m; 113 118 foreach $m (keys %md5sum_valid) { 114 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') &&($m ne 'NON-EXISTANT')) {119 if (($m ne 'd41d8cd98f00b204e9800998ecf8427e') && ($m ne 'NON-EXISTANT')) { 115 120 if ($valid_sum ne '') { 116 121 die "Too many acceptable files for key $key\n"; … … 122 127 if ($valid_sum eq '') { 123 128 die "No acceptable file for key $key\n"; 124 } 125 else { 129 } else { 126 130 print "Repairing instances\n"; 127 131 foreach $m (keys %md5sum_valid) { … … 130 134 print "\tcp $valid_file $f\n"; 131 135 system("cp $valid_file $f"); 136 137 # if we failed to make a copy, the target ($f) could be inaccessible 132 138 if ($? >> 8 != 0) { 133 139 if ($existance[0] == 1) { 134 # We can fix this with culls and replications. 140 141 # The target is a valid file 0-byte file 142 # but we cannot replace it with the 143 # correct file. We can fix this with 144 # culls and replications. 145 135 146 print "Attempting to fix this.\n"; 136 147 print("neb-replicate $key\n"); 137 148 system("neb-replicate $key"); 138 149 if ($? >> 8 == 0) { 150 # if the neb-replicate succeeded, remove the bad copy with neb-cull 139 151 my $bad_volume = (split /\//, $f)[2]; 140 152 print("neb-cull --volume $bad_volume $key\n"); 141 153 system("neb-cull --volume $bad_volume $key"); 142 } 143 else { 154 } else { 144 155 die "Failed to copy file $valid_file to $f, and subsequent replication also failed!\n"; 145 156 } 146 } 147 else { 157 } else { 148 158 die "Failed to copy file $valid_file to $f!\n"; 149 159 } … … 187 197 =head1 DESCRIPTION 188 198 189 This program repairs instances and corrects instance counts for a nebulous key. 199 This program repairs instances and corrects instance counts for a nebulous key: 200 201 If some of the existing instances have the MD5 sum corresponding to a 202 0-byte file, but the rest have the same, non-zero byte md5sum, then 203 replace the 0-byte files with the non-zero byte version. 204 205 At the end, if the number of instances is less than the value of 206 user.copies, then additional copies are generated. 190 207 191 208 =head1 OPTIONS -
trunk/Nebulous/bin/neb-replicate
r29476 r41172 42 42 ); 43 43 44 # Nebulous::Client programs can use this to set the log level: 45 # $neb->set_log_level ('DEBUG'); 46 44 47 die "can't connected to Nebulous Server: $server" 45 48 unless defined $neb; … … 50 53 for (my $i = 0; $i < $copies; $i++) { 51 54 if (defined $volume) { 55 # this is coded so that all copies end up on the specified volume which seems wrong 52 56 $neb->replicate($key, $volume) 53 57 or die "failed to replicate Nebulous key: $key"; -
trunk/Nebulous/bin/neb-shift
r31964 r41172 17 17 18 18 my ($volume, $server); 19 20 die "this tool may fail since find_instances will return an instance which is not on the hard volume"; 19 21 20 22 $server = $ENV{'NEB_SERVER'} unless $server; -
trunk/Nebulous/bin/neb-stat
r32045 r41172 19 19 use URI; 20 20 21 my ($validate,$server,$nouris );21 my ($validate,$server,$nouris,$help); 22 22 23 23 $server = $ENV{'NEB_SERVER'} unless $server; 24 24 25 25 GetOptions( 26 'server|s=s' => \$server, 27 'validate|v' => \$validate, 28 'files' => \$nouris, 26 'server|s=s' => \$server, 27 'validate|v' => \$validate, 28 'files|f' => \$nouris, 29 'help|h' => \$help, 29 30 ) || pod2usage( 2 ); 30 31 32 # explicitly defined -h / --help: 33 if ($help) { pod2usage( -verbose => 1 ); } 34 31 35 my $key = shift; 32 36 33 37 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 34 pod2usage( -msg => "Required options: --server", -exitval => 2 ) 35 unless $server; 36 pod2usage( -msg => "missing key", exitval => 2 ) 37 unless defined $key; 38 pod2usage( -msg => "Required options: --server", -exitval => 2 ) unless $server; 39 pod2usage( -msg => "missing key", exitval => 2 ) unless defined $key; 38 40 39 41 my $neb = Nebulous::Client->new( … … 52 54 eval { 53 55 $user_copies = $neb->getxattr($key, "user.copies"); 56 die ("user.copies not found") unless $user_copies; 54 57 }; 55 unless(defined($user_copies) ) {58 unless(defined($user_copies) and $user_copies ne "") { 56 59 $user_copies = 1; 57 60 } … … 74 77 $md5sum_uniq{$md5sums[$i]} = 1; 75 78 close($fh); 76 } 77 else { 79 } else { 78 80 $existance[$i] = 0; 79 81 $md5sums[$i] = 'NON-EXISTANT'; 80 82 $md5sum_uniq{$md5sums[$i]} = 1; 81 83 } 84 82 85 if (defined($nouris)) { 83 86 $validation[$i] = sprintf("% 3d %32s %s", … … 85 88 $md5sums[$i], 86 89 $files[$i]); 87 } 88 else { 90 } else { 89 91 $validation[$i] = sprintf("% 3d %32s %s", 90 92 $existance[$i], … … 112 114 "instance location:\n", " " x 4, 113 115 join("\n" . " " x 4, @validation), "\n"; 116 } else { 117 118 if (defined($nouris)) { 119 my @files = map {URI->new($_)->file if $_} @$instances; 120 121 print 122 "object id: ", @$stat[0], "\n", 123 "key: ", @$stat[1], "\n", 124 "read lock: ", @$stat[2], "\n", 125 "write lock: ", @$stat[3], "\n", 126 "epoch: ", @$stat[4], "\n", 127 "mtime: ", @$stat[5], "\n", 128 "available instances: ", @$stat[6], "\n", 129 "requested instances: ", $user_copies, "\n", 130 "total instances: ", @$stat[7], "\n", 131 132 "instance location:\n", " " x 4, 133 join("\n" . " " x 4, @files), "\n"; 134 } else { 135 print 136 "object id: ", @$stat[0], "\n", 137 "key: ", @$stat[1], "\n", 138 "read lock: ", @$stat[2], "\n", 139 "write lock: ", @$stat[3], "\n", 140 "epoch: ", @$stat[4], "\n", 141 "mtime: ", @$stat[5], "\n", 142 "available instances: ", @$stat[6], "\n", 143 "requested instances: ", $user_copies, "\n", 144 "total instances: ", @$stat[7], "\n", 145 146 "instance location:\n", " " x 4, 147 join("\n" . " " x 4, @$instances), "\n"; 148 } 149 114 150 } 115 else {116 print117 "object id: ", @$stat[0], "\n",118 "key: ", @$stat[1], "\n",119 "read lock: ", @$stat[2], "\n",120 "write lock: ", @$stat[3], "\n",121 "epoch: ", @$stat[4], "\n",122 "mtime: ", @$stat[5], "\n",123 "available instances: ", @$stat[6], "\n",124 "requested instances: ", $user_copies, "\n",125 "total instances: ", @$stat[7], "\n",126 127 "instance location:\n", " " x 4,128 join("\n" . " " x 4, @$instances), "\n";129 }130 151 131 152 … … 150 171 =over 4 151 172 152 =item *--server|-s <URL>173 =item --server|-s <URL> 153 174 154 175 URL of the Nebulous server to connect to. … … 156 177 Optional if the appropriate environment variable is set. 157 178 158 =item *--validate|-v179 =item --validate|-v 159 180 160 181 Optional - prints out additional information including md5sum. 161 182 162 =item *--files183 =item --files 163 184 164 185 Optional - prints out disk files instead of uris during validate stage. … … 174 195 =over 4 175 196 176 =item *C<NEB_SERVER>197 =item C<NEB_SERVER> 177 198 178 199 Equivalent to --server|-s -
trunk/Nebulous/lib/Nebulous/Client.pm
r40680 r41172 209 209 }, 210 210 ); 211 211 212 212 $log->debug( "entered - @_" ); 213 213 … … 310 310 my $stats = $self->stat($key); 311 311 my $instances = $stats->[6]; 312 312 313 if ((not defined $instances) or ($instances == 0)) { 313 314 $self->set_err("can not cull - no instances"); … … 315 316 return; 316 317 } 317 if ($instances < $min_copies) {318 if ($instances <= $min_copies) { 318 319 $self->set_err("can not cull - not enough instances"); 319 320 $log->debug("leaving"); 320 321 321 return; 322 322 } … … 334 334 335 335 unless (defined $locations) { 336 $self->set_err( "no instances" );337 336 $log->debug( "leaving" ); 338 339 337 return; 340 338 } … … 351 349 } 352 350 } 351 353 352 # If we don't have two copies on one volume, see if we have two copies on a single 354 353 # cabinet. If so, delete the first of those copies. … … 362 361 } 363 362 } 363 364 364 # Fail-safe. We didn't have any duplicates (the instances are "well-mixed"), so 365 365 # delete the first. … … 403 403 eval { 404 404 # first - strip off any inaccesible instances 405 # these are not counted in the 'removed' number 405 406 if (not defined $self->prune($key)) { 406 407 # use the prune() method to also determine if $key is valid 407 408 die "invalid key: $key"; 408 409 } 409 410 # check to see if there is an instance on $vol_name that should be the 411 # sole survivor 410 411 # check to see if there is an instance on $vol_name that 412 # should be the sole survivor. This is a bit dangerous : what 413 # if the only instance is on an invalid volume? what if an 414 # invalid volume is specified? 415 412 416 if (defined $vol_name) { 413 417 $locations = $self->find_instances($key, $vol_name); 418 if (not defined $locations) { 419 die "no instances on requested node"; 420 } 421 if (scalar @$locations == 0) { 422 die "no instances on requested node"; 423 } 414 424 } 415 425 … … 418 428 419 429 if (defined $locations) { 420 my $instances = $self->find_instances($key, undef, 'find them all'); 421 if (scalar @$instances == 1) { 422 # only one instance nothing to do 423 return 0; 424 } 425 if (scalar @$instances == 0) { 430 print "dev: looking for undef volume instances\n"; 431 # first delete the valid instances (except the one we own) 432 my $instances_valid = $self->find_instances($key, undef, 0); # find all valid instances 433 if (not defined $instances_valid) { 434 # there should have been at least one valid instance? 426 435 die "no instances"; 427 436 } 428 foreach my $victim (@$instances) { 429 next if $victim eq $locations->[0]; 430 $self->delete_instance($key, $victim); 431 $removed++; 437 if (scalar @$instances_valid == 0) { 438 # there should have been at least one valid instance? 439 die "no instances"; 432 440 } 441 442 # we have more than one instance, delete the others 443 if (scalar @$instances_valid > 1) { 444 foreach my $victim (@$instances_valid) { 445 next if $victim eq $locations->[0]; 446 $self->delete_instance($key, $victim); 447 $removed ++; 448 } 449 } 450 # the prune above should have deleted any invalid instances, so we only 451 # need to worry about the valid instances; 433 452 } else { 434 453 # nuke whatever … … 448 467 } 449 468 } 450 451 469 }; 452 470 if ($@) { … … 663 681 if ($response->fault) { 664 682 $self->set_err($response->faultstring); 683 684 ## invalid object key 685 if ($response->faultstring =~ /is valid object key/) { 686 $log->debug( "leaving" ); 687 die "invalid key $key, fails 'is valid object key' test\n"; 688 } 689 690 ## invalid object key 691 if ($response->faultstring =~ /xattr is in user. namespace/) { 692 $log->debug( "leaving" ); 693 die "invalid xattr key $name : fails 'xattr is in user. namespace' test\n"; 694 } 695 665 696 $log->logdie("unhandled fault - ", $self->err); 666 697 } … … 690 721 if ( $response->fault ) { 691 722 $self->set_err($response->faultstring); 723 724 ## invalid object key 725 if ($response->faultstring =~ /is valid object key/) { 726 $log->debug( "leaving" ); 727 die "invalid key $key, fails 'is valid object key' test\n"; 728 } 729 730 ## invalid xattr key (not in user. namespace) 731 if ($response->faultstring =~ /xattr is in user. namespace/) { 732 $log->debug( "leaving" ); 733 die "xattr $name is invalid : xattr is in user. namespace\n"; 734 } 735 736 ## invalid xattr key 737 if ($response->faultstring =~ /user\..*? does not exist/) { 738 $log->debug( "leaving" ); 739 die "xattr key $name not found : xattr $name does not exist\n"; 740 } 692 741 $log->logdie("unhandled fault - ", $self->err); 693 742 } … … 747 796 if ( $response->fault ) { 748 797 $self->set_err($response->faultstring); 798 799 ## invalid object key 800 if ($response->faultstring =~ /is valid object key/) { 801 $log->debug( "leaving" ); 802 die "invalid key $key, fails 'is valid object key' test\n"; 803 } 804 805 ## invalid xattr key (not in user. namespace) 806 if ($response->faultstring =~ /xattr is in user. namespace/) { 807 $log->debug( "leaving" ); 808 die "xattr $name is invalid : xattr is in user. namespace\n"; 809 } 810 811 ## invalid xattr key 812 if ($response->faultstring =~ /user\..*? does not exist/) { 813 $log->debug( "leaving" ); 814 die "xattr key $name not found : xattr $name does not exist\n"; 815 } 816 749 817 $log->logdie("unhandled fault - ", $self->err); 750 818 } … … 865 933 unless(defined($params[0])) { 866 934 $params[0] = hostname() . ".0"; 867 #print STDERR "Setting host to $params[0]\n";935 # print STDERR "Setting host to $params[0]\n"; 868 936 } 869 937 … … 871 939 if ( $response->fault ) { 872 940 $self->set_err($response->faultstring); 941 873 942 # check to see if this failure is because $key doesn't exist 874 943 if ($response->faultstring =~ /is valid object key/) { … … 878 947 # key is valid but no instances are on the specified volume 879 948 if ($response->faultstring =~ /no instances on storage volume/) { 949 $log->debug( "leaving" ); 950 return; 951 } 952 # check to see if this failure is volume is unknown 953 if ($response->faultstring =~ /is not a valid volume name/) { 954 $log->debug( "leaving" ); 955 return; 956 } 957 # key is valid but no instances are on the specified volume 958 if ($response->faultstring =~ /no instances available for key/) { 880 959 $log->debug( "leaving" ); 881 960 return; … … 949 1028 $self->set_err($response->faultstring); 950 1029 # check to see if this failure is because $key doesn't exist 1030 my $string = $response->faultstring; 951 1031 if ($response->faultstring =~ /is valid object key/) { 1032 $self->set_err("invalid object key"); 952 1033 $log->debug( "leaving" ); 953 1034 return; … … 955 1036 # key is valid but no instances are on the specified volume 956 1037 if ($response->faultstring =~ /no instances on storage volume/) { 1038 $self->set_err("no instances on storage volume or volume is not available"); 957 1039 $log->debug( "leaving" ); 958 1040 return; … … 972 1054 973 1055 1056 ## this is used by PS:IPP:Config nebulous functions 974 1057 sub find 975 1058 { … … 1014 1097 return $path; 1015 1098 } 1016 1017 1099 1018 1100 sub open … … 1124 1206 $log->debug( "entered - @_" ); 1125 1207 1126 1127 1208 my $locations; 1128 1209 if ($invalid) { 1129 $locations = $self->find_instances( $key, 'any', 'find them all'); 1210 # delete the invalid instances: 1211 $locations = $self->find_instances( $key, 'any', 1); 1130 1212 } 1131 1213 else { … … 1315 1397 } 1316 1398 1399 if ($response->faultstring =~ /is valid object key/) { 1400 $log->logdie("parameter #1 to delete_instance did not pass the 'is valid object key' callback"); 1401 } 1402 1317 1403 $log->logdie("unhandled fault - ", $self->err); 1318 1404 } … … 1477 1563 } 1478 1564 1565 sub set_log_level 1566 { 1567 my $self = shift; 1568 1569 my $log_level = shift; 1570 1571 $log->level($log_level); 1572 1573 return $self; 1574 } 1575 1479 1576 1480 1577 1; -
trunk/Nebulous/lib/Nebulous/Util.pm
r23934 r41172 78 78 # The instance file attempting to be opened should always exist as it was 79 79 # created by the Nebulous server. 80 80 81 my $fh; 81 82 for (my $i = 0; $i < 60; $i++) { … … 160 161 die "can not process $arg because it is not in name:value form" 161 162 unless defined $name and defined $value; 162 die "xattr name: $name is not in t o the form user.name"163 die "xattr name: $name is not in the form user.name" 163 164 unless $name =~ /^user\./; 164 165 $neb->setxattr($key, $name, $value, "replace") -
trunk/Nebulous/nebclient
- Property svn:ignore
-
old new 21 21 stamp-h1 22 22 test-driver 23 INSTALL 24 COPYING
-
- Property svn:ignore
-
trunk/Nebulous/nebclient/tests/tap
- Property svn:ignore
-
old new 19 19 src/.deps 20 20 src/Makefile 21 INSTALL 22 COPYING
-
- Property svn:ignore
-
trunk/Nebulous/nebclient/tests/tests.c
r24999 r41172 16 16 if (foo) nebFree(foo) 17 17 18 int show_instances (nebServer *server, char *key) { 19 20 nebObjectInstances *locations = NULL; 21 22 locations = nebFindInstances(server, key, NULL); 23 24 for (int i = 0; i < locations->n; i++) { 25 fprintf (stderr, "# loc %d : %s\n", i, locations->URI[i]); 26 } 27 nebObjectInstancesFree(locations); 28 return 1; 29 } 30 31 int count_instances (nebServer *server, char *key) { 32 33 nebObjectInstances *locations = NULL; 34 locations = nebFindInstances(server, key, NULL); 35 int Ninstances = locations ? locations->n : 0; 36 nebObjectInstancesFree(locations); 37 return Ninstances; 38 } 39 18 40 int main (int argc, char **argv) { 19 41 nebServer *server = NULL; 20 42 char *key = "foobarbaz"; 21 43 22 plan_tests(3 1);44 plan_tests(37); 23 45 24 46 if (getenv("NEB_SERVER")) { … … 37 59 filename = nebCreate(server, key, NULL, &URI); 38 60 diag("filename is %s", filename); 61 62 if (!filename) { 63 fprintf (stdout, "not ok: no files in test server, exiting\n"); 64 exit (2); 65 } 66 67 show_instances (server, key); 68 ok (count_instances (server, key) == 1, "correct instance count"); 69 39 70 neb_ok(server, filename, "create object"); 40 71 ok(URI, "URI not NULL"); … … 53 84 neb_ok(server, fh > -1, "create new object filehandle"); 54 85 ok(URI, "URI not NULL"); 86 ok (count_instances (server, key) == 1, "correct instance count"); 55 87 56 88 tst_nebFree(URI); 57 89 close(fh); 58 90 } 91 92 show_instances (server, key); 59 93 60 94 { … … 80 114 } 81 115 82 83 116 neb_ok(server, nebReplicate(server, key, NULL, NULL), "replicate object"); 117 show_instances (server, key); 118 ok (count_instances (server, key) == 2, "correct instance count"); 84 119 85 120 neb_ok(server, nebOpen(server, key, NEB_WRITE) < 0, "write to object with multiple instances"); 121 show_instances (server, key); 86 122 87 123 neb_ok(server, nebCull(server, key), "cull object"); 124 show_instances (server, key); 125 ok (count_instances (server, key) == 1, "correct instance count"); 126 127 neb_ok(server, nebCull(server, key) == 0, "cannot cull object with one instance"); 128 show_instances (server, key); 129 ok (count_instances (server, key) == 1, "correct instance count"); 88 130 89 131 neb_ok(server, nebStat(server, key), "stat object"); 132 show_instances (server, key); 90 133 91 134 neb_ok(server, nebLock(server, key, NEB_WRITE), "lock object write"); -
trunk/Nebulous/t/50_client_create.t
r24357 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 9;12 plan tests => 13; 13 13 14 14 use lib qw( ./t ./lib ); … … 19 19 use URI::Split qw( uri_split ); 20 20 21 # this returns the test apache server location 21 22 my $hostport = Apache::Test->config->{ 'hostport' }; 22 23 … … 30 31 31 32 my $uri = $neb->create("foo"); 33 if (not defined $uri) { die "failure to create basic file (does it already exist?)"; } 34 32 35 my ($scheme, $auth, $path, $query, $frag) = uri_split($uri); 33 36 ok(-e $path, "good filename"); 37 34 38 uri_scheme_ok($uri, 'file'); 39 40 # need to remove the test entry we made above (create fails if file exists) 41 ok( $neb->delete( "foo" ), "delete object" ); 35 42 } 36 43 … … 48 55 ok(-e $path, "good filename"); 49 56 uri_scheme_ok($uri, 'file'); 57 58 # need to remove the test entry we made above (create fails if file exists) 59 ok( $neb->delete( "foo" ), "delete object" ); 50 60 } 51 61 … … 63 73 ok(-e $path, "good filename"); 64 74 uri_scheme_ok($uri, 'file'); 75 76 # need to remove the test entry we made above (create fails if file exists) 77 ok( $neb->delete( "foo" ), "delete object" ); 65 78 } 66 79 … … 74 87 $neb->create("foo"); 75 88 is($neb->create("foo"), undef, "object already exists"); 89 90 # need to remove the test entry we made above (create fails if file exists) 91 ok( $neb->delete( "foo" ), "delete object" ); 76 92 } 77 93 -
trunk/Nebulous/t/53_client_cull.t
r25121 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 1 5;12 plan tests => 18; 13 13 14 14 use lib qw( ./t ./lib ); … … 21 21 22 22 Test::Nebulous->setup; 23 24 23 { 25 24 # key … … 37 36 38 37 Test::Nebulous->setup; 39 40 38 { 41 39 # key, $volume … … 43 41 proxy => "http://$hostport/nebulous", 44 42 ); 45 $neb->create("foo" );46 $neb->replicate("foo", "node0 1");47 48 my $uri = $neb->cull("foo", "node0 1");43 $neb->create("foo", "node01"); 44 $neb->replicate("foo", "node02"); 45 46 my $uri = $neb->cull("foo", "node02"); 49 47 50 48 ok($uri, "good cull"); 51 49 ok(! -e _get_file_path($uri), "file exists"); 50 } 51 52 Test::Nebulous->setup; 53 { 54 # key, $volume 55 my $neb = Nebulous::Client->new( 56 proxy => "http://$hostport/nebulous", 57 ); 58 $neb->create("foo", "node01"); 59 $neb->replicate("foo", "node02"); 60 61 # cull with soft volume should succeed even if node does not have instance 62 my $uri = $neb->cull("foo", "node03"); 63 64 ok($uri, "good cull"); 65 ok(! -e _get_file_path($uri), "file exists"); 66 } 67 68 Test::Nebulous->setup; 69 { 70 # key, $volume 71 my $neb = Nebulous::Client->new( 72 proxy => "http://$hostport/nebulous", 73 ); 74 $neb->create("foo", "node01"); 75 $neb->replicate("foo", "node02"); 76 77 # cull with hard volume should not succeed if node does not have instance 78 my $uri = $neb->cull("foo", "~node03"); 79 80 is($uri, undef, "nothing to cull on this node"); 52 81 } 53 82 … … 112 141 proxy => "http://$hostport/nebulous", 113 142 ); 114 $neb->cull(); 143 my $uri = $neb->cull(); 144 145 is ($uri, undef, "no params given to cull"); 115 146 }; 116 147 like( $@, qr/1 - 3 were expected/, "no params" ); … … 122 153 proxy => "http://$hostport/nebulous", 123 154 ); 124 $neb->cull( 1, 2, 3, 4 ); 155 my $uri = $neb->cull( 1, 2, 3, 4 ); 156 157 is ($uri, undef, "no params given to cull"); 125 158 }; 126 159 like( $@, qr/1 - 3 were expected/, "too many params" ); -
trunk/Nebulous/t/56_client_find_instances.t
r19469 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 29;12 plan tests => 35; 13 13 14 14 use lib qw( ./t ./lib ); … … 20 20 my $hostport = Apache::Test->config->{ 'hostport' }; 21 21 22 Test::Nebulous->setup; 23 22 ### XXX EAM : this test suite finds real errors in the implementation. 23 24 ## the API is now slightly different (what is the state of the API in the ipp ops code?) 25 ## find_instances ("key", "volume", find_invalid) 26 27 ## this returns a result even if we request a hard volume unless the hard volume is not valid 28 29 Test::Nebulous->setup; 30 Test::Nebulous->cleanup; 31 32 ### TEST BLOCK for find_invalid 33 ## Test::Nebulous->setup; 34 ## { 35 ## # volume/key, volume override 36 ## my $neb = Nebulous::Client->new( 37 ## proxy => "http://$hostport/nebulous", 38 ## ); 39 ## $neb->create( "foo", "~node02" ); 40 ## $neb->replicate( "foo", "~node01" ); 41 ## 42 ## Test::Nebulous->switch_node_state; 43 ## my $tmphost; 44 ## 45 ## # my $locations = $neb->find_instances( "neb:///foo", "~node02", 1); # result : no instance 46 ## # my $locations = $neb->find_instances( "neb:///foo", "~node02", 0); # result : no instance 47 ## # my $locations = $neb->find_instances( "neb:///foo", "~node02"); # result : no instance 48 ## 49 ## # my $locations = $neb->find_instances( "neb:///foo", "node02", 1); # result : no instance 50 ## # my $locations = $neb->find_instances( "neb:///foo", "node02", 0); # result : no instance 51 ## my $locations = $neb->find_instances( "neb:///foo", "node02"); # result : no instances 52 ## 53 ## # my $locations = $neb->find_instances( "neb:///foo", undef, 1); 54 ## # my $locations = $neb->find_instances( "neb:///foo", undef, 0); 55 ## # my $locations = $neb->find_instances( "neb:///foo", $tmphost, 0); 56 ## 57 ## # my $locations = $neb->find_instances( "neb:///foo", "bebaz", 1); 58 ## # my $locations = $neb->find_instances( "neb:///foo", "bebaz", 0); 59 ## 60 ## # my $locations = $neb->find_instances( "neb:///foo"); 61 ## # my $locations = $neb->find_instances( "neb://bebaz/foo"); 62 ## 63 ## # my $locations = $neb->find_instances( "neb:///foo"); 64 ## # my $locations = $neb->find_instances( "neb:///foo", undef, 0); 65 ## 66 ## foreach my $f (@$locations) { 67 ## print "location: $f\n"; 68 ## } 69 ## 70 ## is( scalar @$locations, 1, "found 1" ); 71 ## like( @$locations[0], qr/file:/, "URIs match" ); 72 ## ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 73 ## } 74 ## die "quit"; 75 76 ## Test::Nebulous->setup; 77 ## eval { 78 ## # volume/key, volume override 79 ## my $neb = Nebulous::Client->new( 80 ## proxy => "http://$hostport/nebulous", 81 ## ); 82 ## $neb->create( "foo", "~node01" ); 83 ## 84 ## my $locations_1 = $neb->find_instances( "neb://~invalid/foo", "~invalid"); 85 ## is($locations_1, undef, "no instances in invalid node" ); 86 ## 87 ## # EAM: we fail this test because the logic of find_instances has 88 ## # changed: as long as there is an instance on a valid node, the 89 ## # instance gets returned 90 ## my $locations = $neb->find_instances( "neb://node01/foo", "~node02" ); 91 ## is($locations, undef, "no instances on specified volume" ); 92 ## }; 93 ##print "result: $@\n"; 94 ##like( $@, qr/result message/, "my message" ); 95 96 # find a single instance by raw name (foo) 97 Test::Nebulous->setup; 24 98 { 25 99 # key … … 36 110 } 37 111 38 Test::Nebulous->setup; 39 112 # find a both instances of a duplicated object 113 Test::Nebulous->setup; 40 114 { 41 115 # key … … 56 130 57 131 Test::Nebulous->setup; 58 59 132 { 60 133 # key, volume … … 79 152 ); 80 153 $neb->create( "foo" ); 154 $neb->set_log_level ('DEBUG'); 81 155 82 156 my $locations = $neb->find_instances( "foo", undef ); … … 103 177 } 104 178 105 Test::Nebulous->setup; 106 179 # find instance using hard_volume for wrong node 180 # (should still return a valid instance) 181 Test::Nebulous->setup; 107 182 { 108 183 # volume/key, volume override … … 111 186 ); 112 187 $neb->create( "foo", "~node01" ); 188 $neb->set_log_level ('DEBUG'); 113 189 114 190 my $locations = $neb->find_instances( "neb://node01/foo", "~node02" ); 115 191 192 is( scalar @$locations, 1, "found 1" ); 193 like( @$locations[0], qr/file:/, "URIs match" ); 194 ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 195 # the API used to return undef if we used a hard_volume but it was not there 196 # is($locations, undef, "no instances on specified volume" ); 197 } 198 199 # find instance using hard_volume for unknown node 200 # (should fail) 201 Test::Nebulous->setup; 202 { 203 # volume/key, volume override 204 my $neb = Nebulous::Client->new( 205 proxy => "http://$hostport/nebulous", 206 ); 207 $neb->create( "foo", "~node01" ); 208 $neb->set_log_level ('DEBUG'); 209 210 my $locations = $neb->find_instances( "neb://node01/foo", "~nobody" ); 116 211 is($locations, undef, "no instances on specified volume" ); 212 # is( scalar @$locations, 0, "found 0" ); 213 # under Ubuntu (Perl 5.26.1), @$locations evaluates to 0 if $locations is undef, 214 # but not under Gentoo (Perl 5.6.6) 215 } 216 217 # find instance using hard_volume for unavailable node 218 # (should fail) 219 Test::Nebulous->setup; 220 { 221 # volume/key, volume override 222 my $neb = Nebulous::Client->new( 223 proxy => "http://$hostport/nebulous", 224 ); 225 $neb->create( "foo", "~node01" ); 226 $neb->set_log_level ('DEBUG'); 227 228 my $locations = $neb->find_instances( "neb://node01/foo", "~node04" ); 229 230 is( scalar @$locations, 1, "found 1" ); 231 like( @$locations[0], qr/file:/, "URIs match" ); 232 ok( -e _get_file_path( @$locations[0] ), "URI matches file" ); 233 234 # the API used to return undef if we used a hard_volume but it was not there 235 # is($locations, undef, "no instances on specified volume" ); 117 236 } 118 237 … … 153 272 154 273 Test::Nebulous->setup; 155 156 274 { 157 275 my $neb = Nebulous::Client->new( … … 171 289 $neb->find_instances(); 172 290 }; 173 like( $@, qr/1 - 2were expected/, "no params" );291 like( $@, qr/1 - 3 were expected/, "no params" ); 174 292 175 293 Test::Nebulous->setup; … … 180 298 ); 181 299 182 $neb->find_instances( "foo", 'read', 3 );300 $neb->find_instances( "foo", 'read', 3, 5 ); 183 301 }; 184 like( $@, qr/1 - 2were expected/, "too many params" );302 like( $@, qr/1 - 3 were expected/, "too many params" ); 185 303 186 304 Test::Nebulous->cleanup; -
trunk/Nebulous/t/59_client_delete.t
r24440 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 1 3;12 plan tests => 18; 13 13 14 14 use lib qw( ./t ./lib ); … … 20 20 my $hostport = Apache::Test->config->{ 'hostport' }; 21 21 22 Test::Nebulous->setup; 23 22 # ensure fresh start: 23 Test::Nebulous->setup; 24 Test::Nebulous->cleanup; 25 26 Test::Nebulous->setup; 24 27 { 25 28 my $neb = Nebulous::Client->new( … … 78 81 } 79 82 80 # force flag 81 Test::Nebulous->setup; 82 83 # test passing in undefined force flag 84 Test::Nebulous->setup; 83 85 { 84 86 my $neb = Nebulous::Client->new( … … 90 92 } 91 93 92 Test::Nebulous->setup; 93 94 # test passing in force flag = 1 95 Test::Nebulous->setup; 94 96 { 95 97 my $neb = Nebulous::Client->new( … … 101 103 } 102 104 105 # test passing in force flag = 0 106 Test::Nebulous->setup; 107 { 108 my $neb = Nebulous::Client->new( 109 proxy => "http://$hostport/nebulous", 110 ); 111 $neb->create( "foo" ); 112 113 is( $neb->delete("foo", 0), 1, "force flag false" ); 114 } 115 116 # test passing in force flag = 0 where disk file is removed 117 Test::Nebulous->setup; 118 eval { 119 my $neb = Nebulous::Client->new( 120 proxy => "http://$hostport/nebulous", 121 ); 122 $neb->create( "foo" ); 123 my $locations = $neb->find_instances( "foo" ); 124 my $diskfile = _get_file_path(@$locations[0]); 125 unlink $diskfile; 126 $neb->delete("foo", 0); 127 }; 128 like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" ); 129 130 # test passing in force flag = 1 where disk file is removed 131 Test::Nebulous->setup; 132 { 133 my $neb = Nebulous::Client->new( 134 proxy => "http://$hostport/nebulous", 135 ); 136 $neb->create( "foo" ); 137 my $locations = $neb->find_instances( "foo" ); 138 my $diskfile = _get_file_path(@$locations[0]); 139 unlink $diskfile; 140 is( $neb->delete("foo", 1), 1, "force flag true deletes file" ); 141 } 142 143 # test passing in undef force flag where disk file is removed 144 Test::Nebulous->setup; 145 eval { 146 my $neb = Nebulous::Client->new( 147 proxy => "http://$hostport/nebulous", 148 ); 149 $neb->create( "foo" ); 150 my $locations = $neb->find_instances( "foo" ); 151 my $diskfile = _get_file_path(@$locations[0]); 152 unlink $diskfile; 153 $neb->delete("foo", undef); 154 }; 155 like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" ); 156 157 # test passing in undefined force flag where disk file is removed 158 Test::Nebulous->setup; 159 eval { 160 my $neb = Nebulous::Client->new( 161 proxy => "http://$hostport/nebulous", 162 ); 163 $neb->create( "foo" ); 164 my $locations = $neb->find_instances( "foo" ); 165 my $diskfile = _get_file_path(@$locations[0]); 166 unlink $diskfile; 167 $neb->delete("foo"); 168 }; 169 like( $@, qr/can't unlink file/, "no force flag, cannot delete inconsistent file" ); 170 103 171 Test::Nebulous->setup; 104 172 … … 109 177 $neb->delete(); 110 178 }; 111 like( $@, qr/1 - 2were expected/, "no params" );179 like( $@, qr/1 - 3 were expected/, "no params" ); 112 180 113 181 Test::Nebulous->setup; … … 127 195 proxy => "http://$hostport/nebulous", 128 196 ); 129 $neb->delete( "foo", 0, 2 );130 }; 131 like( $@, qr/1 - 2were expected/, "too many params" );197 $neb->delete( "foo", 0, 1, 2 ); 198 }; 199 like( $@, qr/1 - 3 were expected/, "too many params" ); 132 200 133 201 Test::Nebulous->cleanup; -
trunk/Nebulous/t/64_client_find_objects.t
r17693 r41172 21 21 22 22 Test::Nebulous->setup; 23 24 23 { 25 24 # key -
trunk/Nebulous/t/65_client_mounts.t
r19494 r41172 29 29 my $mounts = $neb->mounts(); 30 30 31 is(scalar @$mounts, 7, "number of rows");31 is(scalar @$mounts, 8, "number of rows"); 32 32 33 33 my %row; -
trunk/Nebulous/t/66_client_xattr.t
r24301 r41172 21 21 ); 22 22 23 # 1 key / xattr 24 25 Test::Nebulous->setup; 26 23 # setxattr 24 Test::Nebulous->setup; 27 25 { 28 26 my $uri = $neb->create('foo'); … … 46 44 47 45 # multiple xattrs 48 49 Test::Nebulous->setup; 50 46 Test::Nebulous->setup; 51 47 { 52 48 my $uri = $neb->create('foo'); … … 184 180 $neb->getxattr('foo', 'user.bar'); 185 181 }; 186 like($@, qr|xattr neb:///foo:user.bar does not exist|,182 like($@, qr|xattr user.bar does not exist|, 187 183 "get xattr from non-existant xattr key"); 188 184 … … 256 252 $neb->removexattr('foo', 'user.bar'); 257 253 }; 258 like($@, qr|xattr neb:///foo:user.bar does not exist|,254 like($@, qr|xattr user.bar does not exist|, 259 255 "remove xattr from non-existant xattr key"); 260 256 -
trunk/Nebulous/t/68_client_chmod.t
r24281 r41172 41 41 is($mode, 0440, "returned mode"); 42 42 is($neb->getxattr($key, 'user.mode'), 0440, "xattr user.mode"); 43 44 # reset to 600 so the user can delete the file and /tmp entry 45 chmod(0600, $path); 43 46 } 44 47 … … 53 56 my $mode = $neb->chmod($key, 0440); 54 57 55 my $st1 = stat(URI->new($uri1)->path); 56 my $st2 = stat(URI->new($uri2)->path); 58 my $path1 = URI->new($uri1)->path; 59 my $path2 = URI->new($uri2)->path; 60 61 my $st1 = stat($path1); 62 my $st2 = stat($path2); 57 63 58 64 is($st1->mode &07777, 0440, "chmod() first instance"); … … 60 66 is($mode, 0440, "returned mode"); 61 67 is($neb->getxattr($key, 'user.mode'), 0440, "xattr user.mode"); 68 69 # reset to 600 so the user can delete the file and /tmp entry 70 chmod(0600, $path1); 71 chmod(0600, $path2); 62 72 } 63 73 -
trunk/Nebulous/t/70_neb-ls.t
r24560 r41172 23 23 use Test::Cmd; 24 24 use Nebulous::Client; 25 use Nebulous::Util qw( :standard ); 25 26 use Test::Nebulous; 26 27 … … 28 29 my $neb_url = "http://$hostport/nebulous"; 29 30 30 31 31 my $cmd = 'bin/neb-ls'; 32 32 33 # last ditch effort to make sure dsgetis executable33 # last ditch effort to make sure neb-ls is executable 34 34 chmod 0755, 'bin/neb-ls'; 35 35 … … 37 37 isa_ok($test, 'Test::Cmd'); 38 38 39 # NEB_SERVER env var not set39 # test if NEB_SERVER env var not set 40 40 undef $ENV{'NEB_SERVER'} if defined $ENV{'NEB_SERVER'}; 41 41 Test::Nebulous->setup; 42 43 42 { 44 43 $test->run(args => ''); … … 46 45 } 47 46 48 # NEB_SERVER set 49 Test::Nebulous->setup; 50 47 # NEB_SERVER set (and used in the following tests) 48 Test::Nebulous->setup; 51 49 { 52 50 $ENV{NEB_SERVER} = $neb_url; … … 57 55 58 56 Test::Nebulous->setup; 59 60 { 61 my $neb = Nebulous::Client->new( 62 proxy => $neb_url, 63 ); 64 $neb->create('foo'); 65 66 $test->run(args => ''); 67 57 { 58 my $neb = Nebulous::Client->new( 59 proxy => $neb_url, 60 ); 61 $neb->create('foo'); 62 63 $test->run(args => ''); 68 64 is($? >> 8, 0, "exit code"); 69 65 like($test->stdout, qr/^foo$/, "stdout"); … … 72 68 73 69 Test::Nebulous->setup; 74 75 70 { 76 71 my $neb = Nebulous::Client->new( … … 83 78 84 79 is($? >> 8, 0, "exit code"); 85 like($test->stdout, qr/^bar\ nfoo$/, "stdout");80 like($test->stdout, qr/^bar\s+foo$/, "stdout"); 86 81 like($test->stderr, qr/^$/, "stderr"); 87 82 } 88 83 89 84 Test::Nebulous->setup; 90 85 { 86 my $neb = Nebulous::Client->new( 87 proxy => $neb_url, 88 ); 89 $neb->create('foo'); 90 91 my $locations = $neb->find_instances( "foo" ); 92 my $diskfile = _get_file_path( @$locations[0] ); 93 my $filestats = `ls -l $diskfile`; 94 95 $test->run(args => '-l'); 96 97 is($? >> 8, 0, "exit code"); 98 like($test->stdout, qr/^$filestats$/, "stdout"); 99 like($test->stderr, qr/^$/, "stderr"); 100 } 101 102 Test::Nebulous->setup; 91 103 { 92 104 my $neb = Nebulous::Client->new( … … 96 108 $neb->create('bar'); 97 109 98 $test->run(args => '- l');110 $test->run(args => '-c'); 99 111 100 112 is($? >> 8, 0, "exit code"); … … 109 121 proxy => $neb_url, 110 122 ); 111 $neb->create('foo'); 112 $neb->create('bar'); 113 114 $test->run(args => '-1'); 115 116 is($? >> 8, 0, "exit code"); 117 like($test->stdout, qr/^bar\nfoo\n$/, "stdout"); 118 like($test->stderr, qr/^$/, "stderr"); 119 } 120 121 Test::Nebulous->setup; 122 123 { 124 my $neb = Nebulous::Client->new( 125 proxy => $neb_url, 126 ); 127 $neb->create('a/foo'); 128 129 $test->run(args => ''); 130 131 is($? >> 8, 0, "exit code"); 132 like($test->stdout, qr||, "stdout"); 123 $neb->create('a/foo'); 124 125 $test->run(args => ''); 126 127 is($? >> 8, 0, "exit code"); 128 like($test->stdout, qr|^a/$|, "stdout"); 133 129 like($test->stderr, qr/^$/, "stderr"); 134 130 } … … 161 157 162 158 is($? >> 8, 0, "exit code"); 163 like($test->stdout, qr|^a/bar\ na/foo$|, "stdout");159 like($test->stdout, qr|^a/bar\s+a/foo$|, "stdout"); 164 160 like($test->stderr, qr/^$/, "stderr"); 165 161 } … … 193 189 194 190 is($? >> 8, 0, "exit code"); 195 like($test->stdout, qr|^a/b/\ na/foo$|, "stdout");191 like($test->stdout, qr|^a/b/\s+a/foo$|, "stdout"); 196 192 like($test->stderr, qr/^$/, "stderr"); 197 193 } -
trunk/Nebulous/t/71_client_there_can_be_only_one.t
r24930 r41172 10 10 use Apache::Test qw( -withtestmore ); 11 11 12 plan tests => 8;12 plan tests => 13; 13 13 14 14 use lib qw( ./t ./lib ); … … 21 21 22 22 Test::Nebulous->setup; 23 Test::Nebulous->cleanup; 23 24 25 ## volume is defined, but it is not valid (should exit) 26 ## Test::Nebulous->setup; 27 ## { 28 ## my $key = "foo"; 29 ## my $neb = Nebulous::Client->new( 30 ## proxy => "http://$hostport/nebulous", 31 ## ); 32 ## 33 ## my $uri = $neb->create($key, "node01"); 34 ## 35 ## $neb->replicate($key, "node02"); 36 ## 37 ## ## set node02 to an invalid state: 38 ## Test::Nebulous->switch_node_state; 39 ## 40 ## # if requested node is invalid, the other instance is kept and the invalid one removed 41 ## # but since invalid instances are removed with a prune call, they are not counted 42 ## # in the number of items removed (return by the function call) 43 ## is($neb->there_can_be_only_one($key, "node02"), 0, "there can be only one!"); 44 ## my $locations = $neb->find_instances( "foo" ); 45 ## 46 ## is( scalar @$locations, 1, "found 1" ); 47 ## is($locations->[0], $uri, "instance on correct volume" ); 48 ## }; 49 ## is($@, "", "there_can_be_only_one with supplied volume should succeed"); 50 ## die "asdf"; 51 52 ####### 53 54 ## volume not defined 55 Test::Nebulous->setup; 24 56 { 25 57 my $key = "foo"; … … 37 69 } 38 70 71 ## volume is defined, only valid instances 39 72 Test::Nebulous->setup; 40 41 { 73 eval { 42 74 my $key = "foo"; 43 75 my $neb = Nebulous::Client->new( … … 45 77 ); 46 78 $neb->create($key, "node01"); 79 47 80 my $uri = $neb->replicate($key, "node02"); 48 49 81 is($neb->there_can_be_only_one($key, "node02"), 1, "there can be only one!"); 50 82 … … 53 85 is( scalar @$locations, 1, "found 1" ); 54 86 is($locations->[0], $uri, "instance on correct volume" ); 55 } 87 }; 88 is($@, "", "there_can_be_only_one with supplied volume should succeed"); 89 90 ## volume is defined, but it is not valid (should exit) 91 Test::Nebulous->setup; 92 eval { 93 my $key = "foo"; 94 my $neb = Nebulous::Client->new( 95 proxy => "http://$hostport/nebulous", 96 ); 97 my $uri = $neb->create($key, "node01"); 98 99 $neb->replicate($key, "node02"); 100 101 ## set node02 to an invalid state: 102 Test::Nebulous->switch_node_state; 103 104 # if requested node is invalid, nothing is removed 105 is($neb->there_can_be_only_one($key, "node02"), 0, "there can be only one!"); 106 107 my $locations = $neb->find_instances( "foo" ); 108 109 is( scalar @$locations, 1, "found 1" ); 110 is($locations->[0], $uri, "instance on correct volume" ); 111 }; 112 is($@, "", "there_can_be_only_one with supplied volume should succeed"); 56 113 57 114 Test::Nebulous->setup; -
trunk/Nebulous/t/72_neb-cull.t
r25121 r41172 39 39 # NEB_SERVER env var not set 40 40 undef $ENV{'NEB_SERVER'} if defined $ENV{'NEB_SERVER'}; 41 Test::Nebulous->setup; 42 41 42 ## problem test 43 ## Test::Nebulous->setup; 44 ## { 45 ## $ENV{NEB_SERVER} = $neb_url; 46 ## 47 ## my $key = 'foo'; 48 ## 49 ## my $neb = Nebulous::Client->new( 50 ## proxy => $neb_url, 51 ## ); 52 ## $neb->create($key); 53 ## 54 ## $test->run(args => "--one_only " . $key); 55 ## 56 ## ## my $line1 = $test->stdout; 57 ## ## print "stdout: $line1\n"; 58 ## ## 59 ## ## my $line2 = $test->stderr; 60 ## ## print "stderr: $line2\n"; 61 ## 62 ## is($neb->stat($key)->[6], 1, "correct # of instances"); 63 ## is($? >> 8, 255, "exit code"); 64 ## like($test->stdout, qr/^$/, "stdout"); 65 ## like($test->stderr, qr/no instances/, "stderr"); 66 ## } 67 ## die "stop"; 68 69 ## Test::Nebulous->setup; 70 ## { 71 ## my $key = 'foo'; 72 ## 73 ## my $neb = Nebulous::Client->new( 74 ## proxy => $neb_url, 75 ## ); 76 ## $neb->create($key); 77 ## $neb->replicate($key); 78 ## 79 ## $test->run(args => "--server $neb_url $key"); 80 ## 81 ## my $line = $test->stderr; 82 ## print "stderr: $line\n"; 83 ## 84 ## is($neb->stat($key)->[6], 1, "correct # of instances"); 85 ## is($? >> 8, 0, "exit code"); 86 ## like($test->stdout, qr/^$/, "stdout"); 87 ## like($test->stderr, qr/^$/, "stderr"); 88 ## } 89 ## die "TEST"; 90 91 Test::Nebulous->setup; 43 92 { 44 93 $test->run(args => ''); … … 48 97 # NEB_SERVER set 49 98 Test::Nebulous->setup; 50 51 99 { 52 100 $ENV{NEB_SERVER} = $neb_url; … … 57 105 58 106 Test::Nebulous->setup; 59 60 { 61 my $key = 'foo'; 62 63 my $neb = Nebulous::Client->new( 64 proxy => $neb_url, 65 ); 66 $neb->create($key); 107 { 108 my $key = 'foo'; 109 110 my $neb = Nebulous::Client->new( 111 proxy => $neb_url, 112 ); 113 $neb->create($key); 114 115 $test->run(args => "--server $neb_url $key"); 116 # $test->run(args => $key); 117 118 is($neb->stat($key)->[6], 1, "correct # of instances"); 119 is($? >> 8, 255, "exit code"); 120 like($test->stdout, qr/^$/, "stdout"); 121 like($test->stderr, qr/failed to cull Nebulous key/, "stderr"); 122 } 123 124 Test::Nebulous->setup; 125 126 { 127 my $key = 'foo'; 128 129 my $neb = Nebulous::Client->new( 130 proxy => $neb_url, 131 ); 132 $neb->create($key); 133 $neb->replicate($key); 67 134 68 135 $test->run(args => $key); 69 136 70 is($neb->stat($key)->[6], 1, "correct # of instances"); 71 is($? >> 8, 255, "exit code"); 72 like($test->stdout, qr/^$/, "stdout"); 73 like($test->stderr, qr/failed to cull Nebulous key/, "stderr"); 74 } 75 76 Test::Nebulous->setup; 77 78 { 79 my $key = 'foo'; 80 81 my $neb = Nebulous::Client->new( 82 proxy => $neb_url, 83 ); 84 $neb->create($key); 137 my $line = $test->stderr; 138 139 # the default min_copies is 2: 140 is($neb->stat($key)->[6], 2, "correct # of instances"); 141 is($? >> 8, 255, "exit code"); 142 like($test->stdout, qr/^$/, "stdout"); 143 like($test->stderr, qr/not enough instances/, "stderr"); 144 } 145 146 Test::Nebulous->setup; 147 148 { 149 my $key = 'foo'; 150 151 my $neb = Nebulous::Client->new( 152 proxy => $neb_url, 153 ); 154 $neb->create($key); 155 $neb->replicate($key); 85 156 $neb->replicate($key); 86 157 87 158 $test->run(args => $key); 88 159 89 is($neb->stat($key)->[6], 1, "correct # of instances");90 is($? >> 8, 0, "exit code");91 like($test->stdout, qr/^$/, "stdout");92 like($test->stderr, qr/^$/, "stderr");93 }94 95 Test::Nebulous->setup;96 97 {98 my $key = 'foo';99 100 my $neb = Nebulous::Client->new(101 proxy => $neb_url,102 );103 $neb->create($key);104 $neb->replicate($key);105 $neb->replicate($key);106 107 $test->run(args => $key);108 109 160 is($neb->stat($key)->[6], 2, "correct # of instances"); 110 161 is($? >> 8, 0, "exit code"); … … 113 164 } 114 165 166 ## problem test 115 167 Test::Nebulous->setup; 116 168 … … 202 254 203 255 is($neb->stat($key)->[6], 1, "correct # of instances"); 204 is($? >> 8, 0, "exit code"); 256 257 is($? >> 8, 255, "exit code"); 205 258 like($test->stdout, qr/^$/, "stdout"); 206 259 like($test->stderr, qr/not enough instances/, "stderr"); … … 221 274 $test->run(args => "--min_copies 2 " . $key); 222 275 223 is($neb->stat($key)->[6], 1, "correct # of instances");276 is($neb->stat($key)->[6], 2, "correct # of instances"); 224 277 is($? >> 8, 0, "exit code"); 225 278 like($test->stdout, qr/^$/, "stdout"); -
trunk/Nebulous/t/conf/extra.conf.in
r4911 r41172 3 3 # this file will be Include-d by @ServerRoot@/httpd.conf 4 4 5 # need to add MPM? 6 7 # Conflicts: mpm_worker mpm_prefork 8 #LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so 9 #LoadModule authz_core_module /usr/lib/apache2/modules/mod_authz_core.so 10 LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so 11 #LoadModule cgid_module /usr/lib/apache2/modules/mod_cgid.so 12 LoadModule cgi_module /usr/lib/apache2/modules/mod_cgi.so 13 LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so 14 15 # event MPM 16 # StartServers: initial number of server processes to start 17 # MinSpareThreads: minimum number of worker threads which are kept spare 18 # MaxSpareThreads: maximum number of worker threads which are kept spare 19 # ThreadsPerChild: constant number of worker threads in each server process 20 # MaxRequestWorkers: maximum number of worker threads 21 # MaxConnectionsPerChild: maximum number of requests a server process serves 22 <IfModule mpm_event_module> 23 StartServers 2 24 MinSpareThreads 25 25 MaxSpareThreads 75 26 ThreadLimit 64 27 ThreadsPerChild 25 28 MaxRequestWorkers 150 29 MaxConnectionsPerChild 0 30 </IfModule> 31 32 <IfModule mod_alias.c> 33 <IfModule mod_cgi.c> 34 # Define ENABLE_USR_LIB_CGI_BIN 35 </IfModule> 36 37 <IfModule mod_cgid.c> 38 # Define ENABLE_USR_LIB_CGI_BIN 39 </IfModule> 40 41 <IfDefine ENABLE_USR_LIB_CGI_BIN> 42 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 43 <Directory "/usr/lib/cgi-bin"> 44 AllowOverride None 45 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 46 Require all granted 47 </Directory> 48 </IfDefine> 49 </IfModule> 50 51 # nebulous location: 5 52 <Location /nebulous> 6 53 SetHandler perl-script 7 PerlResponseHandler Apache 2::SOAP54 PerlResponseHandler Apache::SOAP 8 55 PerlSetVar dispatch_to "PerlHandler Nebulous::Server::SOAP" 9 56 PerlSetVar options "compress_threshold => 10000" -
trunk/Nebulous/t/conf/startup.pl.in
r24372 r41172 5 5 use lib qw( @ServerRoot@ ); 6 6 7 use ModPerl::Util (); #for CORE::GLOBAL::exit 8 9 use Apache2::RequestRec (); 10 use Apache2::RequestIO (); 11 use Apache2::RequestUtil (); 12 13 use Apache2::ServerRec (); 14 use Apache2::ServerUtil (); 15 use Apache2::Connection (); 16 use Apache2::Log (); 17 18 use APR::Table (); 19 20 use ModPerl::Registry (); 21 22 use Apache2::Const -compile => ':common'; 23 use APR::Const -compile => ':common'; 24 25 use Apache::SOAP; 26 7 27 use Apache::DBI; 8 28 use DBI; … … 10 30 use Nebulous::Server::Apache; 11 31 use Nebulous::Server; 12 use Test::Nebulous; 32 33 # do not inherit here, let's be explicit 34 # use Test::Nebulous; 35 36 # EAM : making this match Nebulous-Server/docs/apache2-mod_perl-startup.pl: 37 38 # use the real mysql server: 39 #my $dsn = 'DBI:mysql:database=nebulous:host=localhost,mysql_socket=8500'; 40 #my $dbuser = 'nebulous'; 41 #my $dbpasswd = ''; 42 43 # use the test mysql server (defined in Test::Nebulous) 44 my $dsn = 'DBI:mysql:database=test:host=localhost:mysql_socket=/var/run/mysqld/mysqld.sock'; 45 my $dbuser = 'test'; 46 my $dbpasswd = ''; 13 47 14 48 #$Apache::DBI::DEBUG = 1; 15 Apache::DBI->connect_on_init( $NEB_DB, $NEB_USER, $NEB_PASS );16 Apache::DBI->setPingTimeOut($ NEB_DB, 10);49 #Apache::DBI->connect_on_init( $NEB_DB, $NEB_USER, $NEB_PASS ); 50 Apache::DBI->setPingTimeOut($dsn, 10); 17 51 18 52 my $config = Nebulous::Server::Config->new( … … 22 56 $config->add_db( 23 57 dbindex => 0, 24 dsn => $ NEB_DB,25 dbuser => $ NEB_USER,26 dbpasswd => $ NEB_PASS,58 dsn => $dsn, 59 dbuser => $dbuser, 60 dbpasswd => $dbpasswd, 27 61 ); 28 #$config->add_db(29 # dbindex => 1,30 # dsn => 'DBI:mysql:database=nebulous1:host=localhost',31 # dbuser => $dbuser,32 # dbpasswd => $dbpasswd,33 #);34 62 35 63 Nebulous::Server::SOAP->new_on_init($config);
Note:
See TracChangeset
for help on using the changeset viewer.
