You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/04/12 11:56:09 UTC

svn commit: r527868 - in /spamassassin/trunk: MANIFEST t/spamd_prefork_stress_4.t

Author: jm
Date: Thu Apr 12 02:56:08 2007
New Revision: 527868

URL: http://svn.apache.org/viewvc?view=rev&rev=527868
Log:
add a new, aggressive multi-process spamd preforking stress-test.  skipped by default, unless 'run_spamd_prefork_stress_test' is set to 'y' in t/config

Added:
    spamassassin/trunk/t/spamd_prefork_stress_4.t   (with props)
Modified:
    spamassassin/trunk/MANIFEST

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/spamassassin/trunk/MANIFEST?view=diff&rev=527868&r1=527867&r2=527868
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Thu Apr 12 02:56:08 2007
@@ -491,3 +491,4 @@
 t/text_bad_ctype.t
 t/data/spam/badctype1
 t/data/spam/badctype2
+t/spamd_prefork_stress_4.t

Added: spamassassin/trunk/t/spamd_prefork_stress_4.t
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/spamd_prefork_stress_4.t?view=auto&rev=527868
==============================================================================
--- spamassassin/trunk/t/spamd_prefork_stress_4.t (added)
+++ spamassassin/trunk/t/spamd_prefork_stress_4.t Thu Apr 12 02:56:08 2007
@@ -0,0 +1,123 @@
+#!/usr/bin/perl
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("spamd_prefork_stress_4");
+use Test;
+
+our $RUN_THIS_TEST;
+
+BEGIN {
+  $RUN_THIS_TEST = conf_bool('run_spamd_prefork_stress_test');
+  plan tests => ($SKIP_SPAMD_TESTS || !$RUN_THIS_TEST ? 0 : 43)
+};
+
+exit if $SKIP_SPAMD_TESTS;
+
+print "NOTE: this test requires 'run_spamd_prefork_stress_test' set to 'y'.\n";
+exit unless $RUN_THIS_TEST;
+
+# ---------------------------------------------------------------------------
+
+# tstlocalrules ('
+        # loadplugin myTestPlugin ../../data/testplugin.pm
+        # header PLUGIN_SLEEP eval:sleep_based_on_header()
+# ');
+
+
+%patterns = (
+
+q{ X-Spam-Status: Yes, score=}, 'status',
+q{ X-Spam-Flag: YES}, 'flag',
+q{ X-Spam-Level: **********}, 'stars',
+q{ TEST_ENDSNUMS}, 'endsinnums',
+q{ TEST_NOREALNAME}, 'noreal',
+
+);
+
+my $tmpnum = 0;
+start_spamd("-L -m10");
+ok ($spamd_pid > 1);
+
+srand ($$); print "srand: $$\n";
+
+ok (spamcrun ("< data/spam/001", \&patterns_run_cb));
+ok_all_patterns();
+
+test_spamc(); ok_all_patterns();
+
+my @bgpids = ();
+
+$SIG{INT} = sub {
+  kill 15, @bgpids;
+  die "interrupted";
+};
+
+foreach my $i (0 .. 20) {
+  my $pid = fork();
+
+  if ($pid) {
+    push @bgpids, $pid;
+    print "forked $pid\n";
+
+  } else {
+    $tmpnum = ($$ * 100);
+    $testname .= ".pid$$";
+
+    my $nummsgs = 5 + ($$ % 9);
+    
+    print "pid $$: starting, will send $nummsgs msgs\n";
+
+    for my $j (1 .. $nummsgs) {
+      select(undef, undef, undef, 0.25 + rand(10));
+      if (!test_without_ok()) {
+        die "pid $$ failed on spamc run";
+      }
+      if (!ok_all_patterns(1)) {
+        die "pid $$ failed on results check";
+      }
+    }
+
+    print "pid $$: done\n";
+    exit 0;
+  }
+}
+
+foreach my $pid (@bgpids) {
+  print "wait for $pid\n";
+  waitpid($pid, 0);
+  my $ex = ($? >> 8);
+  print "$pid exited with status: ".$ex."\n";
+  ok ($ex == 0);
+}
+
+test_spamc(); ok_all_patterns();
+ok (stop_spamd());
+
+# now search for errors
+my $failed = 0;
+
+ok (open (IN, "<${spamd_stderr}"));
+while (<IN>) {
+  /prefork: ordered child \S+ to accept, but/ and $failed++;
+  /prefork: killing failed child/ and $failed++;
+  /syswrite.. to parent failed/ and $failed++;
+}
+close IN;
+
+ok (!$failed);
+
+
+
+sub test_without_ok {
+  clear_pattern_counters();
+  print "pid $$: running spamc\n";
+  return (spamcrun ("<data/spam/001", \&patterns_run_cb));
+}
+
+sub test_spamc {
+  clear_pattern_counters();
+  ok (spamcrun ("<data/spam/001", \&patterns_run_cb));
+}
+
+
+

Propchange: spamassassin/trunk/t/spamd_prefork_stress_4.t
------------------------------------------------------------------------------
    svn:executable = *