[svn:modperl-modules] rev 172 - in Apache-Scoreboard-2.0/trunk: . lib/Apache t/lib/MyTest
[email protected] 8 Mar 2005 15:33:46 -0000
| Newsgroups | perl.modperl.modules.svn |
|---|---|
| Message-ID | <[email protected]> |
Author: stas
Date: Tue Mar 8 07:33:46 2005
New Revision: 172
Modified:
Apache-Scoreboard-2.0/trunk/Changes
Apache-Scoreboard-2.0/trunk/TODO
Apache-Scoreboard-2.0/trunk/lib/Apache/Scoreboard.pm
Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm
Log:
further test improvements
Modified: Apache-Scoreboard-2.0/trunk/Changes
==============================================================================
--- Apache-Scoreboard-2.0/trunk/Changes (original)
+++ Apache-Scoreboard-2.0/trunk/Changes Tue Mar 8 07:33:46 2005
@@ -1,5 +1,8 @@
2.06 - dev
+Revamping docs (still needs more work)
+
+Extending tests to test all worker score methods
2.05 - Sun Feb 27 11:16:46 EST 2005
Modified: Apache-Scoreboard-2.0/trunk/TODO
==============================================================================
--- Apache-Scoreboard-2.0/trunk/TODO (original)
+++ Apache-Scoreboard-2.0/trunk/TODO Tue Mar 8 07:33:46 2005
@@ -1,14 +1,4 @@
-the status() method returning a constant is not sufficient. We need to
-export the constants too (SERVER_DEAD, SERVER_READY, etc, see
-mod_status.c / scoreboard.h). Recently Apache has added some new
-entries in the status list, and now modules like Apache::VMonitor may
-show an incorrect status. May be a better solution is to provide new
-methods status_short() (just the letter), status_long() (the whole
-explanation).
-
----
-
Apache::Scoreboard 2 REMOTE_SCOREBOARD_TYPE is available in global_score,
should probably use that instead of the hardwired value
Modified: Apache-Scoreboard-2.0/trunk/lib/Apache/Scoreboard.pm
==============================================================================
--- Apache-Scoreboard-2.0/trunk/lib/Apache/Scoreboard.pm (original)
+++ Apache-Scoreboard-2.0/trunk/lib/Apache/Scoreboard.pm Tue Mar 8 07:33:46 2005
@@ -552,8 +552,9 @@
$status = $worker_score->status();
-This method returns the status of the given worker, as a number
-(constant), which can be mapped via the following list
+This method returns the status of the given worker as a
+dual-variable. In the string context it gives a single letter, which
+can be mapped to the long description via the following list
"_" Waiting for Connection
"S" Starting up
@@ -567,11 +568,10 @@
"I" Idle cleanup of worker
"." Open slot with no current process
-META: see the TODO file: need to rework this method/add a new method
-to return a letter, and not an index, since the latter changes in the
-scoreboard once in a while, making the application display incorrect
-status.
-
+In the numerical context it returns the numerical status (which
+corresponds to a C define like SERVER_DEAD, SERVER_READY, etc) for
+which we don't really have the use at the moment. You should use the
+string context to get the status.
Modified: Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm
==============================================================================
--- Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm (original)
+++ Apache-Scoreboard-2.0/trunk/t/lib/MyTest/Common.pm Tue Mar 8 07:33:46 2005
@@ -20,20 +20,25 @@
my $hostport = Apache::TestRequest::hostport($cfg);
my $retrieve_url = "http://$hostport/scoreboard";
-my @worker_score_scalar_props = qw(
- thread_num tid req_time most_recent status access_count
- bytes_served my_access_count my_bytes_served conn_bytes conn_count
- client request vhost
-);
+my @worker_score_scalar_props =
+ qw(access_count bytes_served
+ client conn_bytes conn_count most_recent
+ my_access_count my_bytes_served request req_time
+ status thread_num tid);
+# vhost is not available outside mod_perl, since it requires a call to
+# an Apache method
+push @worker_score_scalar_props, "vhost" if $ENV{MOD_PERL};
-my @worker_score_dual_props = qw(
+my @worker_score_dual_ctx_props = qw(
times start_time stop_time
);
+my @worker_score_dual_var_props = qw(status);
+
sub retrieve_url { return $retrieve_url }
sub num_of_tests {
- my $ntests = 16 + @worker_score_scalar_props + @worker_score_dual_props * 2;
+ my $ntests = 16;
$ntests += 2 if $ENV{MOD_PERL}; # deprecated constants
return $ntests;
}
@@ -172,28 +177,10 @@
t_debug "pid: $$, self_parent_idx: $self_parent_idx";
my $self_parent_score = $image->parent_score($self_parent_idx);
t_debug "parent_idx_by_pid";
+ # parent_score_is_ok internally calls worker_score_is_ok on the
+ # first worker score
ok parent_score_is_ok($self_parent_score);
- ### worker_score properties ###
-
- t_debug "worker_score properties:";
- for (@worker_score_dual_props) {
- my $res = $worker_score->$_();
- t_debug "$_ (scalar ctx): $res";
- ok defined $res;
-
- my @res = $worker_score->$_();
- t_debug "$_ (list ctx): @res";
- ok @res;
-
- }
-
- for (@worker_score_scalar_props) {
- my $res = $worker_score->$_();
- t_debug "$_: $res";
- ok defined $res;
- }
-
}
# try to access various underlying datastructures to test that the
@@ -218,16 +205,6 @@
return $status;
}
-my @methods = qw(access_count bytes_served
- client conn_bytes conn_count most_recent
- my_access_count my_bytes_served request req_time
- start_time status stop_time thread_num tid times
- );
-
-# vhost is not available outside mod_perl, since it requires a call to
-# an Apache method
-push @methods, "vhost" if $ENV{MOD_PERL};
-
# check that all worker_score props return something
sub parent_score_is_ok {
my ($parent_score) = shift;
@@ -236,13 +213,9 @@
$ok = 0 unless $parent_score && $parent_score->pid;
+ # check the first worker
my $worker_score = $parent_score->worker_score;
- for (@methods) {
- no strict 'refs';
- my $val = $worker_score->$_;
- #error "$_ [$val]";
- $ok = 0 unless defined $val;
- }
+ $ok = 0 unless worker_score_is_ok($worker_score);
return $ok;
}
@@ -254,7 +227,7 @@
return 0 unless $worker_score;
my $ok = 1;
- for (@worker_score_dual_props) {
+ for (@worker_score_dual_ctx_props) {
my $res = $worker_score->$_();
$ok = 0 unless defined $res;
@@ -262,6 +235,13 @@
$ok = 0 unless @res;
}
+ # status: dual var
+ {
+ my $res = $worker_score->status();
+ $ok = 0 unless $res/1 == $res;
+ $ok = 0 unless $res =~ /^[\w\.]$/;
+ }
+
for (@worker_score_scalar_props) {
my $res = $worker_score->$_();
$ok = 0 unless defined $res;