Browse Source

Fix include file structure.

Brian Aker 14 years ago
parent
commit
7fa07a0ccf

+ 25 - 0
bin/include.am

@@ -46,3 +46,28 @@ noinst_HEADERS+= \
 		 bin/function.h \
 		 bin/client.h \
 		 bin/worker.h
+
+GEARMAN_CLIENT_TEST= bin/gearman
+GEARMAN_VALGRIND_CLIENT_TEST= $(VALGRIND_COMMAND) bin/gearman
+GEARMAN_PIDFILE = ${abs_top_builddir}/tests/Xugear.pid
+
+client-test: $(GEARMAN_CLIENT_TEST)
+	@$(GEARMAN_CLIENT_TEST) -H 2>&1 > /dev/null
+	@$(GEARMAN_CLIENT_TEST) -w -f true -d -i $(GEARMAN_PIDFILE) -- false
+	cat $(GEARMAN_PIDFILE) | xargs kill
+	@echo "gearman client success"
+
+client-test-wc: $(GEARMAN_CLIENT_TEST)
+	@echo "1" > ${abs_top_builddir}/tests/test_file 
+	@$(GEARMAN_CLIENT_TEST) -w -f wc -d -i $(GEARMAN_PIDFILE) -- wc -l
+	@$(GEARMAN_CLIENT_TEST) -f wc < ${abs_top_builddir}/tests/test_file > ${abs_top_builddir}/tests/out_file
+	diff -q ${abs_top_builddir}/tests/test_file  ${abs_top_builddir}/tests/out_file
+	rm ${abs_top_builddir}/tests/test_file  ${abs_top_builddir}/tests/out_file
+	cat $(GEARMAN_PIDFILE) | xargs kill
+	@echo "gearman client success"
+
+valgrind-client-test: $(GEARMAN_CLIENT_TEST)
+		      @$(GEARMAN_VALGRIND_CLIENT_TEST) -H 2>&1 > /dev/null
+		      @$(GEARMAN_CLIENT_TEST) -w -f true -d -i $(GEARMAN_PIDFILE) -- false
+		      cat $(GEARMAN_PIDFILE) | xargs kill
+		      @echo "gearman client success"

+ 19 - 9
gearmand/gearmand.cc

