Changeset 41172 for trunk/Nebulous/t
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- Location:
- trunk/Nebulous/t
- Files:
-
- 13 edited
-
50_client_create.t (modified) (6 diffs)
-
53_client_cull.t (modified) (6 diffs)
-
56_client_find_instances.t (modified) (10 diffs)
-
59_client_delete.t (modified) (7 diffs)
-
64_client_find_objects.t (modified) (1 diff)
-
65_client_mounts.t (modified) (1 diff)
-
66_client_xattr.t (modified) (4 diffs)
-
68_client_chmod.t (modified) (3 diffs)
-
70_neb-ls.t (modified) (11 diffs)
-
71_client_there_can_be_only_one.t (modified) (5 diffs)
-
72_neb-cull.t (modified) (6 diffs)
-
conf/extra.conf.in (modified) (1 diff)
-
conf/startup.pl.in (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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.
