1 # Copyright (c) 2009, 2010 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License version 2 as published
5 # by the Free Software Foundation.
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # You should have received a copy of the GNU General Public License along
13 # with this program; if not, write to the Free Software Foundation, Inc.,
14 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
17 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
19 use Test::More tests => 31;
24 use lib "@amperldir@";
26 use Installcheck::Mock qw( setup_mock_mtx );
27 use Installcheck::Run qw( run run_get run_err );
29 my $vtape_root = "$Installcheck::TMP/mock_mtx_vtapes";
30 my $mtx_state_file = setup_mock_mtx (
39 vtape_root => $vtape_root,
46 unless(like(run_get('mock/mtx', '-f', $mtx_state_file, 'inquiry'),
47 qr/Product Type: Medium Changer/,
50 skip("mock/mtx seems broken; calling off the test early",
51 Test::More->builder->expected_tests-1);
56 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
57 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
58 Data Transfer Element 0:Empty
59 Data Transfer Element 1:Empty
60 Storage Element 1:Full :VolumeTag=023984
61 Storage Element 2:Empty
62 Storage Element 3:Full :VolumeTag=978344
63 Storage Element 4:Empty
64 Storage Element 5:Empty
65 Storage Element 6 IMPORT/EXPORT:Empty},
66 "mtx status (+BARCODES, +TRACK ORIG)");
68 like(run_err('mock/mtx', '-f', $mtx_state_file, 'load', '2', '0'),
69 qr/source Element Address 2 is Empty/,
70 "mtx load 2 0 (slot empty)");
72 like(run_err('mock/mtx', '-f', $mtx_state_file, 'unload', '5', '1'),
73 qr/Unloading Data Transfer Element into Storage Element 5...source Element Address.*/,
74 "mtx unload 5 1 (drive empty)");
76 like(run_err('mock/mtx', '-f', $mtx_state_file, 'unload', '3', '0'),
77 qr/Storage Element 3 is Already Full/,
78 "mtx unload 5 1 (slot full)");
80 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
83 ok(-d "$vtape_root/drive0/data", "fake vfs drive loaded");
85 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
86 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
87 Data Transfer Element 0:Full \(Storage Element 1 Loaded\):VolumeTag=023984
88 Data Transfer Element 1:Empty
89 Storage Element 1:Empty
90 Storage Element 2:Empty
91 Storage Element 3:Full :VolumeTag=978344
92 Storage Element 4:Empty
93 Storage Element 5:Empty
94 Storage Element 6 IMPORT/EXPORT:Empty},
95 "mtx status shows results");
97 like(run_err('mock/mtx', '-f', $mtx_state_file, 'load', '3', '0'),
98 qr/Drive 0 Full \(Storage Element 1 Loaded\)/,
99 "mtx load 3 0 (drive full)");
101 ok(run('mock/mtx', '-f', $mtx_state_file, 'unload', '2', '0'),
104 ok(! -d "$vtape_root/drive0/data", "fake vfs drive unloaded");
105 ok(-d "$vtape_root/slot2/data", "fake vfs slot re-populated");
107 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
108 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
109 Data Transfer Element 0:Empty
110 Data Transfer Element 1:Empty
111 Storage Element 1:Empty
112 Storage Element 2:Full :VolumeTag=023984
113 Storage Element 3:Full :VolumeTag=978344
114 Storage Element 4:Empty
115 Storage Element 5:Empty
116 Storage Element 6 IMPORT/EXPORT:Empty},
117 "mtx status shows results");
119 like(run_err('mock/mtx', '-f', $mtx_state_file, 'transfer', '1', '4'),
120 qr/source Element Address 1 is Empty/,
121 "mtx transfer 1 4 (source empty)");
123 like(run_err('mock/mtx', '-f', $mtx_state_file, 'transfer', '2', '3'),
124 qr/destination Element Address 3 is Already Full/,
125 "mtx transfer 1 4 (dest full)");
127 ok(run('mock/mtx', '-f', $mtx_state_file, 'transfer', '2', '4'),
130 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
131 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
132 Data Transfer Element 0:Empty
133 Data Transfer Element 1:Empty
134 Storage Element 1:Empty
135 Storage Element 2:Empty
136 Storage Element 3:Full :VolumeTag=978344
137 Storage Element 4:Full :VolumeTag=023984
138 Storage Element 5:Empty
139 Storage Element 6 IMPORT/EXPORT:Empty},
140 "mtx status shows results");
145 # Without barcodes, with track orig
147 $mtx_state_file = setup_mock_mtx (
161 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
162 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
163 Data Transfer Element 0:Empty
164 Storage Element 1:Full
165 Storage Element 2:Full
166 Storage Element 3:Full
167 Storage Element 4:Empty
168 Storage Element 5:Empty},
169 "mtx status (-BARCODES, +TRACK ORIG)");
171 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
174 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
175 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
176 Data Transfer Element 0:Full \(Storage Element 1 Loaded\)
177 Storage Element 1:Empty
178 Storage Element 2:Full
179 Storage Element 3:Full
180 Storage Element 4:Empty
181 Storage Element 5:Empty},
182 "mtx status shows results");
185 # Without barcodes, without track orig
187 $mtx_state_file = setup_mock_mtx (
201 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
202 "mtx load 1 0 (-BARCODES, -TRACK ORIG)");
204 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
205 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
206 Data Transfer Element 0:Full
207 Storage Element 1:Empty
208 Storage Element 2:Full
209 Storage Element 3:Full
210 Storage Element 4:Empty
211 Storage Element 5:Empty},
212 "mtx status shows results");
215 # With barcodes, without track orig
217 $mtx_state_file = setup_mock_mtx (
231 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '2', '1'),
232 "mtx load 2 0 (+BARCODES, -TRACK ORIG)");
234 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
235 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
236 Data Transfer Element 0:Empty
237 Data Transfer Element 1:Full :VolumeTag=023984
238 Storage Element 1:Empty
239 Storage Element 2:Empty
240 Storage Element 3:Full :VolumeTag=376524
241 Storage Element 4:Full :VolumeTag=983754
242 Storage Element 5:Empty},
243 "mtx status shows results");
245 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '4', '0'),
248 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
249 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
250 Data Transfer Element 0:Full :VolumeTag=983754
251 Data Transfer Element 1:Full :VolumeTag=023984
252 Storage Element 1:Empty
253 Storage Element 2:Empty
254 Storage Element 3:Full :VolumeTag=376524
255 Storage Element 4:Empty
256 Storage Element 5:Empty},
257 "mtx status shows results");
260 # With barcodes, with weird track orig behavior
262 $mtx_state_file = setup_mock_mtx (
276 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
277 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
278 Data Transfer Element 0:Empty
279 Data Transfer Element 1:Empty
280 Storage Element 1:Empty
281 Storage Element 2:Full :VolumeTag=023984
282 Storage Element 3:Full :VolumeTag=376524
283 Storage Element 4:Full :VolumeTag=983754
284 Storage Element 5:Empty},
285 "mtx status (+BARCODES, IMAGINED TRACK ORIG)");
287 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '2', '1'),
290 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
291 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
292 Data Transfer Element 0:Empty
293 Data Transfer Element 1:Full \(Storage Element 1 Loaded\):VolumeTag=023984
294 Storage Element 1:Empty
295 Storage Element 2:Empty
296 Storage Element 3:Full :VolumeTag=376524
297 Storage Element 4:Full :VolumeTag=983754
298 Storage Element 5:Empty},
299 "mtx status shows results");
301 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '4', '0'),
304 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
305 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
306 Data Transfer Element 0:Full \(Storage Element 1 Loaded\):VolumeTag=983754
307 Data Transfer Element 1:Full \(Storage Element 2 Loaded\):VolumeTag=023984
308 Storage Element 1:Empty
309 Storage Element 2:Empty
310 Storage Element 3:Full :VolumeTag=376524
311 Storage Element 4:Empty
312 Storage Element 5:Empty},
313 "mtx status shows results");