- change tests references to testcases
- fix changed field abbreviations
- disabled testgroup/subgroup editing -> interim step before test runs
- display lists of all testgroups/subgroups to which a testcase belongs when viewing a testcase
- updated database schema
- updated database population script.
- NOTE: due to changes in the underlying db structure, it will be necessary for users to establish new linkages between products, platforms, testgroup, subgroups, and testcases (documented in populatedb.sql)
- when running tests, ony display testgroups that match the chosen branch

b=322585
- fix defaulttestgroup display when continuing to test

b=334871
- allow fulltext searching of testcases by summary, steps, and expected results
This commit is contained in:
ccooper%deadsquid.com 2006-06-05 04:07:29 +00:00
parent 681b024298
commit 7d6c5dc95e
11 changed files with 424 additions and 263 deletions

View File

@ -203,7 +203,7 @@ if ($c->param) {
my $products = Litmus::FormWidget->getProducts; my $products = Litmus::FormWidget->getProducts;
my $platforms = Litmus::FormWidget->getUniquePlatforms; my $platforms = Litmus::FormWidget->getUniquePlatforms;
my $test_groups = Litmus::FormWidget->getTestGroups; my $test_groups = Litmus::FormWidget->getTestGroups;
my $test_ids = Litmus::FormWidget->getTestIDs; my $testcases = Litmus::FormWidget->getTestcaseIDs;
my $result_statuses = Litmus::FormWidget->getResultStatuses; my $result_statuses = Litmus::FormWidget->getResultStatuses;
my $branches = Litmus::FormWidget->getBranches; my $branches = Litmus::FormWidget->getBranches;
my $locales = Litmus::FormWidget->getLocales; my $locales = Litmus::FormWidget->getLocales;
@ -221,7 +221,7 @@ my $vars = {
products => $products, products => $products,
platforms => $platforms, platforms => $platforms,
test_groups => $test_groups, test_groups => $test_groups,
test_ids => $test_ids, testcases => $testcases,
result_statuses => $result_statuses, result_statuses => $result_statuses,
branches => $branches, branches => $branches,
locales => $locales, locales => $locales,

View File

@ -127,9 +127,11 @@ if ($reset_db) {
} }
# UPGRADE THE SCHEMA # UPGRADE THE SCHEMA
# Now we need to deal with upgrading old installations by adding new fields and # Now we need to deal with upgrading old installations by adding new fields
# indicies to the schema. To do this, we use the helpful Litmus::DBTools module # and indicies to the schema. To do this, we use the helpful Litmus::DBTools
# Note that anything changed here should also be added to schema.pl for new # module.
#
# NOTE: anything changed here should also be added to schema.pl for new
# installations # installations
use Litmus::DBTools; use Litmus::DBTools;
my $dbtool = Litmus::DBTools->new($dbh); my $dbtool = Litmus::DBTools->new($dbh);
@ -141,6 +143,8 @@ $dbtool->AddField("users", "password", "varchar(255)");
$dbtool->AddField("users", "realname", "varchar(255)"); $dbtool->AddField("users", "realname", "varchar(255)");
$dbtool->AddField("users", "is_admin", "tinyint(1) default '0'"); $dbtool->AddField("users", "is_admin", "tinyint(1) default '0'");
$dbtool->AddField("users", "irc_nickname", "varchar(32)"); $dbtool->AddField("users", "irc_nickname", "varchar(32)");
$dbtool->DropIndex("users", "email");
$dbtool->DropIndex("users", "irc_nickname");
$dbtool->AddUniqueKey("users","email","(email)"); $dbtool->AddUniqueKey("users","email","(email)");
$dbtool->AddUniqueKey("users","irc_nickname","(irc_nickname)"); $dbtool->AddUniqueKey("users","irc_nickname","(irc_nickname)");
$dbtool->AddKey("users","bugzilla_uid","(bugzilla_uid)"); $dbtool->AddKey("users","bugzilla_uid","(bugzilla_uid)");
@ -171,22 +175,71 @@ $dbtool->DropField("test_results", "vetting_status_id");
$dbtool->DropTable("validity_lookup"); $dbtool->DropTable("validity_lookup");
$dbtool->DropTable("vetting_status_lookup"); $dbtool->DropTable("vetting_status_lookup");
$dbtool->AddField("test_groups", "enabled", "tinyint(1) default '1'"); $dbtool->RenameTable("test_groups","testgroups");
$dbtool->AddKey("test_groups","enabled","(enabled)"); $dbtool->AddField("testgroups", "enabled", "tinyint(1) NO NULL default '1'");
$dbtool->AddField("subgroups", "enabled", "tinyint(1) default '1'"); $dbtool->AddKey("testgroups","enabled","(enabled)");
$dbtool->AddKey("subgroups","enabled","(enabled)"); $dbtool->DropField("testgroups", "obsolete");
$dbtool->DropField("test_groups", "obsolete"); $dbtool->DropField("testgroups", "expiration_days");
$dbtool->AddField("users", "enabled", "tinyint(1) default '1'"); $dbtool->AddField("subgroups", "enabled", "tinyint(1) NOT NULL default '1'");
$dbtool->AddKey("subgroups","enabled","(enabled)");
$dbtool->AddField("subgroups", "product_id", "tinyint(4) NOT NULL");
$dbtool->AddKey("subgroups","product_id","(product_id)");
$dbtool->DropField("subgroups", "testgroup_id");
$dbtool->AddField("users", "enabled", "tinyint(1) NOT NULL default '1'");
$dbtool->AddKey("users","enabled","(enabled)"); $dbtool->AddKey("users","enabled","(enabled)");
$dbtool->DropField("users", "disabled"); $dbtool->DropField("users", "disabled");
# Remove reference to test_status_lookup
$dbtool->AddField("tests", "enabled", "tinyint(1) NOT NULL default '1'");
$dbtool->AddKey("tests","enabled","(enabled)");
$dbtool->DropField("tests", "status_id");
$dbtool->DropTable("test_status_lookup"); $dbtool->DropTable("test_status_lookup");
# Remove reference to test_status_lookup
$dbtool->RenameTable("tests","testcases");
$dbtool->AddField("testcases", "enabled", "tinyint(1) NOT NULL default '1'");
$dbtool->AddKey("testcases","enabled","(enabled)");
$dbtool->DropIndex("testcases", "test_id");
$dbtool->RenameField("testcases", "test_id", "testcase_id");
$dbtool->AddKey("testcases","testcase_id","(testcase_id)");
$dbtool->AddKey("testcases","summary_2","(summary, steps, expected_results)");
$dbtool->ChangeFieldType("testcases", "community_enabled", 'tinyint(1) default "1"');
$dbtool->AddField("testcases", "product_id", "tinyint(4) NOT NULL");
$dbtool->AddKey("testcases","product_id","(product_id)");
$dbtool->DropField("testcases", "subgroup_id");
$dbtool->DropIndex("test_results", "test_id");
$dbtool->RenameField("test_results", "test_id", "testcase_id");
$dbtool->AddKey("test_results","testcase_id","(testcase_id)");
$dbtool->RenameField("test_results", "buildid", "build_id");
$dbtool->ChangeFieldType("test_results", "build_id", 'int(10) unsigned');
$dbtool->AddKey("test_results","build_id","(build_id)");
$dbtool->DropIndex("test_results", "result_id");
$dbtool->RenameField("test_results", "result_id", "result_status_id");
$dbtool->AddKey("test_results","result_status_id","(result_status_id)");
$dbtool->DropField("test_results", "platform_id");
$dbtool->AddField("branches", "enabled", "tinyint(1) NOT NULL default '1'");
$dbtool->AddKey("branches","enabled","(enabled)");
$dbtool->DropField("platforms", "product_id");
print "Schema update complete.\n\n";
print <<EOS;
Due to the schema changes introduced, and depending on the when you last
updated your schema, you may now need to update/normalize your data as
well. This will include, but may not be limited to:
* populating the platform_products table;
* updating/normalizing platforms;
* updating/normalizing platform_ids in test_results;
* updating/normalizing opsyses;
* updating/normalizing opsys_ids in test_results;
* populating the subgroup_testgroups table;
* populating the testcase_subgroups table;
* filling in product_ids for each testcase/subgroup;
* populating the testgroup_branches table
EOS
# javascript cache # javascript cache
print "Rebuilding JS cache..."; print "Rebuilding JS cache...";
require Litmus::Cache; require Litmus::Cache;

View File

@ -82,7 +82,7 @@ foreach my $curtestid (@tests) {
next; next;
} }
my $curtest = Litmus::DB::Test->retrieve($curtestid); my $curtest = Litmus::DB::Testcase->retrieve($curtestid);
unless ($curtest) { unless ($curtest) {
# oddly enough, the test doesn't exist # oddly enough, the test doesn't exist
next; next;
@ -101,7 +101,7 @@ foreach my $curtestid (@tests) {
$ua->platform($curtest->product()), $ua->platform($curtest->product()),
"NULL", # no way to autodetect the opsys "NULL", # no way to autodetect the opsys
$ua->branch($curtest->product()), $ua->branch($curtest->product()),
$ua->buildid(), $ua->build_id(),
); );
} }
@ -122,8 +122,8 @@ foreach my $curtestid (@tests) {
exit; exit;
} }
my $result = Litmus::DB::Result->retrieve($c->param("testresult_".$curtestid)); my $result_status = Litmus::DB::ResultStatus->retrieve($c->param("testresult_".$curtestid));
$resultcounts{$result->name()}++; $resultcounts{$result_status->name()}++;
my $note = $c->param("comment_".$curtestid); my $note = $c->param("comment_".$curtestid);
my $bugs = $c->param("bugs_".$curtestid); my $bugs = $c->param("bugs_".$curtestid);
@ -136,20 +136,19 @@ foreach my $curtestid (@tests) {
if ($c->param("isSimpleTest")) { if ($c->param("isSimpleTest")) {
$user = $user || Litmus::DB::User->search(email => 'web-tester@mozilla.org')->next(); $user = $user || Litmus::DB::User->search(email => 'web-tester@mozilla.org')->next();
} else { } else {
$user = $user || Litmus::Auth::getCookie()->userid(); $user = $user || Litmus::Auth::getCookie()->user_id();
} }
my $tr = Litmus::DB::Testresult->create({ my $tr = Litmus::DB::Testresult->create({
user => $user, user => $user,
testid => $curtest, testcase => $curtest,
timestamp => $time, timestamp => $time,
last_updated => $time, last_updated => $time,
useragent => $ua, useragent => $ua,
result => $result, result_status => $result_status,
platform => $sysconfig->platform(),
opsys => $sysconfig->opsys(), opsys => $sysconfig->opsys(),
branch => $sysconfig->branch(), branch => $sysconfig->branch(),
buildid => $sysconfig->buildid(), build_id => $sysconfig->build_id(),
locale_abbrev => $sysconfig->locale(), locale_abbrev => $sysconfig->locale(),
}); });

View File

@ -29,6 +29,9 @@
use strict; use strict;
use Time::HiRes qw( gettimeofday tv_interval );
my $t0 = [gettimeofday];
use Litmus; use Litmus;
use Litmus::Error; use Litmus::Error;
use Litmus::DB::Product; use Litmus::DB::Product;
@ -80,34 +83,38 @@ sub page_pickGroupSubgroup {
invalidInputError("Invalid product ".$c->param("product")); invalidInputError("Invalid product ".$c->param("product"));
} }
Litmus::Auth::requireLogin("run_tests.cgi"); my $branch;
if ($c->param("continuetesting")) { if ($c->param("continuetesting")) {
# they have already gotten setup and just want to # they have already gotten setup and just want to
# pick a new group or subgroup: # pick a new group or subgroup:
$sysconfig = Litmus::SysConfig->getCookie($product); $sysconfig = Litmus::SysConfig->getCookie($product);
if (!$sysconfig) {page_pickProduct()}; if (!$sysconfig) {
page_pickProduct()
};
print $c->header(); print $c->header();
$branch = $sysconfig->branch();
} else { } else {
$branch = Litmus::DB::Branch->retrieve($c->param("branch"));
if (! $branch) {
print $c->header();
invalidInputError("Invalid branch ".$c->param("branch"));
}
$sysconfig = Litmus::SysConfig->processForm($c); $sysconfig = Litmus::SysConfig->processForm($c);
# get the user id and set a sysconfig cookie # get the user id and set a sysconfig cookie
$c->storeCookie($sysconfig->setCookie()); $c->storeCookie($sysconfig->setCookie());
print $c->header(); print $c->header();
} }
# get all groups for the product: Litmus::Auth::requireLogin("run_tests.cgi");
my @groups = Litmus::DB::Testgroup->search(product => $sysconfig->product(),
enabled => 1, # Get all groups for the current branch.
{ order_by => 'name ASC' }); my @groups = Litmus::DB::Testgroup->search_EnabledByBranch($branch->branch_id());
# all possible subgroups per group: # all possible subgroups per group:
my %subgroups; my %subgroups;
foreach my $curgroup (@groups) { foreach my $curgroup (@groups) {
my @subgroups = Litmus::DB::Subgroup->search(testgroup => $curgroup, my @subgroups = Litmus::DB::Subgroup->search_EnabledByTestgroup($curgroup->testgroup_id());
enabled => 1, $subgroups{$curgroup->testgroup_id()} = \@subgroups;
{ order_by => 'sort_order ASC' });
$subgroups{$curgroup->testgroupid()} = \@subgroups;
} }
my $defaultgroup = ""; my $defaultgroup = "";
@ -133,6 +140,11 @@ sub page_pickGroupSubgroup {
Litmus->template()->process("runtests/selectgroupsubgroup.html.tmpl", Litmus->template()->process("runtests/selectgroupsubgroup.html.tmpl",
$vars) || $vars) ||
internalError(Litmus->template()->error()); internalError(Litmus->template()->error());
if ($Litmus::Config::DEBUG) {
my $elapsed = tv_interval ( $t0 );
printf "<div id='pageload'>Page took %f seconds to load.</div>", $elapsed;
}
} }
# display a page of testcases: # display a page of testcases:
@ -140,36 +152,42 @@ sub page_test {
# the form has a subgroup radio button set for each possible group, named # the form has a subgroup radio button set for each possible group, named
# subgroup_n where n is the group id number. We get the correct # subgroup_n where n is the group id number. We get the correct
# subgroup based on whatever group the user selected: # subgroup based on whatever group the user selected:
my $subgroupid = $c->param("subgroup_".$c->param("group")); my $testgroup_id = $c->param("group");
my $subgroup_id = $c->param("subgroup_".$testgroup_id);
print $c->header(); print $c->header();
# get the tests to display: # get the tests to display:
my @tests = Litmus::DB::Test->search( my @tests = Litmus::DB::Testcase->search_CommunityEnabledBySubgroup($subgroup_id);
subgroup => $subgroupid,
enabled => 1,
{ order_by => 'sort_order ASC' }
);
# get all possible test results: # get all possible test results:
my @results = Litmus::DB::Result->retrieve_all(); # my @results = Litmus::DB::Result->retrieve_all();
my $sysconfig = Litmus::SysConfig->getCookie($tests[0]->product()); my $sysconfig = Litmus::SysConfig->getCookie($tests[0]->product());
my $cookie = Litmus::Auth::getCookie();
my $vars = { my $vars = {
title => $title, title => $title,
sysconfig => Litmus::SysConfig->getCookie($tests[0]->product()), sysconfig => Litmus::SysConfig->getCookie($tests[0]->product()),
group => Litmus::DB::Subgroup->retrieve($subgroupid)->testgroup(), group => Litmus::DB::Testgroup->retrieve($testgroup_id),
subgroup => Litmus::DB::Subgroup->retrieve($subgroupid), subgroup => Litmus::DB::Subgroup->retrieve($subgroup_id),
tests => \@tests, tests => \@tests,
results => \@results, # results => \@results,
istrusted => Litmus::Auth::istrusted(Litmus::Auth::getCookie()), defaultemail => $cookie,
show_admin => Litmus::Auth::istrusted($cookie),
istrusted => Litmus::Auth::istrusted($cookie),
}; };
my $cookie = Litmus::Auth::getCookie();
$vars->{"defaultemail"} = $cookie; $vars->{"defaultemail"} = $cookie;
$vars->{"show_admin"} = Litmus::Auth::istrusted($cookie); $vars->{"show_admin"} = Litmus::Auth::istrusted($cookie);
$vars->{"istrusted"} = Litmus::Auth::istrusted($cookie);
Litmus->template()->process("runtests/testdisplay.html.tmpl", $vars) || Litmus->template()->process("runtests/testdisplay.html.tmpl", $vars) ||
internalError(Litmus->template()->error()); internalError(Litmus->template()->error());
if ($Litmus::Config::DEBUG) {
my $elapsed = tv_interval ( $t0 );
printf "<div id='pageload'>Page took %f seconds to load.</div>", $elapsed;
}
} }

