Changeset 40982 for branches/eam_branches/ipp-20191011
- Timestamp:
- Oct 28, 2019, 2:17:03 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous-Server/t/08_server_find_instances.t
r24362 r40982 8 8 use warnings FATAL => qw( all ); 9 9 10 use Test::More tests => 19;10 use Test::More tests => 25; 11 11 12 12 use lib qw( ./t ./lib ); … … 22 22 ); 23 23 24 Test::Nebulous->setup; 25 24 # object exists but instance is on a different volume 25 # "~node02" is meant to be a hard volume 26 27 # XXX previously, the logic was: if we request a hard volume location 28 # using ~node, then we would give an error if no data is available except on that node. 29 30 # the code has been modified so that the requested storage object is provided if possible, 31 # even if the apparently "hard" target did not exist. 32 33 Test::Nebulous->setup; 34 Test::Nebulous->cleanup; # make sure the database is reset before running any tests 35 36 Test::Nebulous->setup; 26 37 { 27 38 # key … … 35 46 36 47 Test::Nebulous->setup; 37 38 48 { 39 49 # key … … 49 59 50 60 Test::Nebulous->setup; 51 52 61 { 53 62 # key, volume … … 61 70 62 71 Test::Nebulous->setup; 63 64 72 { 65 73 # key, volume … … 73 81 74 82 Test::Nebulous->setup; 75 76 83 { 77 84 # key, volume … … 85 92 86 93 Test::Nebulous->setup; 87 88 94 { 89 95 # key … … 100 106 # object exists but instance is on a different volume 101 107 Test::Nebulous->setup; 102 103 108 eval { 104 109 # key, volume 105 110 my $uri = $neb->create_object('foo', '~node01'); 106 107 111 my $locations = $neb->find_instances('foo', '~node02'); 108 }; 109 like($@, qr/no instances on storage volume/, 'instances on a different volume'); 112 113 uri_scheme_ok($locations->[0], 'file'); 114 is($uri, $locations->[0], "URIs match"); 115 116 # print "uri: $uri\n"; 117 # print "result: $locations->[0]\n"; 118 }; 119 # die "quick check"; 120 # print "answer: $_[0]\n"; 121 # like($@, qr/no instances on storage volume/, 'instances on a different volume'); 122 123 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 1) 124 # XXX should return the INVALID instance (currently 2019.10.24 does not) 125 Test::Nebulous->setup; 126 eval { 127 # key, volume 128 my $uri = $neb->create_object('foo', '~node02'); 129 Test::Nebulous->switch_node_state; 130 131 my $locations = $neb->find_instances('foo', 'node02', 1); 132 uri_scheme_ok($locations->[0], 'file'); 133 is($uri, $locations->[0], "URIs match"); 134 }; 135 is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 136 #like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned"); 137 138 # request from a soft_volume for an instance which is on an invalid node (find_invalid = 0) 139 # XXX should return the INVALID instance (currently 2019.10.24 does not) 140 Test::Nebulous->setup; 141 eval { 142 # key, volume 143 my $uri = $neb->create_object('foo', '~node02'); 144 Test::Nebulous->switch_node_state; 145 146 my $locations = $neb->find_instances('foo', 'node02', 0); 147 }; 148 #is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 149 like($@, qr/database error/, "instance on invalid node (as soft_volume) not returned"); 150 151 #### tests with a hard_volume: 152 153 # request from a hard_volume for an instance which is on an invalid node (find_instance not supplied) 154 Test::Nebulous->setup; 155 eval { 156 # key, volume 157 my $uri = $neb->create_object('foo', '~node02'); 158 Test::Nebulous->switch_node_state; 159 160 my $locations = $neb->find_instances('foo', '~node02'); 161 }; 162 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned"); 163 164 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 1) 165 Test::Nebulous->setup; 166 eval { 167 # key, volume 168 my $uri = $neb->create_object('foo', '~node02'); 169 Test::Nebulous->switch_node_state; 170 171 my $locations = $neb->find_instances('foo', '~node02', 1); 172 uri_scheme_ok($locations->[0], 'file'); 173 is($uri, $locations->[0], "URIs match"); 174 }; 175 is($@, "", "instance on invalid node (as hard_volume) returned with find_invalid is set"); 176 #like($@, qr/database error/, "instance on invalid node (as hard_volume) not returned"); 177 178 # request from a hard_volume for an instance which is on an invalid node (find_invalid = 0) 179 Test::Nebulous->setup; 180 eval { 181 # key, volume 182 my $uri = $neb->create_object('foo', '~node02'); 183 Test::Nebulous->switch_node_state; 184 185 my $locations = $neb->find_instances('foo', '~node02', 0); 186 }; 187 like($@, qr/no instances on storage volume/, "instance on invalid node (as hard_volume) not returned"); 188 189 # request from a hard_volume for an instance which is on an invalid node 190 Test::Nebulous->setup; 191 eval { 192 # key, volume 193 my $uri = $neb->create_object('foo', '~node02'); 194 Test::Nebulous->switch_node_state; 195 196 my $locations = $neb->find_instances('foo', '~node02', 1); 197 198 uri_scheme_ok($locations->[0], 'file'); 199 is($uri, $locations->[0], "URIs match"); 200 }; 201 202 # request from a hard_volume returns an instance which is not on the hard volume if available 203 Test::Nebulous->setup; 204 eval { 205 # key, volume 206 my $uri = $neb->create_object('foo', '~node01'); 207 208 my $locations = $neb->find_instances('foo', '~node02'); 209 210 uri_scheme_ok($locations->[0], 'file'); 211 is($uri, $locations->[0], "URIs match"); 212 }; 213 214 ######## 110 215 111 216 Test::Nebulous->setup; … … 125 230 126 231 Test::Nebulous->setup; 127 128 eval { 129 $neb->find_instances();130 };131 like($@, qr/1 - 2 were expected/, "no params"); 232 eval { 233 my $locations = $neb->find_instances(); 234 }; 235 like($@, qr/1 - 3 were expected/, "no params"); 236 # note the new API expects 1-3 parameters 132 237 133 238 Test::Nebulous->setup; … … 135 240 eval { 136 241 $neb->create_object('foo'); 137 $neb->find_instances('foo', 'node01', 3); 138 }; 139 like($@, qr/1 - 2 were expected/, "too many params"); 242 $neb->find_instances('foo', 'node01', 3, 5); 243 }; 244 like($@, qr/1 - 3 were expected/, "too many params"); 245 # note the new API expects 1-3 parameters 140 246 141 247 Test::Nebulous->cleanup;
Note:
See TracChangeset
for help on using the changeset viewer.
