The branch, master has been updated
via 8353d47... s3: add dbwrap_torture - a tool to stress test tdb
transactions through dbwrap
via 63a801e... s3:torture: move the torture-specific headers to new
torture/torture.h
from 632e4af... s3:idmap_ldap: fix indentation: tab/space mixup
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 8353d47e9b2eda9d5711610b672a183eb414c6a3
Author: Michael Adam <[email protected]>
Date: Sat Nov 21 00:48:40 2009 +0100
s3: add dbwrap_torture - a tool to stress test tdb transactions through
dbwrap
This can be used to also test tdb transactions on clustered installations
throught ctdb. The test is modeled after the ctdb_transaction.c test program
from the ctdb source code. It runs transactions in a tight loop on a test
database called "transactions.tdb" (by default), increasing a counter in
each
iteration. In a clustered environment, a counter is maintained for each
node.
Michael
commit 63a801e5c931e401351b02445704800d1103417c
Author: Michael Adam <[email protected]>
Date: Fri Nov 20 17:47:21 2009 +0100
s3:torture: move the torture-specific headers to new torture/torture.h
Michael
-----------------------------------------------------------------------
Summary of changes:
source3/Makefile.in | 20 +++-
source3/include/proto.h | 55 -------
source3/torture/denytest.c | 1 +
source3/torture/mangle_test.c | 1 +
source3/torture/nbio.c | 1 +
source3/torture/scanner.c | 1 +
source3/torture/torture.c | 1 +
source3/torture/torture.h | 81 +++++++++
source3/torture/utable.c | 1 +
source3/utils/dbwrap_torture.c | 350 ++++++++++++++++++++++++++++++++++++++++
10 files changed, 456 insertions(+), 56 deletions(-)
create mode 100644 source3/torture/torture.h
create mode 100644 source3/utils/dbwrap_torture.c
Changeset truncated at 500 lines:
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 724c221..28be9d1 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -234,7 +234,8 @@ EVERYTHING_PROGS = bin/debug2h...@exeext@
bin/smbfil...@exeext@ \
$(TALLOCTORT) bin/replacet...@exeext@ \
bin/log2p...@exeext@ \
bin/v...@exeext@ bin/smbic...@exeext@ \
- bin/dbwrap_t...@exeext@
+ bin/dbwrap_t...@exeext@ \
+ bin/dbwrap_tort...@exeext@
PAM_MODULES = @PAM_MODULES@
@@ -1338,6 +1339,12 @@ DBWRAP_TOOL_OBJ = utils/dbwrap_tool.o \
$(LIB_NONSMBD_OBJ) \
$(LIBSAMBA_OBJ)
+DBWRAP_TORTURE_OBJ = utils/dbwrap_torture.o \
+ $(PARAM_OBJ) \
+ $(LIB_NONSMBD_OBJ) \
+ $(LIBSAMBA_OBJ) \
+ $(POPT_LIB_OBJ)
+
######################################################################
# now the rules...
######################################################################
@@ -2912,6 +2919,17 @@ bin/dbwrap_t...@exeext@: $(DBWRAP_TOOL_OBJ) $(LIBTALLOC)
$(LIBTDB)
install-dbwrap_tool:: bin/dbwrap_t...@exeext@
@$(SHELL) script/installbin.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix)
$(BINDIR) $<
+bin/dbwrap_tort...@exeext@: $(DBWRAP_TORTURE_OBJ) $(LIBTALLOC) $(LIBTDB)
+ @echo "Linking $@"
+ @$(CC) -o $@ $(DBWRAP_TORTURE_OBJ)\
+ $(LDFLAGS) $(DYNEEXP) $(LIBS) \
+ $(LDAP_LIBS) \
+ $(POPT_LIBS) \
+ $(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
+
+install-dbwrap_torture:: bin/dbwrap_tort...@exeext@
+ @$(SHELL) script/installbin.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(prefix)
$(BINDIR) $<
+
install:: installservers installbin @INSTALL_CIFSMOUNT@ @INSTALL_CIFSUMOUNT@
@INSTALL_CIFSUPCALL@ installman \
installscripts installdat installmodules @SWAT_INSTALL_TARGETS@
\
@INSTALL_PAM_MODULES@ installlibs installmo
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 88f6dd5..5b1ce74 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -7163,61 +7163,6 @@ int vfs_lstat_smb_fname(struct connection_struct *conn,
const char *fname,
SMB_STRUCT_STAT *psbuf);
NTSTATUS vfs_stat_fsp(files_struct *fsp);
-/* The following definitions come from torture/denytest.c */
-
-bool torture_denytest1(int dummy);
-bool torture_denytest2(int dummy);
-
-/* The following definitions come from torture/mangle_test.c */
-
-bool torture_mangle(int dummy);
-
-/* The following definitions come from torture/nbio.c */
-
-double nbio_total(void);
-void nb_alarm(int ignore);
-void nbio_shmem(int n);
-void nb_setup(struct cli_state *cli);
-void nb_unlink(const char *fname);
-void nb_createx(const char *fname,
- unsigned create_options, unsigned create_disposition, int
handle);
-void nb_writex(int handle, int offset, int size, int ret_size);
-void nb_readx(int handle, int offset, int size, int ret_size);
-void nb_close(int handle);
-void nb_rmdir(const char *fname);
-void nb_rename(const char *oldname, const char *newname);
-void nb_qpathinfo(const char *fname);
-void nb_qfileinfo(int fnum);
-void nb_qfsinfo(int level);
-void nb_findfirst(const char *mask);
-void nb_flush(int fnum);
-void nb_deltree(const char *dname);
-void nb_cleanup(void);
-
-/* The following definitions come from torture/scanner.c */
-
-bool torture_trans2_scan(int dummy);
-bool torture_nttrans_scan(int dummy);
-
-/* The following definitions come from torture/torture.c */
-
-void start_timer(void);
-double end_timer(void);
-void *shm_setup(int size);
-bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
- char **hostname, char **sharename);
-void torture_open_connection_free_unclist(char **unc_list);
-bool torture_open_connection(struct cli_state **c, int conn_index);
-bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid);
-bool torture_close_connection(struct cli_state *c);
-bool torture_ioctl_test(int dummy);
-bool torture_chkpath_test(int dummy);
-
-/* The following definitions come from torture/utable.c */
-
-bool torture_utable(int dummy);
-bool torture_casetable(int dummy);
-
/* The following definitions come from utils/passwd_util.c */
char *stdin_new_passwd( void);
diff --git a/source3/torture/denytest.c b/source3/torture/denytest.c
index 66a1c9f..bf491bc 100644
--- a/source3/torture/denytest.c
+++ b/source3/torture/denytest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "torture.h"
extern bool torture_showall;
diff --git a/source3/torture/mangle_test.c b/source3/torture/mangle_test.c
index 34c908e..e5f6947 100644
--- a/source3/torture/mangle_test.c
+++ b/source3/torture/mangle_test.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "torture.h"
extern int torture_numops;
diff --git a/source3/torture/nbio.c b/source3/torture/nbio.c
index bef54f7..5e7a458 100644
--- a/source3/torture/nbio.c
+++ b/source3/torture/nbio.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "torture.h"
#define MAX_FILES 1000
diff --git a/source3/torture/scanner.c b/source3/torture/scanner.c
index e42e80a..4d9ee28 100644
--- a/source3/torture/scanner.c
+++ b/source3/torture/scanner.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "torture.h"
#define VERBOSE 0
#define OP_MIN 0
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index bf89ca3..19103df 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include "nsswitch/libwbclient/wbc_async.h"
+#include "torture.h"
extern char *optarg;
extern int optind;
diff --git a/source3/torture/torture.h b/source3/torture/torture.h
new file mode 100644
index 0000000..353b98c
--- /dev/null
+++ b/source3/torture/torture.h
@@ -0,0 +1,81 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB torture tester - header file
+
+ Copyright (C) Andrew Tridgell 1997-1998
+ Copyright (C) Jeremy Allison 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TORTURE_H__
+#define __TORTURE_H__
+
+/* The following definitions come from torture/denytest.c */
+
+bool torture_denytest1(int dummy);
+bool torture_denytest2(int dummy);
+
+/* The following definitions come from torture/mangle_test.c */
+
+bool torture_mangle(int dummy);
+
+/* The following definitions come from torture/nbio.c */
+
+double nbio_total(void);
+void nb_alarm(int ignore);
+void nbio_shmem(int n);
+void nb_setup(struct cli_state *cli);
+void nb_unlink(const char *fname);
+void nb_createx(const char *fname,
+ unsigned create_options, unsigned create_disposition, int
handle);
+void nb_writex(int handle, int offset, int size, int ret_size);
+void nb_readx(int handle, int offset, int size, int ret_size);
+void nb_close(int handle);
+void nb_rmdir(const char *fname);
+void nb_rename(const char *oldname, const char *newname);
+void nb_qpathinfo(const char *fname);
+void nb_qfileinfo(int fnum);
+void nb_qfsinfo(int level);
+void nb_findfirst(const char *mask);
+void nb_flush(int fnum);
+void nb_deltree(const char *dname);
+void nb_cleanup(void);
+
+/* The following definitions come from torture/scanner.c */
+
+bool torture_trans2_scan(int dummy);
+bool torture_nttrans_scan(int dummy);
+
+/* The following definitions come from torture/torture.c */
+
+void start_timer(void);
+double end_timer(void);
+void *shm_setup(int size);
+bool smbcli_parse_unc(const char *unc_name, TALLOC_CTX *mem_ctx,
+ char **hostname, char **sharename);
+void torture_open_connection_free_unclist(char **unc_list);
+bool torture_open_connection(struct cli_state **c, int conn_index);
+bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid);
+bool torture_close_connection(struct cli_state *c);
+bool torture_ioctl_test(int dummy);
+bool torture_chkpath_test(int dummy);
+
+/* The following definitions come from torture/utable.c */
+
+bool torture_utable(int dummy);
+bool torture_casetable(int dummy);
+
+#endif /* __TORTURE_H__ */
diff --git a/source3/torture/utable.c b/source3/torture/utable.c
index 1f75164..247642b 100644
--- a/source3/torture/utable.c
+++ b/source3/torture/utable.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "torture.h"
bool torture_utable(int dummy)
{
diff --git a/source3/utils/dbwrap_torture.c b/source3/utils/dbwrap_torture.c
new file mode 100644
index 0000000..2077eea
--- /dev/null
+++ b/source3/utils/dbwrap_torture.c
@@ -0,0 +1,350 @@
+/*
+ Samba Linux/Unix CIFS implementation
+
+ simple tool to test persistent databases
+
+ Copyright (C) Michael Adam 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+#if 0
+#include "lib/events/events.h"
+#include "system/filesys.h"
+#include "popt.h"
+#include "cmdline.h"
+
+#include <sys/time.h>
+#include <time.h>
+#endif
+
+extern bool AllowDebugChange;
+
+static struct timeval tp1,tp2;
+
+static void start_timer(void)
+{
+ gettimeofday(&tp1,NULL);
+}
+
+static double end_timer(void)
+{
+ gettimeofday(&tp2,NULL);
+ return (tp2.tv_sec + (tp2.tv_usec*1.0e-6)) -
+ (tp1.tv_sec + (tp1.tv_usec*1.0e-6));
+}
+
+#define DEFAULT_DB_NAME "transaction.tdb"
+
+static int timelimit = 10;
+static int delay = 0;
+static int verbose = 0;
+static int no_trans = 0;
+static char *db_name = (char *)discard_const(DEFAULT_DB_NAME);
+
+
+static unsigned int pnn;
+
+static TDB_DATA old_data;
+
+static int success = true;
+
+static void print_counters(void)
+{
+ int i;
+ uint32_t *old_counters;
+
+ printf("[%4u] Counters: ", getpid());
+ old_counters = (uint32_t *)old_data.dptr;
+ for (i=0; i < old_data.dsize/sizeof(uint32_t); i++) {
+ printf("%6u ", old_counters[i]);
+ }
+ printf("\n");
+}
+
+static void each_second(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval t,
+ void *private_data)
+{
+ struct db_context *db = talloc_get_type(private_data, struct
db_context);
+
+ print_counters();
+
+ tevent_add_timer(ev, db, timeval_current_ofs(1, 0), each_second, db);
+}
+
+static bool check_counters(struct db_context *db, TDB_DATA data)
+{
+ int i;
+ uint32_t *counters, *old_counters;
+
+ counters = (uint32_t *)data.dptr;
+ old_counters = (uint32_t *)old_data.dptr;
+
+ /* check that all the counters are monotonic increasing */
+ for (i=0; i < old_data.dsize/sizeof(uint32_t); i++) {
+ if (counters[i] < old_counters[i]) {
+ printf("[%4u] ERROR: counters has decreased for node %u
From %u to %u\n",
+ getpid(), i, old_counters[i], counters[i]);
+ success = false;
+ return false;
+ }
+ }
+
+ if (old_data.dsize != data.dsize) {
+ old_data.dsize = data.dsize;
+ old_data.dptr = (unsigned char*)talloc_realloc_size(db,
old_data.dptr, old_data.dsize);
+ }
+
+ memcpy(old_data.dptr, data.dptr, data.dsize);
+ if (verbose) print_counters();
+
+ return true;
+}
+
+
+static void do_sleep(unsigned int sec)
+{
+ unsigned int i;
+
+ if (sec == 0) {
+ return;
+ }
+
+ for (i=0; i<sec; i++) {
+ if (verbose) printf(".");
+ sleep(1);
+ }
+
+ if (verbose) printf("\n");
+}
+
+static void test_store_records(struct db_context *db, struct tevent_context
*ev)
+{
+ TDB_DATA key;
+ uint32_t *counters;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+
+ key.dptr = (unsigned char *)discard_const("testkey");
+ key.dsize = strlen((const char *)key.dptr)+1;
+
+ start_timer();
+ while ((timelimit == 0) || (end_timer() < timelimit)) {
+ struct db_record *rec;
+ TDB_DATA data;
+ int ret;
+ NTSTATUS status;
+
+ if (!no_trans) {
+ if (verbose) DEBUG(1, ("starting transaction\n"));
+ ret = db->transaction_start(db);
+ if (ret != 0) {
+ DEBUG(0, ("Failed to start transaction on node "
+ "%d\n", pnn));
+ goto fail;
+ }
+ if (verbose) DEBUG(1, ("transaction started\n"));
+ do_sleep(delay);
+ }
+
+ if (verbose) DEBUG(1, ("calling fetch_lock\n"));
+ rec = db->fetch_locked(db, tmp_ctx, key);
+ if (rec == NULL) {
+ DEBUG(0, ("Failed to fetch record\n"));
+ goto fail;
+ }
+ if (verbose) DEBUG(1, ("fetched record ok\n"));
+ do_sleep(delay);
+
+ data.dsize = MAX(rec->value.dsize, sizeof(uint32_t) * (pnn+1));
+ data.dptr = (unsigned char *)talloc_zero_size(tmp_ctx,
+ data.dsize);
+ if (data.dptr == NULL) {
+ DEBUG(0, ("Failed to allocate data\n"));
+ goto fail;
+ }
+ memcpy(data.dptr, rec->value.dptr,rec->value.dsize);
+
+ counters = (uint32_t *)data.dptr;
+
+ /* bump our counter */
+ counters[pnn]++;
+
+ if (verbose) DEBUG(1, ("storing data\n"));
+ status = rec->store(rec, data, TDB_REPLACE);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to store record\n"));
+ if (!no_trans) {
+ ret = db->transaction_cancel(db);
+ if (ret != 0) {
+ DEBUG(0, ("Error cancelling
transaction.\n"));
+ }
+ }
+ goto fail;
+ }
+ talloc_free(rec);
+ if (verbose) DEBUG(1, ("stored data ok\n"));
+ do_sleep(delay);
+
+ if (!no_trans) {
+ if (verbose) DEBUG(1, ("calling transaction_commit\n"));
+ ret = db->transaction_commit(db);
+ if (ret != 0) {
+ DEBUG(0, ("Failed to commit transaction\n"));
+ goto fail;
+ }
+ if (verbose) DEBUG(1, ("transaction committed\n"));
+ }
+
+ /* store the counters and verify that they are sane */
+ if (verbose || (pnn == 0)) {
+ if (!check_counters(db, data)) {
+ goto fail;
+ }
+ }
+ talloc_free(data.dptr);
+
+ do_sleep(delay);
+ }
+
+ goto done;
--
Samba Shared Repository