From: Eric Bollengier Date: Mon, 12 Nov 2007 22:23:52 +0000 (+0000) Subject: ebl Add a regress test for bweb X-Git-Tag: Release-3.0.0~2255 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0c57ad624867d8a1b27ddac8b5225409c182bf38;p=bacula%2Fbacula ebl Add a regress test for bweb git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5923 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/script/regress.pl b/gui/bweb/script/regress.pl new file mode 100755 index 0000000000..6a1150c503 --- /dev/null +++ b/gui/bweb/script/regress.pl @@ -0,0 +1,253 @@ +#!/usr/bin/perl -w +use strict; + +=head1 LICENSE + + Bweb - A Bacula web interface + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + + The main author of Bweb is Eric Bollengier. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich, + Switzerland, email:ftf@fsfeurope.org. + +=head1 USAGE + + Get it working with a regress environment: + * get regress module from SVN + * use postgresql or mysql in config + * make setup + * add catalog = all, !skipped, !saved into Messages Standard (scripts/bacula-dir.conf) + * add exit 0 to scripts/cleanup + * run bacula-backup-test + * charger bweb-(mysql|postgresql).sql + * ./bin/bacula start + * configure bweb to point to bconsole and the catalog + +=head1 VERSION + + $Id$ + +=cut + +use Test::More qw(no_plan); +use WWW::Mechanize; + +use Getopt::Long; + +my ($login, $pass, $url, $verbose); +GetOptions ("login=s" => \$login, + "passwd=s" => \$pass, + "url|u=s" => \$url, + "verbose" => \$verbose, + ); + +die "Usage: $0 --url http://.../cgi-bin/bweb/bweb.pl [-u user -p pass]" + unless ($url); + +print "Making tests on $url\n"; +my ($req, $res, $c, $cli); + +my $agent = new WWW::Mechanize(autocheck=>1); +if ($login) { + $agent->credentials($login, $pass); +} + +################################################################ +# Check bweb libraries +################################################################ + +# first, try to load all bweb libraries +require_ok('Bweb'); +require_ok('Bconsole'); +require_ok('CCircle'); + +# test first page and check for the last job +$agent->get($url); ok($agent->success, "Get main page"); $c = $agent->content; +like($c, qr!!, "Check EOP"); +ok($c =~ m!(action=job_zoom;jobid=\d+)!, "Get the first JobId"); +die "Can't get first jobid ($c)" unless $1; + +# test job_zoom page +# check for +# - job log +# - fileset +# - media view +$agent->get("$url?$1"); ok($agent->success,"Get job zoom"); $c=$agent->content; +like($c, qr!!, "Check EOP"); +like($c, qr!Using Device!, "Check for job log"); + +ok($agent->form_name('fileset_view'), "Find form"); +$agent->click(); $c=$agent->content; +ok($agent->success, "Get fileset"); +like($c, qr!!, "Check EOP"); +ok($c =~ m!
\s*(/[^>]+?)
!s,"Check fileset"); +print $1 if $verbose; +$agent->back(); ok($agent->success,"Return from fileset"); + +ok($agent->form_name("rerun"), "Find form"); +$agent->click(); $c=$agent->content; +ok($agent->success, "ReRun job"); +ok($agent->form_name("form1"), "Find form"); +ok($c =~ m!\s*