View File

@ -28,22 +28,26 @@
our $table; our $table;
$table{branches} = $table{branches} =
'branch_id smallint not null primary key auto_increment, 'branch_id smallint(6) not null primary key auto_increment,
product_id tinyint not null, product_id tinyint(4) not null,
name varchar(64) not null, name varchar(64) not null,
detect_regexp varchar(255), detect_regexp varchar(255),
enabled tinyint(1) default 1,
index(product_id), index(product_id),
index(name)'; index(name),
index(detect_regexp),
index(enabled)
';
$table{build_type_lookup} = $table{build_type_lookup} =
'build_type_id tinyint not null primary key auto_increment, 'build_type_id tinyint(4) not null primary key auto_increment,
name varchar(64) not null, name varchar(64) not null,
index(name)'; index(name)';
$table{exit_status_lookup} = $table{exit_status_lookup} =
'exit_status_id tinyint not null primary key auto_increment, 'exit_status_id tinyint(4) not null primary key auto_increment,
name varchar(64) not null, name varchar(64) not null,
index(name)'; index(name)';
@ -55,29 +59,36 @@ $table{locale_lookup} =
index(name)'; index(name)';
$table{log_type_lookup} = $table{log_type_lookup} =
'log_type_id tinyint not null primary key auto_increment, 'log_type_id tinyint(4) not null primary key auto_increment,
name varchar(64) not null, name varchar(64) not null,
index(name)'; index(name)';
$table{opsyses} = $table{opsyses} =
'opsys_id smallint not null primary key auto_increment, 'opsys_id smallint(6) not null primary key auto_increment,
platform_id smallint not null, platform_id smallint(6) not null,
name varchar(64) not null, name varchar(64) not null,
detect_regexp varchar(255), detect_regexp varchar(255),
index(platform_id), index(platform_id),
index(name)'; index(name),
index(detect_regexp)';
$table{platform_products} =
'platform_id smallint(6) not null,
product_id tinyint(4) not null,
primary key (platform_id, product_id)';
$table{platforms} = $table{platforms} =
'platform_id smallint not null primary key auto_increment, 'platform_id smallint not null primary key auto_increment,
product_id tinyint not null,
name varchar(64) not null, name varchar(64) not null,
detect_regexp varchar(255), detect_regexp varchar(255),
iconpath varchar(255), iconpath varchar(255),
index(product_id), index(name),
index(name)'; index(detect_regexp),
index(iconpath)';
$table{products} = $table{products} =
'product_id tinyint not null primary key auto_increment, 'product_id tinyint not null primary key auto_increment,
@ -85,49 +96,52 @@ $table{products} =
iconpath varchar(255), iconpath varchar(255),
enabled tinyint default \'1\', enabled tinyint default \'1\',
index(name), unique key(name),
index(iconpath),
index(enabled)'; index(enabled)';
$table{subgroups} = $table{sessions} =
'subgroup_id smallint not null primary key auto_increment, 'session_id int(11) not null primary key auto_increment,
testgroup_id smallint not null, user_id int(11) not null,
name varchar(64) not null, sessioncookie varchar(255) not null,
sort_order smallint(6), expires datetime not null,
testrunner_group_id int,
enabled tiniyint(1) default "1", index(user_id),
index(sessioncookie),
index(expires)';
$table{subgroup_testgroups} =
'subgroup_id smallint(6) not null,
testgroup_id smallint(6) not null,
primary key(subgroup_id, testgroup_id';
$table{subgroups} =
'subgroup_id smallint(6) not null primary key auto_increment,
name varchar(64) not null,
sort_order smallint(6) not null default "1",
testrunner_group_id int(11),
enabled tiniyint(1) default "1",
product_id tinyint(4) not null,
index(testgroup_id),
index(name), index(name),
index(sort_order), index(sort_order),
index(testrunner_group_id), index(testrunner_group_id),
index(enabled)'; index(enabled),
index(product_id)';
$table{test_format_lookup} = $table{test_format_lookup} =
'format_id tinyint not null primary key auto_increment, 'format_id tinyint(4) not null primary key auto_increment,
name varchar(255) not null, name varchar(255) not null,
index(name)'; index(name)';
$table{test_groups} =
'testgroup_id smallint not null primary key auto_increment,
product_id tinyint not null,
name varchar(64) not null,
expiration_days smallint not null,
enabled tinyint(1) default "1",
testrunner_plan_id int,
index(product_id),
index(name),
index(expiration_days),
index(enabled),
index(testrunner_plan_id)';
$table{test_result_bugs} = $table{test_result_bugs} =
'test_result_id int not null primary key auto_increment, 'test_result_id int(11) not null primary key auto_increment,
last_updated datetime not null, last_updated datetime not null,
submission_time datetime not null, submission_time datetime not null,
user_id int, user_id int(11),
bug_id int not null, bug_id int(11) not null,
index(test_result_id), index(test_result_id),
index(last_updated), index(last_updated),
@ -135,11 +149,11 @@ $table{test_result_bugs} =
index(user_id)'; index(user_id)';
$table{test_result_comments} = $table{test_result_comments} =
'comment_id int not null primary key auto_increment, 'comment_id int(11) not null primary key auto_increment,
test_result_id int not null, test_result_id int(11) not null,
last_updated datetime not null, last_updated datetime not null,
submission_time datetime not null, submission_time datetime not null,
user_id int, user_id int(11),
comment text, comment text,
index(test_result_id), index(test_result_id),
@ -148,12 +162,12 @@ $table{test_result_comments} =
index(user_id)'; index(user_id)';
$table{test_result_logs} = $table{test_result_logs} =
'log_id int not null primary key auto_increment, 'log_id int(11) not null primary key auto_increment,
test_result_id int not null, test_result_id int(11) not null,
last_updated datetime not null, last_updated datetime not null,
submission_time datetime not null, submission_time datetime not null,
log_text longtext, log_text longtext,
log_type_id tinyint not null default \'1\', log_type_id tinyint(4) not null default \'1\',
index(test_result_id), index(test_result_id),
index(last_updated), index(last_updated),
@ -163,7 +177,7 @@ $table{test_result_logs} =
$table{test_result_status_lookup} = $table{test_result_status_lookup} =
'result_status_id smallint not null primary key auto_increment, 'result_status_id smallint(6) not null primary key auto_increment,
name varchar(64) not null, name varchar(64) not null,
style varchar(255) not null, style varchar(255) not null,
class_name varchar(16), class_name varchar(16),
@ -173,22 +187,21 @@ $table{test_result_status_lookup} =
index(class_name)'; index(class_name)';
$table{test_results} = $table{test_results} =
'testresult_id int not null primary key auto_increment, 'testresult_id int(11) not null primary key auto_increment,
test_id int not null, testcase_id int(11) not null,
last_updated datetime, last_updated datetime,
submission_time datetime, submission_time datetime,
user_id int, user_id int(11),
platform_id smallint, opsys_id smallint(6),
opsys_id smallint, branch_id smallint(6),
branch_id smallint, build_id int(10),
buildid varchar(45),
user_agent varchar(255), user_agent varchar(255),
result_id smallint, result_status_id smallint(6),
build_type_id tinyint not null default \'1\', build_type_id tinyint(4) not null default \'1\',
machine_name varchar(64), machine_name varchar(64),
exit_status_id tinyint not null default \'1\', exit_status_id tinyint(4) not null default \'1\',
duration_ms int unsigned, duration_ms int(11) unsigned,
talkback_id int unsigned, talkback_id int(11) unsigned,
locale_abbrev varchar(16) not null default \'en-US\', locale_abbrev varchar(16) not null default \'en-US\',
valid tinyint(1) not null default \'1\', valid tinyint(1) not null default \'1\',
vetted tinyint(1) not null default \'0\', vetted tinyint(1) not null default \'0\',
@ -197,15 +210,15 @@ $table{test_results} =
validated_timestamp datetime, validated_timestamp datetime,
vetted_timestamp datetime, vetted_timestamp datetime,
index(test_id), index(testcase_id),
index(last_updated), index(last_updated),
index(submission_time), index(submission_time),
index(user_id), index(user_id),
index(platform_id),
index(opsys_id), index(opsys_id),
index(branch_id), index(branch_id),
index(build_id),
index(user_agent), index(user_agent),
index(result_id), index(result_status_id),
index(build_type_id), index(build_type_id),
index(machine_name), index(machine_name),
index(exit_status_id), index(exit_status_id),
@ -219,41 +232,109 @@ $table{test_results} =
index(validated_timestamp), index(validated_timestamp),
index(vetted_timestamp)'; index(vetted_timestamp)';
$table{tests} = $table{test_run_branches} =
'test_id int not null primary key auto_increment, 'test_run_id int(11) not null,
subgroup_id smallint not null, branch_id smallint(6) not null,
primary key(test_run_id, branch_id)';
$table{test_run_build_ids} =
'test_run_id int(11) not null,
build_id int(10) not null,
primary key(test_run_id, build_id)';
$table{test_run_opsyses} =
'test_run_id int(11) not null,
opsys_id smallint(6) not null,
primary key(test_run_id, opsys_id)';
$table{test_run_platforms} =
'test_run_id int(11) not null,
platform_id smallint(6) not null,
primary key(test_run_id, platform_id)';
$table{test_runs} =
'test_run_id int(11) not null primary key auto increment,
testgroup_id smallint(6) not null,
name varchar(64) not null,
description varchar(255),
start_timestamp datetime not null,
finish_timestamp datetime not null,
enabled tinyint(1) not null default "1",
index(testgroup_id),
index(name),
index(description),
index(start_timestamp),
index(finish_timestamp),
index(enabled)';
$table{testcase_subgroups} =
'testcase_id int(11) not null,
subgroup_id smallint(6) not null,
primary key(testcase_id, subgroup_id)';
$table{testcases} =
'testcase_id int(11) not null primary key auto_increment,
summary varchar(255) not null, summary varchar(255) not null,
details text, details text,
enabled tinyint(1) not null default \'1\', enabled tinyint(1) not null default \'1\',
community_enabled tinyint(1), community_enabled tinyint(1) not null default \'1\',
format_id tinyint not null default \'1\', format_id tinyint(4) not null default \'1\',
regression_bug_id int, regression_bug_id int(11),
steps longtext, steps longtext,
expected_results longtext, expected_results longtext,
sort_order smallint not null default \'1\', sort_order smallint(6) not null default \'1\',
author_id int not null, author_id int(11) not null,
creation_date datetime not null, creation_date datetime not null,
last_updated datetime not null, last_updated datetime not null,
version smallint not null default \'1\', version smallint(6) not null default \'1\',
testrunner_case_id int, testrunner_case_id int(11),
testrunner_case_version int, testrunner_case_version int(11),
product_id tinyint(4) not null,
index(subgroup_id),
index(summary), index(summary),
index(status_id), index(enabled),
index(community_enabled), index(community_enabled),
index(format_id),
index(regression_bug_id), index(regression_bug_id),
index(steps(255)), index(steps(255)),
index(expected_results(255)), index(expected_results(255)),
index(author_id), index(author_id),
index(creation_date), index(creation_date),
index(last_updated), index(last_updated),
index(testrunner_case_id)'; index(testrunner_case_id),
index(testrunner_case_version),
index(product_id),
fulltext key(summary,steps,expected_results)';
$table{testgroup_branches} =
'testgroup_id smallint(6) not null,
branch_id smallint(6) not null,
primary key(testgroup_id, branch_id)';
$table{testgroups} =
'testgroup_id smallint(6) not null primary key auto_increment,
product_id tinyint(4) not null,
name varchar(64) not null,
enabled tinyint(1) default "1",
testrunner_plan_id int(11),
index(product_id),
index(name),
index(enabled),
index(testrunner_plan_id)';
$table{users} = $table{users} =
'user_id int not null primary key auto_increment, 'user_id int(11) not null primary key auto_increment,
bugzilla_uid int, bugzilla_uid int,
email varchar(255), email varchar(255) not null,
password varchar(255), password varchar(255),
realname varchar(255), realname varchar(255),
irc_nickname varchar(32), irc_nickname varchar(32),
@ -262,17 +343,8 @@ $table{users} =
index(bugzilla_uid), index(bugzilla_uid),
unique index(email), unique index(email),
index(realname),
unique index(irc_nickname), unique index(irc_nickname),
index(password),
index(realname),
index(disabled), index(disabled),
index(is_admin)'; index(is_admin)';
$table{sessions} =
'session_id int not null primary key auto_increment,
user_id int not null,
sessioncookie varchar(255) not null,
expires datetime not null,
index(user_id),
index(sessioncookie),
index(expires)';

View File

@ -89,7 +89,7 @@ if ($c->param) {
push @where, {field => $param, push @where, {field => $param,
value => $value}; value => $value};
$where_criteria .= "Test group is \'".$c->param($param)."\'<br/>"; $where_criteria .= "Test group is \'".$c->param($param)."\'<br/>";
} elsif ($param eq 'test_id') { } elsif ($param eq 'testcase_id') {
my $value = quotemeta($c->param($param)); my $value = quotemeta($c->param($param));
push @where, {field => $param, push @where, {field => $param,
value => $value}; value => $value};

View File

@ -41,44 +41,48 @@ my $c = Litmus->cgi();
print $c->header(); print $c->header();
my $testid = $c->param("id");
my $vars; my $vars;
my $cookie = Litmus::Auth::getCookie(); my $cookie = Litmus::Auth::getCookie();
$vars->{"defaultemail"} = $cookie; $vars->{"defaultemail"} = $cookie;
$vars->{"show_admin"} = Litmus::Auth::istrusted($cookie); $vars->{"show_admin"} = Litmus::Auth::istrusted($cookie);
if (! $testid) { $vars->{'default_match_limit'} = Litmus::DB::Testcase->getDefaultMatchLimit();
Litmus->template()->process("show/enter_id.html.tmpl", $vars) || $vars->{'default_relevance_threshold'} = Litmus::DB::Testcase->getDefaultRelevanceThreshold();
if (! $c->param) {
Litmus->template()->process("show/search_for_testcases.tmpl", $vars) ||
internalError(Litmus->template()->error()); internalError(Litmus->template()->error());
exit; exit;
} }
# Process changes to testcases: if ($c->param("id")) {
# Only users with canedit can edit testcases. my $testcase_id = $c->param("id");
my @changed;
my $update_status = 0; # Process changes to testcases:
if ($c->param("editingTestcases") && # Only users with canedit can edit testcases.
my @changed;
my $update_status = 0;
if ($c->param("editingTestcases") &&
Litmus::Auth::canEdit(Litmus::Auth::getCookie())) { Litmus::Auth::canEdit(Litmus::Auth::getCookie())) {
# the editingTestcases param contains a comma-separated list of # the editingTestcases param contains a comma-separated list of
# testids that the user has made changes to (well, has clicked # testcase IDs that the user has made changes to (well, has clicked
# the edit button for). # the edit button for).
@changed = split(',' => $c->param("editingTestcases")); @changed = split(',' => $c->param("editingTestcases"));
foreach my $editid (@changed) { foreach my $editid (@changed) {
my $edittest = Litmus::DB::Test->retrieve($editid); my $edittest = Litmus::DB::Testcase->retrieve($editid);
if (! $edittest) {invalidInputError("Test $editid does not exist")} if (! $edittest) {invalidInputError("Testcase $editid does not exist")}
$edittest->summary($c->param("summary_edit_$editid")); $edittest->summary($c->param("summary_edit_$editid"));
my $product = Litmus::DB::Product->retrieve($c->param("product_$editid")); my $product = Litmus::DB::Product->retrieve($c->param("product_$editid"));
my $group = Litmus::DB::Testgroup->retrieve($c->param("testgroup_$editid")); # my $group = Litmus::DB::Testgroup->retrieve($c->param("testgroup_$editid"));
my $subgroup = Litmus::DB::Subgroup->retrieve($c->param("subgroup_$editid")); # my $subgroup = Litmus::DB::Subgroup->retrieve($c->param("subgroup_$editid"));
requireField("product", $product); requireField("product", $product);
requireField("group", $group); # requireField("group", $group);
requireField("subgroup", $subgroup); # requireField("subgroup", $subgroup);
$edittest->product($product); $edittest->product($product);
$edittest->testgroup($group); # $edittest->testgroup($group);
$edittest->subgroup($subgroup); # $edittest->subgroup($subgroup);
$edittest->steps($c->param("steps_edit_$editid")); $edittest->steps($c->param("steps_edit_$editid"));
$edittest->expected_results($c->param("results_edit_$editid")); $edittest->expected_results($c->param("results_edit_$editid"));
@ -117,31 +121,55 @@ if ($c->param("editingTestcases") &&
} }
$vars->{'onload'} = "toggleMessage('$status','$message');"; $vars->{'onload'} = "toggleMessage('$status','$message');";
} }
} elsif ($c->param("editingTestcases") && } elsif ($c->param("editingTestcases") &&
! Litmus::Auth::canEdit(Litmus::Auth::getCookie())) { ! Litmus::Auth::canEdit(Litmus::Auth::getCookie())) {
invalidInputError("You do not have permissions to edit testcases. "); invalidInputError("You do not have permissions to edit testcases. ");
} }
my $test = Litmus::DB::Test->retrieve($testid); my $testcase = Litmus::DB::Testcase->retrieve($testcase_id);
if (! $test) { if (! $testcase) {
invalidInputError("Test $testid is not a valid test id"); invalidInputError("\"$testcase_id\" is not a valid testcase ID.");
} }
my @results = Litmus::DB::Result->retrieve_all(); my @testgroups = Litmus::DB::Testgroup->search_EnabledByTestcase($testcase_id);
my @subgroups = Litmus::DB::Subgroup->search_EnabledByTestcase($testcase_id);
my $showallresults = $c->param("showallresults") || ""; my @result_statuses = Litmus::DB::ResultStatus->retrieve_all();
my @where; my $showallresults = $c->param("showallresults") || "";
push @where, { field => 'test_id', value => $testid };
my @order_by;
push @order_by, { field => 'created', direction => 'DESC' };
my $test_results = Litmus::DB::Testresult->getTestResults(\@where,\@order_by);
$vars->{'test'} = $test; my @where;
$vars->{'results'} = \@results; push @where, { field => 'testcase_id', value => $testcase_id };
$vars->{'showallresults'} = $showallresults; my @order_by;
$vars->{'test_results'} = $test_results; push @order_by, { field => 'created', direction => 'DESC' };
my $test_results = Litmus::DB::Testresult->getTestResults(\@where,\@order_by);
Litmus->template()->process("show/show.html.tmpl", $vars) || $vars->{'testcase'} = $testcase;
$vars->{'sysconfig'} = Litmus::SysConfig->getCookie($testcase->product());
$vars->{'testgroups'} = \@testgroups;
$vars->{'subgroups'} = \@subgroups;
$vars->{'result_statuses'} = \@result_statuses;
$vars->{'showallresults'} = $showallresults;
$vars->{'test_results'} = $test_results;
Litmus->template()->process("show/show.html.tmpl", $vars) ||
internalError(Litmus->template()->error()); internalError(Litmus->template()->error());
exit;
}
if ($c->param("text_snippet")) {
my $text_snippet = $c->param("text_snippet");
my $match_limit = $c->param("match_limit");
my $relevance_threshold = $c->param("relevance_threshold");
my @testcases = Litmus::DB::Testcase->getFullTextMatches($text_snippet,
$match_limit,
$relevance_threshold);
$vars->{'testcases'} = \@testcases;
$vars->{'search_string_for_display'} = "Full-Text Search: \"$text_snippet\"";
}
Litmus->template()->process("show/search_for_testcases.tmpl", $vars) ||
internalError(Litmus->template()->error());

