- standardize on 'enabled' as field name of choice for entities that can be toggled on or off

- replace test status with simple enabled field, and remove obsolete Status.pm
- add enabled fields to Testgroups and Subgroups
This commit is contained in:
ccooper%deadsquid.com 2006-02-24 22:02:41 +00:00
Родитель 31635c30a0
Коммит a93e259537
15 изменённых файлов: 55 добавлений и 299 удалений

Просмотреть файл

@ -72,7 +72,7 @@ sub validate_login($$) {
return 0;
}
if ($userobj->disabled() && $userobj->disabled() == 1) {
if (!$userobj->enabled() || $userobj->enabled() == 0) {
die "Account ".$userobj->username()." has been disabled by the administrator";
}
@ -220,7 +220,7 @@ sub processLoginForm {
password => bz_crypt($password),
bugzilla_uid => 0,
realname => $name,
disabled => 0,
enabled => 1,
is_admin => 0,
irc_nickname => $nickname
});
@ -314,7 +314,7 @@ sub processLoginForm {
$userobj->password(bz_crypt($password));
$userobj->bugzilla_uid("0");
$userobj->realname($realname);
$userobj->disabled(0);
$userobj->enabled(1);
# $userobj->is_admin(0);
$userobj->irc_nickname($nickname);
$userobj->update();

Просмотреть файл

@ -59,7 +59,7 @@ sub isValid {
return 0;
}
if ($self->user_id()->disabled() && $self->user_id()->disabled() == 1) {
if (!$self->user_id()->enabled() || $self->user_id()->enabled() == 0) {
$self->makeExpire();
return 0;
}

Просмотреть файл

Просмотреть файл

@ -41,7 +41,7 @@ use Litmus::DB::Testresult;
Litmus::DB::Subgroup->table('subgroups');
Litmus::DB::Subgroup->columns(All => qw/subgroup_id testgroup_id name sort_order testrunner_group_id/);
Litmus::DB::Subgroup->columns(All => qw/subgroup_id testgroup_id name sort_order testrunner_group_id enabled/);
Litmus::DB::Subgroup->column_alias("subgroup_id", "subgroupid");
Litmus::DB::Subgroup->column_alias("testgroup_id", "testgroup");
@ -62,12 +62,12 @@ sub community_coverage() {
if (! $community_only) {
@tests = Litmus::DB::Test->search(
subgroup => $self,
status => Litmus::DB::Status->search(name => "Enabled"),
enabled => 1,
);
} else {
@tests = Litmus::DB::Test->search(
subgroup => $self,
status => Litmus::DB::Status->search(name => "Enabled"),
enabled => 1,
communityenabled => 1,
);
}
@ -100,12 +100,12 @@ sub personal_coverage() {
if (! $community_only) {
@tests = Litmus::DB::Test->search(
subgroup => $self,
status => Litmus::DB::Status->search(name => "Enabled"),
enabled => 1,
);
} else {
@tests = Litmus::DB::Test->search(
subgroup => $self,
status => Litmus::DB::Status->search(name => "Enabled"),
enabled => 1,
communityenabled => 1,
);
}

Просмотреть файл

@ -1,260 +0,0 @@
# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*-
=head1 COPYRIGHT
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License
# at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and
# limitations under the License.
#
# The Original Code is Litmus.
#
# The Initial Developer of the Original Code is
# the Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Chris Cooper <ccooper@deadsquid.com>
# Zach Lipton <zach@zachlipton.com>
#
# ***** END LICENSE BLOCK *****
=cut
package Litmus::DB::Test;
use strict;
use base 'Litmus::DBI';
use Litmus::DB::Testresult;
use Memoize;
use Litmus::Error;
Litmus::DB::Test->table('tests');
Litmus::DB::Test->columns(Primary => qw/test_id/);
Litmus::DB::Test->columns(Essential => qw/subgroup_id summary details status_id community_enabled format_id regression_bug_id/);
Litmus::DB::Test->columns(All => qw/steps expected_results sort_order author_id creation_date last_updated version testrunner_case_id testrunner_case_version/);
Litmus::DB::Test->column_alias("test_id", "testid");
Litmus::DB::Test->column_alias("subgroup_id", "subgroup");
Litmus::DB::Test->column_alias("status_id", "status");
Litmus::DB::Test->column_alias("community_enabled", "communityenabled");
Litmus::DB::Test->column_alias("format_id", "format");
Litmus::DB::Test->column_alias("author_id", "author");
Litmus::DB::Test->has_a(subgroup => "Litmus::DB::Subgroup");
Litmus::DB::Test->has_a(status => "Litmus::DB::Status");
Litmus::DB::Test->has_a("format" => "Litmus::DB::Format");
Litmus::DB::Test->has_a(author => "Litmus::DB::User");
Litmus::DB::Test->has_many(testresults => "Litmus::DB::Testresult", {order_by => 'submission_time DESC'});
#########################################################################
# does the test have at least one recent result?
# optionally, just check for a particular platform.
#########################################################################
memoize('isrecent');
sub isrecent {
my $self = shift;
my $platform = shift;
my %restrictor;
if ($platform) { $restrictor{platform} = $platform }
my @results = $self->testresults(%restrictor);
foreach my $curresult (@results) {
if ($curresult->isrecent()) {
return 1;
}
}
return 0;
}
#########################################################################
# is_completed($$$$$)
#
# Check whether we have test results for the current test that correspond
# to the provided platform, build_id, and user(optional).
#########################################################################
memoize('is_completed');
sub is_completed {
my $self = shift;
my $platform = shift;
my $build_id = shift;
my $locale = shift;
my $user = shift; # optional
my @results;
if ($user) {
@results = $self->testresults(
platform => $platform,
buildid => $build_id,
locale => $locale,
user => $user,
);
} else {
@results = Litmus::DB::Testresult->retrieve_from_sql(
"platform_id = " . $platform->{'platform_id'} . " AND " .
"buildid LIKE \'\%" . $build_id . "\%\' AND " .
"locale_abbrev = \'" . $locale->{'abbrev'} . "\' AND " .
"test_id = " . $self->{'test_id'}
);
# @results = $self->testresults(
# platform => $platform,
# buildid => $build_id,
# locale => $locale,
# );
}
return @results;
}
#########################################################################
# You might think that getting the state of a test for a particular platform
# would be pretty easy. In reality, it's more of an art then a science, since
# we get to consider all the test results submitted for a particular test,
# their age, whether the result is from a trusted user, and other fun things.
#
# Or in other words: "Heuristics are bug ridden by definition. If they didn't
# have bugs, then they'd be algorithms."
#
# XXX: Rewrite all this as an SQL query so it doesn't take so long.
#
# YYY: 'state' is even less simple than you might think, and should be
# based per-branch and make note of the most recent build ID per
# platform.
#########################################################################
memoize('state');
sub state {
my $self = shift;
my $platform = shift;
# XXX: if the test is automated, just return the most recent state
my %statecounts;
# first get all results for this test for this platform:
my @results = $self->testresults(platform => $platform);
foreach my $curresult (@results) {
if (! $curresult->isrecent($platform)) {
# only consider recent results
next;
}
# we weight the result based on its age and if it is confirmed:
# first figure out how old the result is as a proportion of the
# expiration time for the group using a grannuler definition of a day:
my $adjustedage;
if ($curresult->age()->days() < 1.5) {
$adjustedage = 1;
} elsif ($curresult->age()->days() < 2.5) {
$adjustedage = 1.8;
} else {
$adjustedage = $curresult->age()->days();
}
my $ageproportion = $self->subgroup()->testgroup()->expirationdays()/$adjustedage;
my $weight = $ageproportion;
# give an additional weighting of 2 points to confirmed results:
if ($curresult->istrusted()) {
$weight += 2;
}
$statecounts{$curresult->result()} += $weight;
}
# now that we have the weighted counts for each possible state, we
# calculate the magic number for this test. In other words, the
# result spread that we require in order to have confidence in our
# result. If the spread between two states is within the magic
# number, we just return 0 and the test should be considered unrun
# since we have no confidence in our result.
my $magicnumber = 2; # ok we don't really calculate it. We should though...
foreach my $outer (keys(%statecounts)) {
foreach my $inner (keys(%statecounts)) {
if ($outer eq $inner) {
next;
}
if (abs($statecounts{$inner} - $statecounts{$outer}) < $magicnumber) {
return 0;
}
}
}
# now we just find the state with the greatest value and return it:
my $maxkey;
foreach my $cur (keys(%statecounts)) {
unless ($maxkey) {$maxkey = $cur}
if ($statecounts{$cur} > $statecounts{$maxkey}) {
$maxkey = $cur;
}
}
return Litmus::DB::Result->retrieve($maxkey);
}
#########################################################################
# calculate the percent of the time this test has been in existance that it
# has had a particular state (default state is the current one)
#########################################################################
sub percentinstate {
my $self = shift;
my $state = shift || $self->state();
}
#########################################################################
# find the number of recent results for this test
#########################################################################
memoize('num_recent_results');
sub num_recent_results {
my $self = shift;
my $count;
foreach my $curresult ($self->testresults()) {
if ($curresult->isrecent()) {
$count++;
}
}
return $count;
}
#########################################################################
# these are just convenience functions since they are pretty common needs
# and templates would be pretty verbose without them:
#########################################################################
sub product {
my $self = shift;
return $self->testgroup()->product();
}
#########################################################################
#########################################################################
sub testgroup {
my $self = shift;
return $self->subgroup()->testgroup();
}
1;

Просмотреть файл

@ -37,7 +37,7 @@ use base 'Litmus::DBI';
Litmus::DB::Testgroup->table('test_groups');
Litmus::DB::Testgroup->columns(All => qw/testgroup_id product_id name expiration_days obsolete testrunner_plan_id/);
Litmus::DB::Testgroup->columns(All => qw/testgroup_id product_id name expiration_days enabled testrunner_plan_id/);
Litmus::DB::Testgroup->column_alias("testgroup_id", "testgroupid");
Litmus::DB::Testgroup->column_alias("product_id", "product");

Просмотреть файл

@ -324,8 +324,6 @@ sub _processSearchField(\%) {
$table_field='t.name';
} elsif ($search_field->{'search_field'} eq 'test_group') {
$table_field='tg.name';
} elsif ($search_field->{'search_field'} eq 'test_status') {
$table_field='tsl.name';
} elsif ($search_field->{'search_field'} eq 'user_agent') {
$table_field='tr.user_agent';
} else {

Просмотреть файл

@ -37,7 +37,7 @@ use base 'Litmus::DBI';
Litmus::DB::User->table('users');
Litmus::DB::User->columns(All => qw/user_id bugzilla_uid email password realname irc_nickname disabled is_admin/);
Litmus::DB::User->columns(All => qw/user_id bugzilla_uid email password realname irc_nickname enabled is_admin/);
Litmus::DB::User->column_alias("user_id", "userid");
Litmus::DB::User->column_alias("is_trusted", "istrusted");

Просмотреть файл

@ -157,8 +157,9 @@ sub getLogTypes()
#########################################################################
sub getTestStatuses()
{
my $sql = "SELECT test_status_id,name FROM test_status_lookup ORDER BY test_status_id";
return _getValues($sql);
my @TestStatuses = ({name => 'Enabled'},
{name => 'Disabled'});
return \@TestStatuses;
}
#########################################################################
@ -226,8 +227,6 @@ sub getFields()
display_string => "Summary", },
{ name => 'test_group',
display_string => "Testgroup", },
{ name => 'test_status',
display_string => "Test Status", },
{ name => 'user_agent',
display_string => "User Agent", },
);

Просмотреть файл

@ -138,7 +138,6 @@ $dbtool->DropField("users", "is_trusted");
$dbtool->AddField("users", "bugzilla_uid", "int default '1'");
$dbtool->AddField("users", "password", "varchar(255)");
$dbtool->AddField("users", "realname", "varchar(255)");
$dbtool->AddField("users", "disabled", "tinyint(1) default '0'");
$dbtool->AddField("users", "is_admin", "tinyint(1) default '0'");
$dbtool->AddField("users", "irc_nickname", "varchar(32)");
$dbtool->AddUniqueKey("users","email","(email)");
@ -149,7 +148,6 @@ $dbtool->AddKey("users","is_admin","(is_admin)");
# replace enums with more portable and flexible formats:
$dbtool->ChangeFieldType("products", "enabled", 'tinyint(1) default "1"');
$dbtool->ChangeFieldType("test_groups", "obsolete", 'tinyint(1) default "0"');
$dbtool->DropField("test_result_logs", "log_path");
$dbtool->AddField("test_result_logs", "log_text", "longtext");
@ -172,8 +170,21 @@ $dbtool->DropField("test_results", "vetting_status_id");
$dbtool->DropTable("validity_lookup");
$dbtool->DropTable("vetting_status_lookup");
$dbtool->ChangeFieldType("users", "disabled", 'tinyint(1) default "0"');
$dbtool->AddKey("users","disabled","(disabled)");
$dbtool->AddField("test_groups", "enabled", "tinyint(1) default '1'");
$dbtool->AddKey("test_groups","enabled","(enabled)");
$dbtool->AddField("subgroups", "enabled", "tinyint(1) default '1'");
$dbtool->AddKey("subgroups","enabled","(enabled)");
$dbtool->DropField("test_groups", "obsolete");
$dbtool->AddField("users", "enabled", "tinyint(1) default '1'");
$dbtool->AddKey("users","enabled","(enabled)");
$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");
# javascript cache
print "Rebuilding JS cache...";

Просмотреть файл

@ -97,12 +97,14 @@ sub page_pickGroupSubgroup {
}
# get all groups for the product:
my @groups = Litmus::DB::Testgroup->search(product => $sysconfig->product(), obsolete => 0);
my @groups = Litmus::DB::Testgroup->search(product => $sysconfig->product(), enabled => 1);
# all possible subgroups per group:
my %subgroups;
foreach my $curgroup (@groups) {
my @subgroups = Litmus::DB::Subgroup->search(testgroup => $curgroup, { order_by => 'sort_order ASC' });
my @subgroups = Litmus::DB::Subgroup->search(testgroup => $curgroup,
enabled => 1,
{ order_by => 'sort_order ASC' });
$subgroups{$curgroup->testgroupid()} = \@subgroups;
}
@ -143,7 +145,7 @@ sub page_test {
# get the tests to display:
my @tests = Litmus::DB::Test->search(
subgroup => $subgroupid,
status => Litmus::DB::Status->search(name => "Enabled"),
enabled => 1,
{ order_by => 'sort_order ASC' }
);

Просмотреть файл

@ -94,11 +94,13 @@ $table{subgroups} =
name varchar(64) not null,
sort_order smallint(6),
testrunner_group_id int,
enabled tiniyint(1) default "1",
index(testgroup_id),
index(name),
index(sort_order),
index(testrunner_group_id)';
index(testrunner_group_id),
index(enabled)';
$table{test_format_lookup} =
'format_id tinyint not null primary key auto_increment,
@ -111,16 +113,16 @@ $table{test_groups} =
product_id tinyint not null,
name varchar(64) not null,
expiration_days smallint not null,
obsolete tinyint(4) default "0",
enabled tinyint(1) default "1",
testrunner_plan_id int,
index(product_id),
index(name),
index(expiration_days),
index(obsolete),
index(enabled),
index(testrunner_plan_id)';
$table{test_result_bugs} =
$table{test_result_bugs} =
'test_result_id int not null primary key auto_increment,
last_updated datetime not null,
submission_time datetime not null,
@ -216,20 +218,13 @@ $table{test_results} =
index(vetted_by_user_id),
index(validated_timestamp),
index(vetted_timestamp)';
$table{test_status_lookup} =
'test_status_id tinyint not null primary key auto_increment,
name varchar(64) not null,
index(name)';
$table{tests} =
'test_id int not null primary key auto_increment,
subgroup_id smallint not null,
summary varchar(255) not null,
details text,
status_id tinyint not null,
enabled tinyint(1) not null default \'1\',
community_enabled tinyint(1),
format_id tinyint not null default \'1\',
regression_bug_id int,
@ -262,7 +257,7 @@ $table{users} =
password varchar(255),
realname varchar(255),
irc_nickname varchar(32),
disabled tinyint(1),
enabled tinyint(1),
is_admin tinyint(1),
index(bugzilla_uid),

Просмотреть файл

@ -72,7 +72,7 @@ sub showTest {
my $pid = $prod->productid();
# get a random test to display:
Litmus::DB::Test->set_sql(random_test => qq {
SELECT tests.test_id, tests.subgroup_id, tests.summary, tests.details, tests.status_id, tests.community_enabled, tests.format_id, tests.regression_bug_id
SELECT tests.test_id, tests.subgroup_id, tests.summary, tests.details, tests.enabled, tests.community_enabled, tests.format_id, tests.regression_bug_id
FROM __TABLE__, products,test_groups,subgroups
WHERE
products.product_id=? AND

Просмотреть файл

@ -195,7 +195,7 @@ Please select a testing group with testcases, or that has not yet been tested in
[% END %]
[% END %]
[% counttests = cursubgroup.tests('status_id',1) %]
[% counttests = cursubgroup.tests('enabled',1) %]
<tr class="[% groupstyle | none %]">
<td align="left"><input [% IF ! counttests %]disabled [% ELSIF select_first_avail_subgroup==1 %][% select_first_avail_subgroup=0 %]checked [% END %]type="radio" name="subgroup_[% curgroup FILTER html %]"
value="[% cursubgroup.id FILTER html %]">

Просмотреть файл

@ -139,6 +139,16 @@
[% IF showedit %]
<div id="admin_edit_[%test.testid | html%]" style="display: none;">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><b>Enabled?</b></td>
<td>[% IF test.enabled %][% checked = "checked" %][% END %]
<input name="enabled_[%test.testid | html%]"
type="checkbox"
id="enabled_[%test.testid | html%]"
value="1" [% checked %]>
</td>
<td>Check this to completely disable this testcase.</td>
</tr>
<tr>
<td><b>Community Enabled?</b></td>
<td>[% IF test.communityenabled %][% checked = "checked" %][% END %]
@ -147,6 +157,7 @@
id="communityenabled_[%test.testid | html%]"
value="1" [% checked %]>
</td>
<td>Check this to disable this testcase for the community-at-large. Note: trusted testers will stlil be able to see and run this testcase.</td>
</tr>
<tr>
<td><b>Regression Bug ID#</b>:</td>