mirror of
https://github.com/samba-team/samba.git
synced 2025-02-05 21:57:51 +03:00
tests: Remove unused test program ctdb_fetch_lock_once
Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 873b9cadbcc363a9e5f450b0a1feb1cf2ce1e6c9)
This commit is contained in:
parent
f165ed1594
commit
2814c9a0c5
@ -112,7 +112,6 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o \
|
||||
$(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) @INFINIBAND_WRAPPER_OBJ@
|
||||
|
||||
TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \
|
||||
tests/bin/ctdb_fetch_lock_once \
|
||||
tests/bin/ctdb_fetch_readonly_once tests/bin/ctdb_fetch_readonly_loop \
|
||||
tests/bin/ctdb_store tests/bin/ctdb_trackingdb_test \
|
||||
tests/bin/ctdb_randrec tests/bin/ctdb_persistent \
|
||||
@ -239,13 +238,9 @@ tests/bin/ctdb_fetch_one: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch_one.o
|
||||
@echo Linking $@
|
||||
$(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_one.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
|
||||
|
||||
tests/bin/ctdb_fetch_lock_once: libctdb/libctdb.a tests/src/ctdb_fetch_lock_once.o $(CTDB_EXTERNAL_OBJ)
|
||||
tests/bin/ctdb_fetch_readonly_once: tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ)
|
||||
@echo Linking $@
|
||||
$(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_lock_once.o $(CTDB_EXTERNAL_OBJ) libctdb/libctdb.a $(LIB_FLAGS)
|
||||
|
||||
tests/bin/ctdb_fetch_readonly_once: libctdb/libctdb.a tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ)
|
||||
@echo Linking $@
|
||||
$(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) libctdb/libctdb.a $(LIB_FLAGS)
|
||||
$(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_readonly_once.o $(CTDB_EXTERNAL_OBJ) $(LIB_FLAGS)
|
||||
|
||||
tests/bin/ctdb_fetch_readonly_loop: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch_readonly_loop.o
|
||||
@echo Linking $@
|
||||
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
simple ctdb test tool
|
||||
This test just fetch_locks a record and releases it once.
|
||||
|
||||
Copyright (C) Ronnie Sahlberg 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"
|
||||
#include "system/filesys.h"
|
||||
#include "popt.h"
|
||||
#include <poll.h>
|
||||
#include "ctdb.h"
|
||||
|
||||
#define TESTKEY "testkey"
|
||||
|
||||
static void rrl_cb(struct ctdb_db *ctdb_db,
|
||||
struct ctdb_lock *lock, TDB_DATA outdata, void *private)
|
||||
{
|
||||
bool *rrl_cb_called = private;
|
||||
|
||||
printf("Record fetchlocked.\n");
|
||||
printf("Press enter to release the record ...\n");
|
||||
(void)getchar();
|
||||
printf("Record released.\n");
|
||||
|
||||
*rrl_cb_called = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
Just try locking/unlocking a single record once
|
||||
*/
|
||||
static void fetch_lock_once(struct ctdb_connection *ctdb, struct ctdb_db *ctdb_db)
|
||||
{
|
||||
TDB_DATA key;
|
||||
bool rrl_cb_finished = false;
|
||||
|
||||
key.dptr = discard_const(TESTKEY);
|
||||
key.dsize = strlen(TESTKEY);
|
||||
|
||||
printf("Trying to fetch lock the record ...\n");
|
||||
|
||||
/* In the non-contended case the callback might be invoked
|
||||
* immediately, before ctdb_readrecordlock_async() returns.
|
||||
* In the contended case the callback will be invoked later.
|
||||
*
|
||||
* Normally an application would not care whether the callback
|
||||
* has already been invoked here or not, but if the application
|
||||
* needs to know, it can use the *private_data pointer
|
||||
* to pass data through to the callback and back.
|
||||
*/
|
||||
if (!ctdb_readrecordlock_async(ctdb_db, key,
|
||||
rrl_cb, &rrl_cb_finished)) {
|
||||
printf("Failed to send READRECORDLOCK\n");
|
||||
exit(10);
|
||||
}
|
||||
while (!rrl_cb_finished) {
|
||||
struct pollfd pfd;
|
||||
|
||||
pfd.fd = ctdb_get_fd(ctdb);
|
||||
pfd.events = ctdb_which_events(ctdb);
|
||||
if (poll(&pfd, 1, -1) < 0) {
|
||||
printf("Poll failed");
|
||||
exit(10);
|
||||
}
|
||||
if (ctdb_service(ctdb, pfd.revents) < 0) {
|
||||
printf("Failed to service\n");
|
||||
exit(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
main program
|
||||
*/
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
struct ctdb_connection *ctdb;
|
||||
struct ctdb_db *ctdb_db;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
POPT_AUTOHELP
|
||||
POPT_TABLEEND
|
||||
};
|
||||
int opt;
|
||||
const char **extra_argv;
|
||||
int extra_argc = 0;
|
||||
poptContext pc;
|
||||
|
||||
pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
|
||||
|
||||
while ((opt = poptGetNextOpt(pc)) != -1) {
|
||||
switch (opt) {
|
||||
default:
|
||||
fprintf(stderr, "Invalid option %s: %s\n",
|
||||
poptBadOption(pc, 0), poptStrerror(opt));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* setup the remaining options for the main program to use */
|
||||
extra_argv = poptGetArgs(pc);
|
||||
if (extra_argv) {
|
||||
extra_argv++;
|
||||
while (extra_argv[extra_argc]) extra_argc++;
|
||||
}
|
||||
|
||||
ctdb = ctdb_connect("/tmp/ctdb.socket",
|
||||
ctdb_log_file, stderr);
|
||||
if (!ctdb) {
|
||||
printf("Connecting to /tmp/ctdb.socket\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* attach to a specific database */
|
||||
ctdb_db = ctdb_attachdb(ctdb, "test.tdb", false, 0);
|
||||
if (!ctdb_db) {
|
||||
printf("ctdb_attachdb failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Waiting for cluster\n");
|
||||
while (1) {
|
||||
uint32_t recmode=1;
|
||||
ctdb_getrecmode(ctdb, CTDB_CURRENT_NODE, &recmode);
|
||||
if (recmode == 0) break;
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
fetch_lock_once(ctdb, ctdb_db);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user