6 Bweb - A Bacula web interface
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
11 The main author of Bweb is Eric Bollengier.
12 The main author of Bacula is Kern Sibbald, with contributions from
13 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation plus additions
18 that are listed in the file LICENSE.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of Kern Sibbald.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
33 Switzerland, email:ftf@fsfeurope.org.
37 - You need to be in a X session
38 - Install Selenium IDE addon from http://seleniumhq.org/
39 - Install through CPAN WWW::Selenium
40 $ perl -e 'install WWW::Selenium' -MCPAN
41 - Download Selenium RC (remote control) from http://seleniumhq.org/
42 - unzip the archive, and start the Selenium server (require java >= 1.5)
43 $ java -jar selenium-server.jar
46 $ ./tests/bweb-test.pl
51 use Time::HiRes qw(sleep);
52 use Test::WWW::Selenium;
53 use Test::More "no_plan";
56 use scripts::functions;
58 my ($login, $pass, $url, $verbose, %part, @part, $noclean);
59 my @available = qw/client group location run missingjob media overview/;
61 GetOptions ("login=s" => \$login,
64 "module=s@" => \@part,
65 "verbose" => \$verbose,
66 "nocleanup" => \$noclean,
69 die "Usage: $0 --url http://.../cgi-bin/bweb/bweb.pl [-m module] [-n]"
73 %part = map { $_ => 1 } @part;
75 %part = map { $_ => 1 } @available;
83 my $sel = Test::WWW::Selenium->new( host => "localhost",
85 browser => "*firefox",
86 browser_url => $url );
90 $sel->open_ok("/cgi-bin/bweb/bweb.pl?");
91 $sel->wait_for_page_to_load_ok("30000");
92 $sel->is_text_present_ok("Informations");
94 $sel->click_ok("link=Clients");
95 $sel->wait_for_page_to_load_ok("30000");
97 $sel->click_ok("//input[\@name='client']"); # click the first client
98 $sel->click_ok("//button[\@name='action' and \@value='client_status']");
99 $sel->wait_for_page_to_load_ok("30000");
101 $sel->is_text_present_ok("Command output");
102 $sel->click_ok("link=Clients");
103 $sel->wait_for_page_to_load_ok("30000");
105 $sel->is_text_present_ok("Running Jobs"); # This message is in client status
110 $sel->open_ok("/cgi-bin/bweb/bweb.pl");
111 $sel->click_ok("link=Add Media");
112 $sel->wait_for_page_to_load_ok("30000");
114 $sel->select_ok("pool", "label=Scratch");
115 $sel->select_ok("storage", "label=File");
116 $sel->type_ok("nb", "10");
117 $sel->click_ok("//button[\@name='action']"); # create 10 volumes
118 $sel->wait_for_page_to_load_ok("30000");
122 if (eval { $sel->is_text_present("Select") }) { pass; last WAIT }
127 $sel->click_ok("link=All Media");
128 $sel->wait_for_page_to_load_ok("30000");
130 $sel->is_text_present_ok("Vol0001");
131 $sel->is_text_present_ok("Vol0010");
132 $sel->select_ok("mediatype", "label=File");
133 $sel->select_ok("volstatus", "label=Append");
134 $sel->select_ok("pool", "label=Scratch");
135 $sel->click_ok("//button[\@name='action']");
136 $sel->wait_for_page_to_load_ok("30000");
138 $sel->is_text_present_ok("Vol0001");
139 $sel->click_ok("media");
140 $sel->click_ok("//button[\@name='action' and \@value='update_media']");
141 $sel->wait_for_page_to_load_ok("30000");
143 $sel->select_ok("volstatus", "label=Archive");
144 $sel->select_ok("enabled", "label=no");
145 $sel->click_ok("//button[\@name='action']");
146 $sel->wait_for_page_to_load_ok("30000");
148 $sel->click_ok("arrow_0");
149 $sel->is_text_present_ok("New Volume status is: Archive");
150 $sel->click_ok("link=All Media");
151 $sel->wait_for_page_to_load_ok("30000");
153 $sel->is_text_present_ok("Archive");
154 $sel->select_ok("volstatus", "label=Append");
155 $sel->click_ok("//button[\@name='action']");
156 $sel->wait_for_page_to_load_ok("30000");
158 $sel->click_ok("media");
159 $sel->click_ok("//button[\@name='action' and \@value='media_zoom']");
160 $sel->wait_for_page_to_load_ok("30000");
162 $sel->is_text_present_ok("Volume Infos");
163 $sel->click_ok("//button[\@name='action' and \@value='purge']");
164 $sel->wait_for_page_to_load_ok("30000");
166 $sel->is_text_present_ok("Marking it purged");
169 if ($part{missingjob}) {
171 $sel->open_ok("/cgi-bin/bweb/bweb.pl");
172 $sel->click_ok("link=Missing Jobs");
173 $sel->wait_for_page_to_load_ok("30000");
175 $sel->is_text_present_ok("backup");
176 $sel->is_text_present_ok("BackupCatalog");
177 $sel->click_ok("job");
178 $sel->click_ok("//input[\@name='job' and \@value='BackupCatalog']");
179 $sel->click_ok("//button[\@name='action' and \@value='job']");
180 $sel->wait_for_page_to_load_ok("30000");
182 $sel->body_text_isnt("BackupCatalog");
187 $sel->open_ok("/cgi-bin/bweb/bweb.pl?");
188 $sel->click_ok("link=Defined Jobs");
189 $sel->wait_for_page_to_load_ok("30000");
191 $sel->select_ok("job", "label=backup");
192 $sel->is_text_present_ok("backup");
193 $sel->click_ok("//button[\@name='action' and \@value='run_job_mod']");
194 $sel->wait_for_page_to_load_ok("30000");
196 $sel->is_text_present_ok("Default");
197 $sel->is_text_present_ok("Full Set");
198 $sel->is_text_present_ok("Incremental");
199 $sel->click_ok("//button[\@name='action']");
200 $sel->wait_for_page_to_load_ok("30000");
204 if (eval { $sel->is_text_present("Start Backup JobId") }) { pass; last WAIT }
209 $sel->is_text_present_ok("Log: backup on");
210 $sel->click_ok("//button[\@name='action']");
211 $sel->wait_for_page_to_load_ok("30000");
215 if (eval { $sel->is_text_present("Termination: Backup OK") }) { pass; last WAIT }
220 my $volume = $sel->get_text("//tr[\@id='even_row']/td[12]");
221 $sel->click_ok("//button[\@name='action' and \@value='media']");
222 $sel->wait_for_page_to_load_ok("30000");
224 my $volume_found = $sel->get_text("//tr[\@id='even_row']/td[1]");
225 $sel->click_ok("media");
226 $sel->text_is("//tr[\@id='even_row']/td[5]", "Append");
227 $sel->click_ok("//button[\@name='action' and \@value='media_zoom']");
228 $sel->wait_for_page_to_load_ok("30000");
230 $sel->is_text_present_ok("Volume Infos");
231 $sel->click_ok("//img[\@title='terminated normally']");
232 $sel->wait_for_page_to_load_ok("30000");
234 $sel->click_ok("//button[\@name='action' and \@value='fileset_view']");
235 $sel->wait_for_page_to_load_ok("30000");
237 $sel->is_text_present_ok("FileSet Full Set");
238 $sel->is_text_present_ok("What is included:");
239 $sel->is_text_present_ok("/regress/build");
241 $sel->wait_for_page_to_load_ok("30000");
243 $sel->click_ok("//button[\@name='action' and \@value='run_job_mod']");
244 $sel->wait_for_page_to_load_ok("30000");
246 $sel->is_element_present_ok("level");
247 $sel->selected_value_is("name=level", "Full");
248 $sel->selected_label_is("name=fileset", "Full Set");
249 $sel->selected_label_is("name=job", "backup");
250 $sel->click_ok("//button[\@name='action' and \@value='fileset_view']");
251 $sel->wait_for_page_to_load_ok("30000");
253 $sel->is_text_present_ok("FileSet Full Set");
254 $sel->is_text_present_ok("/regress/build");
259 $sel->open_ok("/cgi-bin/bweb/bweb.pl");
260 $sel->click_ok("link=Groups");
261 $sel->wait_for_page_to_load_ok("30000");
263 $sel->text_is("//h1", "Groups");
264 $sel->click_ok("//button[\@name='action' and \@value='groups_edit']");
265 $sel->wait_for_page_to_load_ok("30000");
267 $sel->type_ok("newgroup", "All");
268 $sel->select_ok("name=client", "index=0");
269 $sel->click_ok("//button[\@name='action' and \@value='groups_save']");
270 $sel->wait_for_page_to_load_ok("30000");
272 $sel->is_text_present_ok("All");
273 $sel->click_ok("//input [\@name='client_group' and \@value='All']");
274 $sel->click_ok("//button[3]");
275 $sel->wait_for_page_to_load_ok("30000");
277 $sel->is_text_present_ok("Group: 'All'");
278 $sel->selected_index_is("name=client", "0");
279 $sel->click_ok("//button[\@name='action' and \@value='groups_save']");
280 $sel->wait_for_page_to_load_ok("30000");
282 $sel->click_ok("//input[\@name='client_group' and \@value='All']");
283 $sel->click_ok("//button[4]");
284 $sel->wait_for_page_to_load_ok("30000");
286 $sel->click_ok("//input[\@name='client']");
287 $sel->click_ok("//button[\@name='action' and \@value='client_edit']");
288 $sel->wait_for_page_to_load_ok("30000");
290 $sel->is_text_present_ok("All");
291 $sel->click_ok("link=Groups");
292 $sel->wait_for_page_to_load_ok("30000");
294 $sel->click_ok("//button[\@name='action' and \@value='groups_edit']");
295 $sel->wait_for_page_to_load_ok("30000");
297 $sel->type_ok("newgroup", "Empty");
298 $sel->click_ok("//button[\@name='action']");
299 $sel->wait_for_page_to_load_ok("30000");
301 $sel->click_ok("client_group");
302 $sel->is_text_present_ok("Empty");
303 $sel->click_ok("//button[\@name='action' and \@value='client']");
304 $sel->wait_for_page_to_load_ok("30000");
306 $sel->click_ok("//input[\@name='client']");
307 $sel->click_ok("//button[\@name='action' and \@value='client_edit']");
308 $sel->wait_for_page_to_load_ok("30000");
310 $sel->click_ok("link=Groups");
311 $sel->wait_for_page_to_load_ok("30000");
313 $sel->click_ok("//input[\@name='client_group' and \@value='Empty']");
314 $sel->click_ok("//button[\@name='action' and \@value='groups_del']");
315 ok($sel->get_confirmation() =~ /^Do you want to delete this group[\s\S]$/);
316 $sel->click_ok("link=Groups");
317 $sel->wait_for_page_to_load_ok("30000");
319 $sel->click_ok("//button[\@name='action']");
320 $sel->wait_for_page_to_load_ok("30000");
322 $sel->type_ok("newgroup", "Empty");
323 $sel->click_ok("//button[\@name='action']");
324 $sel->wait_for_page_to_load_ok("30000");
326 $sel->is_text_present_ok("Empty");
327 $sel->click_ok("//input[\@name='client_group' and \@value='All']");
328 $sel->click_ok("//button[\@name='action' and \@value='client']");
329 $sel->wait_for_page_to_load_ok("30000");
331 $sel->click_ok("//input[\@name='client']");
332 $sel->click_ok("//button[\@name='action' and \@value='client_edit']");
333 $sel->wait_for_page_to_load_ok("30000");
335 ok(not $sel->is_checked("//input[\@name='client_group' and \@value='Empty']"));
336 $sel->click_ok("link=Group Statistics");
337 $sel->wait_for_page_to_load_ok("30000");
339 $sel->is_text_present_ok("All");
340 $sel->is_text_present_ok("Empty");
341 $sel->click_ok("link=Groups");
342 $sel->wait_for_page_to_load_ok("30000");
344 $sel->click_ok("//input[\@name='client_group' and \@value='Empty']");
345 $sel->click_ok("document.forms[1].elements[4]");
346 $sel->wait_for_page_to_load_ok("30000");
348 $sel->type_ok("newgroup", "EmptyGroup");
349 $sel->click_ok("//button[\@name='action']");
350 $sel->wait_for_page_to_load_ok("30000");
352 $sel->is_text_present_ok("EmptyGroup");
355 if ($part{location}) {
357 $sel->open_ok("/cgi-bin/bweb/bweb.pl");
358 $sel->click_ok("link=Locations");
359 $sel->wait_for_page_to_load_ok("30000");
361 $sel->click_ok("//button[\@name='action' and \@value='location_add']");
362 $sel->wait_for_page_to_load_ok("30000");
364 $sel->type_ok("location", "Bank");
365 $sel->click_ok("//button[\@name='action']"); # save
366 $sel->wait_for_page_to_load_ok("30000");
368 $sel->is_text_present_ok("Bank");
369 $sel->click_ok("location");
370 $sel->click_ok("//button[\@name='action' and \@value='location_edit']");
371 $sel->wait_for_page_to_load_ok("30000");
373 $sel->type_ok("cost", "100");
374 $sel->is_text_present_ok("Location: Bank");
375 $sel->click_ok("//button[\@name='action']");
376 $sel->wait_for_page_to_load_ok("30000");
378 $sel->is_text_present_ok("100");
379 $sel->is_element_present_ok("//img[\@src='/bweb/inflag1.png']");
380 $sel->click_ok("location");
381 $sel->click_ok("//button[\@name='action' and \@value='location_edit']");
382 $sel->wait_for_page_to_load_ok("30000");
384 $sel->select_ok("enabled", "label=no");
385 $sel->click_ok("//button[\@name='action']");
386 $sel->wait_for_page_to_load_ok("30000");
388 $sel->is_element_present_ok("//img[\@src='/bweb/inflag0.png']");
389 $sel->click_ok("location");
390 $sel->click_ok("//button[\@name='action' and \@value='location_edit']");
391 $sel->wait_for_page_to_load_ok("30000");
393 $sel->select_ok("enabled", "label=archived");
394 $sel->click_ok("//button[\@name='action']");
395 $sel->wait_for_page_to_load_ok("30000");
397 $sel->is_element_present_ok("//img[\@src='/bweb/inflag2.png']");
398 $sel->click_ok("location");
399 $sel->click_ok("//button[\@name='action' and \@value='location_edit']");
400 $sel->wait_for_page_to_load_ok("30000");
402 $sel->type_ok("newlocation", "Office");
403 $sel->click_ok("//button[\@name='action']");
404 $sel->wait_for_page_to_load_ok("30000");
406 $sel->is_text_present_ok("Office");
407 $sel->click_ok("link=All Media");
408 $sel->wait_for_page_to_load_ok("30000");
410 $sel->click_ok("media");
411 $sel->click_ok("//button[\@name='action' and \@value='update_media']");
412 $sel->wait_for_page_to_load_ok("30000");
414 $sel->select_ok("location", "label=Office");
415 $sel->click_ok("//button[\@name='action']");
416 $sel->wait_for_page_to_load_ok("30000");
418 $sel->selected_value_is("location", "Office");
419 $sel->click_ok("//button[\@name='action' and \@value='media']");
420 $sel->wait_for_page_to_load_ok("30000");
422 $sel->select_ok("location", "label=Office");
423 $sel->click_ok("//button[\@name='action']");
424 $sel->wait_for_page_to_load_ok("30000");
426 $sel->body_text_isnt("Vol0010");
427 $sel->click_ok("link=Locations");
428 $sel->wait_for_page_to_load_ok("30000");
430 $sel->click_ok("location");
431 $sel->click_ok("//button[\@name='action' and \@value='location_del']");
432 ok($sel->get_confirmation() =~ /^Do you want to remove this location[\s\S]$/);
433 $sel->wait_for_page_to_load_ok("30000");
435 $sel->is_text_present_ok("Sorry, the location must be empty");
436 $sel->click_ok("link=Locations");
437 $sel->wait_for_page_to_load_ok("30000");
439 $sel->click_ok("//button[\@name='action']");
440 $sel->wait_for_page_to_load_ok("30000");
442 $sel->type_ok("location", "OtherPlace");
443 $sel->click_ok("//button[\@name='action']");
444 $sel->wait_for_page_to_load_ok("30000");
446 $sel->click_ok("location");
447 $sel->click_ok("//button[\@name='action' and \@value='media']");
448 $sel->wait_for_page_to_load_ok("30000");
450 $sel->click_ok("media");
451 $sel->click_ok("//button[\@name='action' and \@value='update_media']");
452 $sel->wait_for_page_to_load_ok("30000");
454 $sel->select_ok("location", "label=OtherPlace");
455 $sel->click_ok("//button[\@name='action']");
456 $sel->wait_for_page_to_load_ok("30000");
458 $sel->click_ok("link=Locations");
459 $sel->wait_for_page_to_load_ok("30000");
461 $sel->click_ok("location");
462 $sel->click_ok("//button[\@name='action' and \@value='location_del']");
463 ok($sel->get_confirmation() =~ /^Do you want to remove this location[\s\S]$/);
464 $sel->wait_for_page_to_load_ok("30000");
466 $sel->body_text_isnt("Office");
469 if ($part{overview}) {
470 $sel->open_ok("/cgi-bin/bweb/bweb.pl");
471 $sel->click_ok("link=Jobs overview");
472 $sel->wait_for_page_to_load_ok("30000");
474 $sel->is_text_present_ok("All");
475 $sel->click_ok("link=All");
476 $sel->wait_for_page_to_load_ok("30000");
478 $sel->click_ok("link=zogi-fd");
479 $sel->wait_for_page_to_load_ok("30000");
481 $sel->is_text_present_ok("backup");
482 $sel->is_text_present_ok("Full Set");