View File

@ -86,11 +86,11 @@ sub showTest {
my $test = Litmus::DB::Test->search_random_test($pid)->next(); my $test = Litmus::DB::Test->search_random_test($pid)->next();
my @results = Litmus::DB::Result->retrieve_all(); my @result_statuses = Litmus::DB::ResultStatus->retrieve_all();
my $vars = { my $vars = {
test => $test, test => $test,
results => \@results, result_statuses => \@result_statuses,
}; };
$vars->{"defaultemail"} = Litmus::Auth::getCookie(); $vars->{"defaultemail"} = Litmus::Auth::getCookie();

View File

@ -56,7 +56,7 @@ if ($c->param && $c->param('id')) {
my $cookie = Litmus::Auth::getCookie(); my $cookie = Litmus::Auth::getCookie();
my $user; my $user;
if ($cookie) { if ($cookie) {
$user = $cookie->userid(); $user = $cookie->user_id();
if ($user and if ($user and
$c->param('new_bugs') and $c->param('new_bugs') and
@ -70,7 +70,7 @@ if ($c->param && $c->param('id')) {
if (!Litmus::DB::Resultbug->search(test_result_id =>$c->param('id'), if (!Litmus::DB::Resultbug->search(test_result_id =>$c->param('id'),
bug_id => $new_bug)) { bug_id => $new_bug)) {
my $bug = Litmus::DB::Resultbug->create({ my $bug = Litmus::DB::Resultbug->create({
testresult => $result, test_result => $result,
last_updated => $time, last_updated => $time,
submission_time => $time, submission_time => $time,
user => $user, user => $user,
@ -84,7 +84,7 @@ if ($c->param && $c->param('id')) {
$c->param('new_comment') and $c->param('new_comment') and
$c->param('new_comment') ne '') { $c->param('new_comment') ne '') {
my $comment = Litmus::DB::Comment->create({ my $comment = Litmus::DB::Comment->create({
testresult => $result, test_result => $result,
last_updated => $time, last_updated => $time,
submission_time => $time, submission_time => $time,
user => $user, user => $user,

View File

@ -42,7 +42,13 @@ my $c = Litmus->cgi();
print $c->header(); print $c->header();
# find the number of testcases in the database # find the number of testcases in the database
my $numtests = Litmus::DB::Test->count_all(); my $numtests = Litmus::DB::Testcase->count_all();
# find the number of subgroups in the database
my $numsubgroups = Litmus::DB::Subgroup->count_all();
# find the number of testgroups in the database
my $numtestgroups = Litmus::DB::Testgroup->count_all();
# find the number of users in the database # find the number of users in the database
my $numusers = Litmus::DB::User->count_all(); my $numusers = Litmus::DB::User->count_all();
@ -52,28 +58,13 @@ my $numresults = Litmus::DB::Testresult->count_all();
# get a list of the top 15 testers of all time, sorted by the number # get a list of the top 15 testers of all time, sorted by the number
# of test results submitted: # of test results submitted:
my $dbh = Litmus::DB::User->db_Main(); my @toptesters = Litmus::DB::User->search_TopTesters();
my $sth = $dbh->prepare("SELECT users.user_id, users.email, count(*) AS thecount
FROM users, test_results
WHERE
users.user_id=test_results.user_id
GROUP BY user_id
ORDER BY thecount DESC
LIMIT 15;");
$sth->execute();
my @toptesters;
my @curtester;
while (@curtester = $sth->fetchrow_array()) {
my %testerinfo;
$testerinfo{"email"} = $curtester[1];
$testerinfo{"numtests"} = $curtester[2];
push(@toptesters, \%testerinfo);
}
my $vars = { my $vars = {
title => "Statistics", title => "Statistics",
numtests => $numtests, numtests => $numtests,
numsubgroups => $numsubgroups,
numtestgroups => $numtestgroups,
numusers => $numusers, numusers => $numusers,
numresults => $numresults, numresults => $numresults,
toptesters => \@toptesters, toptesters => \@toptesters,

View File

@ -56,15 +56,15 @@ if ($tests) {
} }
} else { } else {
Litmus::DB::Test->set_sql('failing' => qq { Litmus::DB::Test->set_sql('failing' => qq {
SELECT tests.test_id SELECT testcases.testcase_id
FROM tests, test_results FROM testcases, test_results
WHERE WHERE
test_results.result_id != 1 AND test_results.result_id != 1 AND
test_results.test_id = tests.test_id test_results.testcase_id = testcases.testcase_id
GROUP BY tests.test_id GROUP BY testcases.testcase_id
}); });
@testlist = Litmus::DB::Test->search_failing(); @testlist = Litmus::DB::Testcase->search_failing();
} }
my $vars = { my $vars = {