[Pkg-nagios-changes] [pkg-mod-gearman] 32/48: make tests more reliable

Stig Sandbeck Mathisen ssm at debian.org
Sun Nov 24 22:38:11 UTC 2013


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository pkg-mod-gearman.

commit f3581f9e9647f740d4159bb8a4e9095eab1937ee
Author: Sven Nierlein <Sven.Nierlein at consol.de>
Date:   Fri Nov 1 17:26:08 2013 +0100

    make tests more reliable
---
 t/02-full.c   | 24 +++++++++++++-----------
 t/benchmark.t |  2 ++
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/t/02-full.c b/t/02-full.c
index 31309e0..3ea29c7 100644
--- a/t/02-full.c
+++ b/t/02-full.c
@@ -39,9 +39,9 @@ void *start_gearmand(void*data) {
         snprintf(port, 30, "--port=%d", GEARMAND_TEST_PORT);
         /* for newer gearman versions */
         if(atof(gearman_version()) >= 0.27) {
-            execlp("gearmand", "gearmand", "--threads=10", "--job-retries=0", port, "--verbose=DEBUG", "--log-file=/tmp/gearmand.log" , (char *)NULL);
+            execlp("gearmand", "gearmand", "--listen=127.0.0.1", "--threads=10", "--job-retries=0", port, "--verbose=DEBUG", "--log-file=/tmp/gearmand.log" , (char *)NULL);
         } else if(atof(gearman_version()) > 0.14) {
-            execlp("gearmand", "gearmand", "--threads=10", "--job-retries=0", port, "--verbose=999", "--log-file=/tmp/gearmand.log" , (char *)NULL);
+            execlp("gearmand", "gearmand", "--listen=127.0.0.1", "--threads=10", "--job-retries=0", port, "--verbose=999", "--log-file=/tmp/gearmand.log" , (char *)NULL);
         } else {
             /* for gearman 0.14 */
             execlp("gearmand", "gearmand", "-t 10", "-j 0", port, (char *)NULL);
@@ -303,6 +303,8 @@ void wait_for_empty_queue(char *queue, int timeout) {
     // print some debug info
     if(tries >= timeout) {
         stats = malloc(sizeof(mod_gm_server_status_t));
+        stats->function_num = 0;
+        stats->worker_num   = 0;
         rc = get_gearman_server_data(stats, &message, &version, "localhost", GEARMAND_TEST_PORT);
         diag("get_gearman_server_data:  rc: %d\n", rc);
         diag("get_gearman_server_data: msg: %s\n", message);
@@ -396,7 +398,7 @@ int main (int argc, char **argv, char **env) {
         status = 0;
     }
 
-    if(!ok(gearmand_pid > 0, "'gearmand started with pid: %d", GEARMAND_TEST_PORT, gearmand_pid)) {
+    if(!ok(gearmand_pid > 0, "'gearmand started with port %d and pid: %d", GEARMAND_TEST_PORT, gearmand_pid)) {
         diag("make sure gearmand is in your PATH. Common locations are /usr/sbin or /usr/local/sbin");
         exit( EXIT_FAILURE );
     }
@@ -453,10 +455,10 @@ int main (int argc, char **argv, char **env) {
     sleep(1);
     kill(worker_pid, SIGTERM);
     waitpid(worker_pid, &status, 0);
-    ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
+    ok(status == 0, "worker (%d) exited with exit code %d", worker_pid, real_exit_code(status));
     status = 0;
-    check_logfile(worker_logfile, 0);
     check_no_worker_running(worker_logfile);
+    check_logfile(worker_logfile, 0);
 
     char * test_keys[] = {
         "12345",
@@ -487,10 +489,10 @@ int main (int argc, char **argv, char **env) {
 
         kill(worker_pid, SIGTERM);
         waitpid(worker_pid, &status, 0);
-        ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
+        ok(status == 0, "worker (%d) exited with exit code %d", worker_pid, real_exit_code(status));
         status = 0;
-        check_logfile(worker_logfile, 0);
         check_no_worker_running(worker_logfile);
+        check_logfile(worker_logfile, 0);
     }
 
     /*****************************************
@@ -540,7 +542,7 @@ int main (int argc, char **argv, char **env) {
         waitpid(gearmand_pid, &status, WNOHANG);
         if(pid_alive(gearmand_pid, FALSE) == FALSE) {
             todo();
-            ok(status == 0, "gearmand exited with: %d", real_exit_code(status));
+            ok(status == 0, "gearmand (%d) exited with: %d", gearmand_pid, real_exit_code(status));
             endtodo;
             break;
         }
@@ -551,7 +553,7 @@ int main (int argc, char **argv, char **env) {
         /* kill it the hard way */
         kill(gearmand_pid, SIGTERM);
         waitpid(gearmand_pid, &status, 0);
-        ok(status == 0, "gearmand exited with exit code %d", real_exit_code(status));
+        ok(status == 0, "gearmand (%d) exited with exit code %d", gearmand_pid, real_exit_code(status));
         status = 0;
         ok(false, "gearmand had to be killed!");
     }
@@ -561,9 +563,9 @@ int main (int argc, char **argv, char **env) {
 
     kill(worker_pid, SIGTERM);
     waitpid(worker_pid, &status, 0);
-    ok(status == 0, "worker exited with exit code %d", real_exit_code(status));
-    check_logfile(worker_logfile, 2);
+    ok(status == 0, "worker (%d) exited with exit code %d", worker_pid, real_exit_code(status));
     check_no_worker_running(worker_logfile);
+    check_logfile(worker_logfile, 2);
     status = 0;
 
 #ifdef EMBEDDEDPERL
diff --git a/t/benchmark.t b/t/benchmark.t
index af8ee6f..0d57675 100755
--- a/t/benchmark.t
+++ b/t/benchmark.t
@@ -6,6 +6,8 @@ use Test::More tests => 8;
 use Data::Dumper;
 use Time::HiRes qw( gettimeofday tv_interval sleep );
 
+alarm(60); # hole test should not take longer than 60 seconds
+
 my $TESTPORT    = 54730;
 my $NR_TST_JOBS = 2000;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-mod-gearman



More information about the Pkg-nagios-changes mailing list