1 # Copyright (c) 2009-2012 Zmanda, Inc. All Rights Reserved.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 use Test::More tests => 31;
25 use lib "@amperldir@";
27 use Installcheck::Mock qw( setup_mock_mtx );
28 use Installcheck::Run qw( run run_get run_err );
30 my $vtape_root = "$Installcheck::TMP/mock_mtx_vtapes";
31 my $mtx_state_file = setup_mock_mtx (
40 vtape_root => $vtape_root,
47 unless(like(run_get('mock/mtx', '-f', $mtx_state_file, 'inquiry'),
48 qr/Product Type: Medium Changer/,
51 skip("mock/mtx seems broken; calling off the test early",
52 Test::More->builder->expected_tests-1);
57 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
58 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
59 Data Transfer Element 0:Empty
60 Data Transfer Element 1:Empty
61 Storage Element 1:Full :VolumeTag=023984
62 Storage Element 2:Empty
63 Storage Element 3:Full :VolumeTag=978344
64 Storage Element 4:Empty
65 Storage Element 5:Empty
66 Storage Element 6 IMPORT/EXPORT:Empty},
67 "mtx status (+BARCODES, +TRACK ORIG)");
69 like(run_err('mock/mtx', '-f', $mtx_state_file, 'load', '2', '0'),
70 qr/source Element Address 2 is Empty/,
71 "mtx load 2 0 (slot empty)");
73 like(run_err('mock/mtx', '-f', $mtx_state_file, 'unload', '5', '1'),
74 qr/Unloading Data Transfer Element into Storage Element 5...source Element Address.*/,
75 "mtx unload 5 1 (drive empty)");
77 like(run_err('mock/mtx', '-f', $mtx_state_file, 'unload', '3', '0'),
78 qr/Storage Element 3 is Already Full/,
79 "mtx unload 5 1 (slot full)");
81 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
84 ok(-d "$vtape_root/drive0/data", "fake vfs drive loaded");
86 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
87 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
88 Data Transfer Element 0:Full \(Storage Element 1 Loaded\):VolumeTag=023984
89 Data Transfer Element 1:Empty
90 Storage Element 1:Empty
91 Storage Element 2:Empty
92 Storage Element 3:Full :VolumeTag=978344
93 Storage Element 4:Empty
94 Storage Element 5:Empty
95 Storage Element 6 IMPORT/EXPORT:Empty},
96 "mtx status shows results");
98 like(run_err('mock/mtx', '-f', $mtx_state_file, 'load', '3', '0'),
99 qr/Drive 0 Full \(Storage Element 1 Loaded\)/,
100 "mtx load 3 0 (drive full)");
102 ok(run('mock/mtx', '-f', $mtx_state_file, 'unload', '2', '0'),
105 ok(! -d "$vtape_root/drive0/data", "fake vfs drive unloaded");
106 ok(-d "$vtape_root/slot2/data", "fake vfs slot re-populated");
108 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
109 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
110 Data Transfer Element 0:Empty
111 Data Transfer Element 1:Empty
112 Storage Element 1:Empty
113 Storage Element 2:Full :VolumeTag=023984
114 Storage Element 3:Full :VolumeTag=978344
115 Storage Element 4:Empty
116 Storage Element 5:Empty
117 Storage Element 6 IMPORT/EXPORT:Empty},
118 "mtx status shows results");
120 like(run_err('mock/mtx', '-f', $mtx_state_file, 'transfer', '1', '4'),
121 qr/source Element Address 1 is Empty/,
122 "mtx transfer 1 4 (source empty)");
124 like(run_err('mock/mtx', '-f', $mtx_state_file, 'transfer', '2', '3'),
125 qr/destination Element Address 3 is Already Full/,
126 "mtx transfer 1 4 (dest full)");
128 ok(run('mock/mtx', '-f', $mtx_state_file, 'transfer', '2', '4'),
131 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
132 qr{ Storage Changer .*:2 Drives, 6 Slots \( 1 Import/Export \)
133 Data Transfer Element 0:Empty
134 Data Transfer Element 1:Empty
135 Storage Element 1:Empty
136 Storage Element 2:Empty
137 Storage Element 3:Full :VolumeTag=978344
138 Storage Element 4:Full :VolumeTag=023984
139 Storage Element 5:Empty
140 Storage Element 6 IMPORT/EXPORT:Empty},
141 "mtx status shows results");
146 # Without barcodes, with track orig
148 $mtx_state_file = setup_mock_mtx (
162 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
163 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
164 Data Transfer Element 0:Empty
165 Storage Element 1:Full
166 Storage Element 2:Full
167 Storage Element 3:Full
168 Storage Element 4:Empty
169 Storage Element 5:Empty},
170 "mtx status (-BARCODES, +TRACK ORIG)");
172 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
175 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
176 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
177 Data Transfer Element 0:Full \(Storage Element 1 Loaded\)
178 Storage Element 1:Empty
179 Storage Element 2:Full
180 Storage Element 3:Full
181 Storage Element 4:Empty
182 Storage Element 5:Empty},
183 "mtx status shows results");
186 # Without barcodes, without track orig
188 $mtx_state_file = setup_mock_mtx (
202 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '1', '0'),
203 "mtx load 1 0 (-BARCODES, -TRACK ORIG)");
205 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
206 qr{ Storage Changer .*:1 Drives, 5 Slots \( 0 Import/Export \)
207 Data Transfer Element 0:Full
208 Storage Element 1:Empty
209 Storage Element 2:Full
210 Storage Element 3:Full
211 Storage Element 4:Empty
212 Storage Element 5:Empty},
213 "mtx status shows results");
216 # With barcodes, without track orig
218 $mtx_state_file = setup_mock_mtx (
232 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '2', '1'),
233 "mtx load 2 0 (+BARCODES, -TRACK ORIG)");
235 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
236 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
237 Data Transfer Element 0:Empty
238 Data Transfer Element 1:Full :VolumeTag=023984
239 Storage Element 1:Empty
240 Storage Element 2:Empty
241 Storage Element 3:Full :VolumeTag=376524
242 Storage Element 4:Full :VolumeTag=983754
243 Storage Element 5:Empty},
244 "mtx status shows results");
246 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '4', '0'),
249 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
250 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
251 Data Transfer Element 0:Full :VolumeTag=983754
252 Data Transfer Element 1:Full :VolumeTag=023984
253 Storage Element 1:Empty
254 Storage Element 2:Empty
255 Storage Element 3:Full :VolumeTag=376524
256 Storage Element 4:Empty
257 Storage Element 5:Empty},
258 "mtx status shows results");
261 # With barcodes, with weird track orig behavior
263 $mtx_state_file = setup_mock_mtx (
277 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
278 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
279 Data Transfer Element 0:Empty
280 Data Transfer Element 1:Empty
281 Storage Element 1:Empty
282 Storage Element 2:Full :VolumeTag=023984
283 Storage Element 3:Full :VolumeTag=376524
284 Storage Element 4:Full :VolumeTag=983754
285 Storage Element 5:Empty},
286 "mtx status (+BARCODES, IMAGINED TRACK ORIG)");
288 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '2', '1'),
291 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
292 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
293 Data Transfer Element 0:Empty
294 Data Transfer Element 1:Full \(Storage Element 1 Loaded\):VolumeTag=023984
295 Storage Element 1:Empty
296 Storage Element 2:Empty
297 Storage Element 3:Full :VolumeTag=376524
298 Storage Element 4:Full :VolumeTag=983754
299 Storage Element 5:Empty},
300 "mtx status shows results");
302 ok(run('mock/mtx', '-f', $mtx_state_file, 'load', '4', '0'),
305 like(run_get('mock/mtx', '-f', $mtx_state_file, 'status'),
306 qr{ Storage Changer .*:2 Drives, 5 Slots \( 0 Import/Export \)
307 Data Transfer Element 0:Full \(Storage Element 1 Loaded\):VolumeTag=983754
308 Data Transfer Element 1:Full \(Storage Element 2 Loaded\):VolumeTag=023984
309 Storage Element 1:Empty
310 Storage Element 2:Empty
311 Storage Element 3:Full :VolumeTag=376524
312 Storage Element 4:Empty
313 Storage Element 5:Empty},
314 "mtx status shows results");