@@ -130,8 +130,8 @@ int main(int argc, char *argv[])
 {
   int backlog= GEARMAND_LISTEN_BACKLOG;
   rlim_t fds= 0;
-  uint8_t job_retries= 0;
-  uint8_t worker_wakeup= 0;
+  uint32_t job_retries;
+  uint32_t worker_wakeup;
 
   std::string host;
   std::string user;
@@ -143,21 +143,23 @@ int main(int argc, char *argv[])
   std::string verbose_string;
 
   uint32_t threads;
-  uint8_t verbose_count= 0;
   bool opt_round_robin;
   bool opt_daemon;
+  bool opt_check_args;
 
   boost::program_options::options_description general("General options");
 
   general.add_options()
   ("backlog,b", boost::program_options::value(&backlog)->default_value(GEARMAND_LISTEN_BACKLOG),
    "Number of backlog connections for listen.")
-  ("daemon,d",boost::program_options::bool_switch(&opt_daemon)->default_value(false),
+  ("check-args", boost::program_options::bool_switch(&opt_check_args)->default_value(false),
+   "Check command line and configuration file argments and then exit.")
+  ("daemon,d", boost::program_options::bool_switch(&opt_daemon)->default_value(false),
    "Daemon, detach and run in the background.")
   ("file-descriptors,f", boost::program_options::value(&fds),
    "Number of file descriptors to allow for the process (total connections will be slightly less). Default is max allowed for user.")
   ("help,h", "Print this help menu.")
-  ("job-retries,j", boost::program_options::value(&job_retries),
+  ("job-retries,j", boost::program_options::value(&job_retries)->default_value(0),
    "Number of attempts to run the job before the job server removes it. This is helpful to ensure a bad job does not crash all available workers. Default is no limit.")
   ("log-file,l", boost::program_options::value(&log_file),
    "Log file to write errors and information to. Turning this option on also forces the first verbose level to be enabled.")
@@ -180,7 +182,7 @@ int main(int argc, char *argv[])
   ("verbose,v", boost::program_options::value(&verbose_string)->default_value("v"),
    "Increase verbosity level by one.")
   ("version,V", "Display the version of gearmand and exit.")
-  ("worker-wakeup,w", boost::program_options::value(&worker_wakeup),
+  ("worker-wakeup,w", boost::program_options::value(&worker_wakeup)->default_value(0),
    "Number of workers to wakeup for each job received. The default is to wakeup all available workers.")
   ;
 
@@ -204,6 +206,14 @@ int main(int argc, char *argv[])
     return EXIT_FAILURE;
   }
 
+  uint8_t verbose_count;
+  verbose_count= static_cast<gearmand_verbose_t>(verbose_string.length());
+
+  if (opt_check_args)
+  {
+    return EXIT_SUCCESS;
+  }
+
   if (vm.count("help"))
   {
     std::cout << all << std::endl;
@@ -216,8 +226,6 @@ int main(int argc, char *argv[])
     return EXIT_FAILURE;
   }
 
-  verbose_count= static_cast<gearmand_verbose_t>(verbose_string.length());
-
   if (opt_daemon)
   {
     gearmand::daemonize(false, true);
@@ -247,7 +255,9 @@ int main(int argc, char *argv[])
 
   gearmand_st *_gearmand;
   _gearmand= gearmand_create(host.empty() ? NULL : host.c_str(),
-                             port.c_str(), threads, backlog, job_retries, worker_wakeup,
+                             port.c_str(), threads, backlog,
+			     static_cast<uint8_t>(job_retries),
+			     static_cast<uint8_t>(worker_wakeup),
                              _log, &log_info, verbose,
                              opt_round_robin);
   if (_gearmand == NULL)

+ 36 - 0
gearmand/include.am

@@ -31,3 +31,39 @@ gearmand-valgrind: gearmand/gearmand
 
 gearmand-debug: gearmand/gearmand
 	$(LIBTOOL) --mode=execute gdb gearmand/gearmand
+
+gearmand-test-args: gearmand/gearmand
+	@gearmand/gearmand --check-args
+	@gearmand/gearmand --backlog=10 --check-args
+	@gearmand/gearmand --b 10 --check-args
+	@gearmand/gearmand --d --check-args
+	@gearmand/gearmand --daemon --check-args
+	@gearmand/gearmand --file-descriptors=100 --check-args
+	@gearmand/gearmand --f 100 --check-args
+	@gearmand/gearmand -h --check-args
+	@gearmand/gearmand --help --check-args
+	@gearmand/gearmand -l "tmp/foo" --check-args
+	@gearmand/gearmand --log-file="tmp/foo" --check-args
+	@gearmand/gearmand --listen=10 --check-args
+	@gearmand/gearmand -L 10 --check-args
+	@gearmand/gearmand --port=10 --check-args
+	@gearmand/gearmand -p 10 --check-args
+	@gearmand/gearmand --pid-file="tmp/file.pid" --check-args
+	@gearmand/gearmand -P "tmp/file.pid" --check-args
+	@gearmand/gearmand --round-robin --check-args
+	@gearmand/gearmand -R --check-args
+	@gearmand/gearmand --pid-file="tmp/file.pid" --check-args
+	@gearmand/gearmand -P "tmp/file.pid" --check-args
+	@gearmand/gearmand --threads=10 --check-args
+	@gearmand/gearmand -t 10  --check-args
+	@gearmand/gearmand --user=nobody --check-args
+	@gearmand/gearmand -u nobody --check-args
+	@gearmand/gearmand --check-args -vvvv
+	@gearmand/gearmand -V --check-args
+	@gearmand/gearmand --version --check-args
+	@gearmand/gearmand -w 10 --check-args
+	@gearmand/gearmand --worker-wakeup=10 --check-args
+	@gearmand/gearmand --protocol=http --check-args
+	@gearmand/gearmand --queue-type=http --check-args
+	@gearmand/gearmand -j 10 --check-args
+	@gearmand/gearmand --job-retries=10 --check-args

+ 1 - 1
libgearman-server/plugins/queue/tokyocabinet/queue.cc

@@ -43,7 +43,7 @@ TokyoCabinet::TokyoCabinet() :
 {
   command_line_options().add_options()
     ("libtokyocabinet-file", boost::program_options::value(&filename), "File name of the database. [see: man tcadb, tcadbopen() for name guidelines]")
-    ("libtokyocabinet-optimize", boost::program_options::value(&optimize)->default_value(true), "Optimize database on open. [default=true]");
+    ("libtokyocabinet-optimize", boost::program_options::bool_switch(&optimize)->default_value(true), "Optimize database on open. [default=true]");
 
   db= tcadbnew();
 }

+ 14 - 0
tests/httpd.am

@@ -0,0 +1,14 @@
+# vim:ft=automake
+# Gearman server and library
+# Copyright (C) 2011 Data Differential, http://datadifferential.com/
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license.  See
+# the COPYING file in the parent directory for full text.
+#
+# Included from Top Level Makefile.am
+# All paths should be given relative to the root
+#
+
+tests-httpd-args: gearmand/gearmand
+	@gearmand/gearmand --http-port=80

+ 8 - 116
tests/include.am

@@ -18,54 +18,12 @@ CLEANFILES+= \
 	     tests/var/log/* \
 	     tests/var/tmp/*
 
-if HAVE_LIBMEMCACHED
-if HAVE_MEMCACHED
-LIBMEMCACHED_PIDFILE = ${abs_top_builddir}/tests/Xumemc.pid
-LIBMEMCACHED_TEST= tests/memcached_test
-# Note, SETUP should do a test for existance and then kill if it exists.
-LIBMEMCACHED_SETUP= @$(MEMCACHED_BINARY) -d -u root -P ${LIBMEMCACHED_PIDFILE} -p 12555
-LIBMEMCACHED_TEARDOWN= @\
-		       cat ${LIBMEMCACHED_PIDFILE} | xargs kill; \
-		       rm ${LIBMEMCACHED_PIDFILE}
-
-noinst_PROGRAMS += tests/memcached_test
-endif
-endif
-
 tests_memcached_test_SOURCES= tests/memcached_test.cc
 tests_memcached_test_LDADD= ${CLIENT_LDADD}
 
-if HAVE_LIBSQLITE3
-SQLITE_TEST= tests/sqlite_test
-QUEUE_REGRESSION_TEST= tests/queue_regression
-CLEANFILES+= tests/gearman.sql tests/gearman.sql-journal tests/gearmand.log*
-noinst_PROGRAMS += tests/sqlite_test tests/queue_regression
-endif
-
-tests_sqlite_test_SOURCES= tests/sqlite_test.cc
-tests_sqlite_test_LDADD= ${CLIENT_LDADD}
-
 tests_queue_regression_SOURCES= tests/queue_regression.cc
 tests_queue_regression_LDADD= ${CLIENT_LDADD}
 
-if HAVE_LIBTOKYOCABINET
-TOKYOCABINET_TEST= tests/tokyocabinet_test
-TOKYOCABINET_RM= @rm -f tests/gearman.tcb
-CLEANFILES+= tests/gearman.tcb
-noinst_PROGRAMS += tests/tokyocabinet_test
-endif
-
-if HAVE_LIBDRIZZLE
-DRIZZLE_TEST= tests/drizzle_test
-noinst_PROGRAMS += tests/drizzle_test
-endif
-
-tests_tokyocabinet_test_SOURCES= tests/tokyocabinet_test.cc
-tests_tokyocabinet_test_LDADD= ${CLIENT_LDADD}
-
-tests_drizzle_test_SOURCES= tests/drizzle_test.cc
-tests_drizzle_test_LDADD= ${CLIENT_LDADD}
-
 noinst_PROGRAMS+= \
 		  tests/burnin_test \
 		  tests/client_test \
@@ -113,46 +71,11 @@ test-worker:
 test-internals:
 	@tests/internals_test $(ARG1) $(ARG2)
 
-test-libmemcached:
-if HAVE_LIBMEMCACHED
-if HAVE_MEMCACHED
-	$(LIBMEMCACHED_SETUP)
-	$(LIBMEMCACHED_TEST) $(ARG1) $(ARG2)
-	$(LIBMEMCACHED_TEARDOWN)
-endif
-endif
-
-queue-regression:
-if HAVE_LIBSQLITE3
-	$(QUEUE_REGRESSION_TEST) $(ARG1) $(ARG2)
-endif
-
-test-sqlite:
-if HAVE_LIBSQLITE3
-	$(SQLITE_TEST) $(ARG1) $(ARG2)
-endif
-
-gdb-sqlite:
-if HAVE_LIBSQLITE3
-	$(LIBTOOL) --mode=execute gdb tests/sqlite_test
-endif
-
-test-tokyocabinet:
-if HAVE_LIBTOKYOCABINET
-	$(TOKYOCABINET_TEST) $(ARG1) $(ARG2)
-	$(TOKYOCABINET_RM)
-endif
-
-test-drizzle:
-if HAVE_LIBDRIZZLE
-	$(DRIZZLE_TEST) $(ARG1) $(ARG2)
-endif
-
 GEARADMIN_TOOL= bin/gearadmin
 test-shutdown: bin/gearadmin
 	$(GEARADMIN_TOOL) --port 32123 --shutdown 2>&1 > /dev/null
 
-check-local: tests/var test-shutdown test-client test-round-robin test-worker test-internals test-libmemcached test-sqlite test-tokyocabinet test-burnin queue-regression
+check-local: gearmand-test-args tests/var test-shutdown test-client test-round-robin test-worker test-internals test-libmemcached test-sqlite test-tokyocabinet test-burnin queue-regression
 
 gdb-client: ${noinst_PROGRAMS}
 	$(LIBTOOL) --mode=execute gdb tests/client_test
@@ -183,42 +106,6 @@ valgrind-libmemcached:
 	$(VALGRIND_COMMAND) $(LIBMEMCACHED_TEST) $(ARG1) $(ARG2)
 	$(LIBMEMCACHED_TEARDOWN)
 
-valgrind-sqlite:
-if HAVE_LIBSQLITE3
-	$(VALGRIND_COMMAND) $(SQLITE_TEST) $(ARG1) $(ARG2)
-endif
-
-valgrind-tokyocabinet:
-if HAVE_LIBTOKYOCABINET
-	$(VALGRIND_COMMAND) $(TOKYOCABINET_TEST) $(ARG1) $(ARG2)
-	$(TOKYOCABINET_RM)
-endif
-
-GEARMAN_CLIENT_TEST= bin/gearman
-GEARMAN_VALGRIND_CLIENT_TEST= $(VALGRIND_COMMAND) bin/gearman
-GEARMAN_PIDFILE = ${abs_top_builddir}/tests/Xugear.pid
-
-client-test: $(GEARMAN_CLIENT_TEST)
-	@$(GEARMAN_CLIENT_TEST) -H 2>&1 > /dev/null
-	@$(GEARMAN_CLIENT_TEST) -w -f true -d -i $(GEARMAN_PIDFILE) -- false
-	cat $(GEARMAN_PIDFILE) | xargs kill
-	@echo "gearman client success"
-
-client-test-wc: $(GEARMAN_CLIENT_TEST)
-	@echo "1" > ${abs_top_builddir}/tests/test_file 
-	@$(GEARMAN_CLIENT_TEST) -w -f wc -d -i $(GEARMAN_PIDFILE) -- wc -l
-	@$(GEARMAN_CLIENT_TEST) -f wc < ${abs_top_builddir}/tests/test_file > ${abs_top_builddir}/tests/out_file
-	diff -q ${abs_top_builddir}/tests/test_file  ${abs_top_builddir}/tests/out_file
-	rm ${abs_top_builddir}/tests/test_file  ${abs_top_builddir}/tests/out_file
-	cat $(GEARMAN_PIDFILE) | xargs kill
-	@echo "gearman client success"
-
-valgrind-client-test: $(GEARMAN_CLIENT_TEST)
-		      @$(GEARMAN_VALGRIND_CLIENT_TEST) -H 2>&1 > /dev/null
-		      @$(GEARMAN_CLIENT_TEST) -w -f true -d -i $(GEARMAN_PIDFILE) -- false
-		      cat $(GEARMAN_PIDFILE) | xargs kill
-		      @echo "gearman client success"
-
 tests/var: tests/var/log tests/var/tmp
 	$(mkdir_p) tests/var
 
@@ -228,9 +115,14 @@ tests/var/log:
 tests/var/tmp:
 	$(mkdir_p) tests/var/tmp
 
-#valgrind: ${noinst_PROGRAMS} valgrind-client valgrind-worker valgrind-internals valgrind-sqlite valgrind-tokyocabinet
-
 valgrind: ${noinst_PROGRAMS} valgrind-client valgrind-round-robin valgrind-worker valgrind-internals valgrind-sqlite valgrind-tokyocabinet
 
+include tests/httpd.am
+include tests/libdrizzle.am
+include tests/libmemcached.am
+include tests/postgres.am
+include tests/sqlite.am
+include tests/tokyocabinet.am
+
 bogus:
 

+ 31 - 0
tests/libdrizzle.am

@@ -0,0 +1,31 @@
+# vim:ft=automake
+# Gearman server and library
+# Copyright (C) 2011 Data Differential, http://datadifferential.com/
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license.  See
+# the COPYING file in the parent directory for full text.
+#
+# Included from Top Level Makefile.am
+# All paths should be given relative to the root
+#
+
+test-drizzle: test-libdrizzle-args test-drizzle-queue
+
+tests-libdrizzle-args: gearmand/gearmand
+if HAVE_LIBDRIZZLE
+	@gearmand/gearmand --check-args --libdrizzle-host=localhost --libdrizzle-port=90 --libdrizzle-uds=tmp/foo.socket --libdrizzle-user=root --libdrizzle-password=test --libdrizzle-db=gearman --libdrizzle-table=gearman --libdrizzle-mysql
+endif
+
+test-drizzle-queue: gearmand/gearmand
+if HAVE_LIBDRIZZLE
+	$(DRIZZLE_TEST) $(ARG1) $(ARG2)
+endif
+
+if HAVE_LIBDRIZZLE
+DRIZZLE_TEST= tests/drizzle_test
+noinst_PROGRAMS += tests/drizzle_test
+endif
+
+tests_drizzle_test_SOURCES= tests/drizzle_test.cc
+tests_drizzle_test_LDADD= ${CLIENT_LDADD}

+ 42 - 0
tests/libmemcached.am

@@ -0,0 +1,42 @@
+# vim:ft=automake
+# Gearman server and library
+# Copyright (C) 2011 Data Differential, http://datadifferential.com/
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license.  See
+# the COPYING file in the parent directory for full text.
+#
+# Included from Top Level Makefile.am
+# All paths should be given relative to the root
+#
+
+test-libmemcached: test-libmemcached-queue test-libmemcached-queue 
+
+tests-libmemcached-args: gearmand/gearmand
+if HAVE_LIBMEMCACHED
+	@gearmand/gearmand --http-port=80
+endif
+
+if HAVE_LIBMEMCACHED
+if HAVE_MEMCACHED
+LIBMEMCACHED_PIDFILE = ${abs_top_builddir}/tests/Xumemc.pid
+LIBMEMCACHED_TEST= tests/memcached_test
+# Note, SETUP should do a test for existance and then kill if it exists.
+LIBMEMCACHED_SETUP= @$(MEMCACHED_BINARY) -d -u root -P ${LIBMEMCACHED_PIDFILE} -p 12555
+LIBMEMCACHED_TEARDOWN= @\
+		       cat ${LIBMEMCACHED_PIDFILE} | xargs kill; \
+		       rm ${LIBMEMCACHED_PIDFILE}
+
+noinst_PROGRAMS += tests/memcached_test
+endif
+endif
+
+
+test-libmemcached-queue:
+if HAVE_LIBMEMCACHED
+if HAVE_MEMCACHED
+	$(LIBMEMCACHED_SETUP)
+	$(LIBMEMCACHED_TEST) $(ARG1) $(ARG2)
+	$(LIBMEMCACHED_TEARDOWN)
+endif
+endif

+ 18 - 0
tests/postgres.am

@@ -0,0 +1,18 @@
+# vim:ft=automake
+# Gearman server and library
+# Copyright (C) 2011 Data Differential, http://datadifferential.com/
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license.  See
+# the COPYING file in the parent directory for full text.
+#
+# Included from Top Level Makefile.am
+# All paths should be given relative to the root
+#
+
+test-postgres: tests-postgres-args
+
+tests-postgres-args: gearmand/gearmand
+if HAVE_LIBPQ
+	@gearmand/gearmand --libpq-conninfo="foo" --libpq-table="gearmand"
+endif

+ 49 - 0
tests/sqlite.am

@@ -0,0 +1,49 @@
+# vim:ft=automake
+# Gearman server and library
+# Copyright (C) 2011 Data Differential, http://datadifferential.com/
+# All rights reserved.
+#
+# Use and distribution licensed under the BSD license.  See
+# the COPYING file in the parent directory for full text.
+#
+# Included from Top Level Makefile.am
+# All paths should be given relative to the root
+#
+
+test-sqlite: tests-sqlite-args test-sqlite-queue
+
+tests-sqlite-args: gearmand/gearmand
+if HAVE_LIBSQLITE3
+	@gearmand/gearmand --check-args --libsqlite3-db=tmp/schema --libsqlite3-table=tmp/table
+
+endif
+
+if HAVE_LIBSQLITE3
+SQLITE_TEST= tests/sqlite_test
+QUEUE_REGRESSION_TEST= tests/queue_regression
+CLEANFILES+= tests/gearman.sql tests/gearman.sql-journal tests/gearmand.log*
+noinst_PROGRAMS += tests/sqlite_test tests/queue_regression
+endif
+
+tests_sqlite_test_SOURCES= tests/sqlite_test.cc
+tests_sqlite_test_LDADD= ${CLIENT_LDADD}
+
+queue-regression:
+if HAVE_LIBSQLITE3
+	$(QUEUE_REGRESSION_TEST) $(ARG1) $(ARG2)
+endif
+
+test-sqlite-queue:
+if HAVE_LIBSQLITE3
+	$(SQLITE_TEST) $(ARG1) $(ARG2)
+endif
+
+gdb-sqlite:
+if HAVE_LIBSQLITE3
+	$(LIBTOOL) --mode=execute gdb tests/sqlite_test
+endif
+
+valgrind-sqlite:
+if HAVE_LIBSQLITE3
+	$(VALGRIND_COMMAND) $(SQLITE_TEST) $(ARG1) $(ARG2)
+endif

Some files were not shown because too many files changed in this diff