6 Bweb - A Bacula web interface
7 Bacula® - The Network Backup Solution
9 Copyright (C) 2000-2006 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.
14 This program is Free Software; you can redistribute it and/or
15 modify it under the terms of version three of the GNU Affero General Public
16 License as published by the Free Software Foundation and included
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Affero General Public License for more details.
24 You should have received a copy of the GNU Affero General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 Bacula® is a registered trademark of Kern Sibbald.
30 The licensor of Bacula is the Free Software Foundation Europe
31 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
32 Switzerland, email:ftf@fsfeurope.org.
36 Get it working with a regress environment:
37 * get regress module from SVN
38 * use postgresql or mysql in config
40 * add catalog = all, !skipped, !saved into Messages Standard (scripts/bacula-dir.conf)
41 * add exit 0 to scripts/cleanup
42 * run bacula-backup-test
43 * uncomment job schedule in bacula-dir.conf
44 * load bweb-(mysql|postgresql).sql
46 * configure bweb to point to bconsole and the catalog
54 use Test::More qw(no_plan);
59 my ($login, $pass, $url, $verbose);
60 GetOptions ("login=s" => \$login,
63 "verbose" => \$verbose,
66 die "Usage: $0 --url http://.../cgi-bin/bweb/bweb.pl [-l user -p pass]"
69 print "Making tests on $url\n";
70 my ($req, $res, $c, $cli, $job_url);
72 my $agent = new WWW::Mechanize(autocheck=>1);
74 $agent->credentials($login, $pass);
77 ################################################################
78 # Check bweb libraries
79 ################################################################
81 # first, try to load all bweb libraries
83 require_ok('Bconsole');
84 require_ok('CCircle');
85 require_ok('GBalloon');
88 # test first page and check for the last job
89 $agent->get($url); ok($agent->success, "Get main page"); $c = $agent->content;
90 like($c, qr!</html>!, "Check EOP");
91 ok($c =~ m!(action=job_zoom;jobid=\d+)!, "Get the first JobId");
92 die "Can't get first jobid ($c)" unless $1;
96 ok($agent->follow_link(text_regex=>qr/Missing Jobs/), "Go to Missing Jobs page");
98 like($c, qr/BackupCatalog/, "Check for BackupCatalog job");
99 unlike($c, qr/backup/, "Check for backup job");
106 $agent->get("$url?$job_url");
107 ok($agent->success,"Get job zoom"); $c=$agent->content;
108 like($c, qr!</html>!, "Check EOP");
109 like($c, qr!Using Device!, "Check for job log");
111 ok($agent->form_name('fileset_view'), "Find form");
112 $agent->click(); $c=$agent->content;
113 ok($agent->success, "Get fileset");
114 like($c, qr!</html>!, "Check EOP");
115 ok($c =~ m!<pre>\s*(/[^>]+?)</pre>!s,"Check fileset");
116 print $1 if $verbose;
117 $agent->back(); ok($agent->success,"Return from fileset");
119 ok($agent->form_name("rerun"), "Find form");
120 $agent->click(); $c=$agent->content;
121 ok($agent->success, "ReRun job");
122 ok($agent->form_name("form1"), "Find form");
123 ok($c =~ m!<select name='job'>\s*<option value='(.+?)'!,"jobs");
124 ok($agent->field('job', $1), "set field job=1");
125 ok($c =~ m!<select name='client'>\s*<option value='(.+?)'!, "clients");
126 ok($agent->field('client', $1), "set field client=$1");
127 ok($c =~ m!<select name='storage'>\s*<option value='(.+?)'!, "storages");
128 ok($agent->field('storage', $1), "set field storage=$1");
129 ok($c =~ m!<select name='fileset'>\s*<option value='(.+?)'!, "filesets");
130 ok($agent->field('fileset', $1), "set field fileset=1");
131 ok($c =~ m!<select name='pool'>\s*<option value=''></option>\s*<option value='(.+?)'!, "pools");
132 $agent->field('pool', $1);
133 $agent->click_button(value => 'run_job_now');
134 ok($agent->success(), "submit");
136 ok($agent->follow_link(text_regex=>qr/here/i), "follow link");
137 ok($agent->success(), "get job page"); $c=$agent->content;
138 like($c, qr/Using Device/, "Check job log");
140 # try to delete this job
141 $agent->get("$url?$job_url");
142 ok($agent->success,"Get job zoom");
143 ok($agent->form_name('delete'), "Find form");
144 $agent->click(); $c=$agent->content;
145 ok($agent->success, "Delete it");
146 like($c, qr!deleted from the catalog!, "Check deleted message");
148 $agent->get("$url?$job_url");
149 ok($agent->success,"Get job zoom");
151 like($c, qr!An error has occurred!, "Check deleted job");
154 ok($agent->follow_link(text_regex=>qr/Defined Jobs/), "Go to Defined Jobs page");
156 like($c, qr/BackupCatalog/, "Check for BackupCatalog job");
158 ################################################################
160 ################################################################
162 ok($agent->follow_link(text_regex=>qr/Clients/), "Go to Clients page");
164 ok($c =~ m!chkbox.value = '(.+?)';!, "get client name");
167 $agent->get("$url?action=client_status;client=$cli");
168 ok($agent->success(), "submit"); $c=$agent->content;
169 like($c, qr/Terminated Jobs/, "check for client status");
171 $agent->get("$url?action=job;client=$cli");
172 ok($agent->success(), "submit"); $c=$agent->content;
173 like($c, qr/'$cli'\).selected = true;/, "list jobs for this client");
175 ################################################################
176 # Test location basic functions
177 ################################################################
180 ok($agent->follow_link(text_regex=>qr/Location/), "Go to Location page");
181 ok($agent->form_number(2), "Find form");
182 $agent->click_button(value => 'location_add');
183 ok($agent->success(), "submit");
184 ok($agent->form_number(2), "Find form");
185 $agent->field("location", $loc);
186 ok($agent->field("cost", 20), "set field cost=20");
187 ok($agent->field("enabled", "yes"), "set field enabled=yes");
188 ok($agent->field("enabled", "no"), "try set field enabled=no");
189 ok($agent->field("enabled", "archived"), "try set field enabled=archived");
190 $agent->click_button(value => 'location_add');
191 ok($agent->success(), "submit"); $c=$agent->content;
192 like($c, qr/$loc/, "Check if location is ok");
193 like($c, qr/inflag2.png/, "Check if enabled is archived");
195 $agent->get("$url?location=$loc&action=location_edit");
196 ok($agent->success(), "Try to edit location"); $c=$agent->content;
197 like($c, qr/$loc/, "Check for location");
198 ok($agent->form_number(2), "Find form");
199 $agent->field("cost", 40);
200 $agent->field("enabled", "no");
202 $agent->field("newlocation", $loc);
203 $agent->click_button(value => 'location_save');
204 ok($agent->success(), "submit to edit location"); $c=$agent->content;
205 like($c, qr/$loc/, "Check if location is ok");
206 like($c, qr/inflag0.png/, "Check if enabled is 'no'");
207 like($c, qr/40/, "Check for cost");
209 ################################################################
211 ################################################################
213 ok($agent->follow_link(text_regex=>qr/All Media/), "Go to All Media page");
214 ok($agent->success(), "submit"); $c=$agent->content;
215 ok($c =~ m/chkbox.value = '(.+?)'/, "get first media");
218 $agent->get("$url?media=$vol;action=update_media");
219 ok($agent->success(), "submit"); $c=$agent->content;
220 like($c, qr/$vol/, "Check if volume is ok");
222 ################################################################
223 # Test group basic functions
224 ################################################################
226 $agent->get("$url?action=client;notingroup=yes");
227 ok($agent->success(), "submit"); $c=$agent->content;
228 like($c, qr/$cli/, "check client=$cli is groupless");
232 ok($agent->follow_link(text_regex=>qr/Groups/), "Go to Groups page");
233 ok($agent->success(), "submit"); $c=$agent->content;
234 unlike($c, qr/error/i, "Check for group installation");
235 ok($agent->form_number(2), "Find form");
236 $agent->click_button(value => 'groups_edit');
237 ok($agent->success(), "submit action=groups_edit");
238 ok($agent->form_number(2), "Find form to create a group");
239 $agent->field("newgroup", $grp);
240 $agent->click_button(value => 'groups_save');
241 ok($agent->success(), "submit action=groups_save");
243 like($c, qr/$grp/, "Check if group have been created");
245 # rename group (client is loss because it was set by javascript)
246 $agent->get("$url?client_group=$grp;action=groups_edit");
247 ok($agent->success(), "submit action=groups_edit"); $c=$agent->content;
248 like($c, qr/$grp/, "Check if group is present to rename it");
249 ok($agent->form_number(2), "Find form");
251 $agent->field("newgroup", $grp);
252 $agent->field("client", $cli);
253 $agent->click_button(value => 'groups_save');
254 ok($agent->success(), "submit"); $c=$agent->content;
255 like($c, qr/'$grp'/, "Check if newgroup is present");
257 # check if group is ok
258 $agent->get("$url?client_group=$grp;action=client");
259 ok($agent->success(), "submit"); $c=$agent->content;
260 like($c, qr/'$cli'/, "Check if client is present in newgrp");
262 $agent->get("$url?action=client;notingroup=yes");
263 ok($agent->success(), "check if client=$cli is already 'not in group'");
265 unlike($c, qr/$cli/, "check client=$cli");
267 $agent->get("$url?client_group=other$grp;action=groups_edit");
268 ok($agent->success(), "create an empty other$grp"); $c=$agent->content;
269 like($c, qr/'other$grp'/, "check if other$grp was created");
272 ok($agent->follow_link(text_regex=>qr/Jobs by group/), "Go to Job by group page");
273 ok($agent->success(), "Get it"); $c=$agent->content;
274 like($c, qr/"$grp"/, "check if $grp is here");
277 ok($agent->follow_link(text_regex=>qr/Jobs overview/), "Go to Job overview");
278 ok($agent->success(), "Get it"); $c=$agent->content;
279 like($c, qr/"$grp"/, "check if $grp is here");
282 ok($agent->follow_link(url_regex=>qr/action=group_stats/), "Go to groups stats");
283 ok($agent->success(), "Get it"); $c=$agent->content;
284 like($c, qr/"$grp"/, "check if $grp is here");
287 ok($agent->follow_link(text_regex=>qr/Next Jobs/), "Go to Next jobs");
288 ok($agent->success(), "Get it"); $c=$agent->content;
289 like($c, qr/'BackupCatalog'/, "check if BackupCatalog is here");
292 ok($agent->follow_link(text_regex=>qr/Add Media/), "Go to Add Media");
293 ok($agent->success(), "Get it");
294 ok($agent->form_number(2), "Find form");
295 $agent->field('pool', 'Scratch');
296 $agent->field('storage', 'File');
297 $agent->field('nb', '3');
298 $agent->field('offset', '1');
299 $agent->field('media', "Vol$$");
300 $agent->click_button(value => 'add_media');
301 ok($agent->success(), "Create them"); $c=$agent->content;
302 like($c, qr/Vol${$}0001/, "Check if media are there");
305 ok($agent->follow_link(text_regex=>qr/Pools/), "Go to Pool");
306 ok($agent->success(), "Get it"); $c=$agent->content;
307 like($c, qr/"Default"/, "check if Default pool is here");
308 like($c, qr/"Scratch"/, "check if Scratch pool is here");
310 ################################################################
311 # other checks and cleanup
312 ################################################################
315 $agent->get("$url?client_group=$grp;action=groups_del");
316 ok($agent->success(), "submit"); $c=$agent->content;
317 unlike($c, qr/'$grp'/, "Check if group was deleted");
319 $agent->get("$url?client_group=other$grp;action=groups_del");
320 ok($agent->success(), "submit"); $c=$agent->content;
321 unlike($c, qr/'other$grp'/, "Check if group was deleted");
324 $agent->get("$url?location=$loc;action=location_del");
325 ok($agent->success(), "submit"); $c=$agent->content;
326 unlike($c, qr/$loc/, "Check if location was deleted");