xapian-core
1.4.26
|
tests of replication functionality More...
#include <config.h>
#include "api_replicate.h"
#include <xapian.h>
#include "api/replication.h"
#include "apitest.h"
#include "dbcheck.h"
#include "errno_to_string.h"
#include "fd.h"
#include "filetests.h"
#include "safedirent.h"
#include "safefcntl.h"
#include "safesysstat.h"
#include "safeunistd.h"
#include "setenv.h"
#include "testsuite.h"
#include "testutils.h"
#include "unixcmds.h"
#include <sys/types.h>
#include <cerrno>
#include <cstdlib>
#include <string>
Go to the source code of this file.
Classes | |
struct | unset_max_changesets_helper_ |
Macros | |
#define | set_max_changesets(N) setenv("XAPIAN_MAX_CHANGESETS", #N, 1) |
#define | UNSET_MAX_CHANGESETS_AFTERWARDS unset_max_changesets_helper_ ezlxq |
Functions | |
static void | rmtmpdir (const string &path) |
static void | mktmpdir (const string &path) |
static off_t | get_file_size (const string &path) |
static size_t | do_read (int fd, char *p, size_t desired) |
static void | do_write (int fd, const char *p, size_t n) |
static off_t | truncated_copy (const string &srcpath, const string &destpath, off_t tocopy) |
static void | get_changeset (const string &changesetpath, Xapian::DatabaseMaster &master, Xapian::DatabaseReplica &replica, int expected_changesets, int expected_fullcopies, bool expected_changed, bool full_copy=false) |
static int | apply_changeset (const string &changesetpath, Xapian::DatabaseReplica &replica, int expected_changesets, int expected_fullcopies, bool expected_changed) |
static int | replicate (Xapian::DatabaseMaster &master, Xapian::DatabaseReplica &replica, const string &tempdir, int expected_changesets, int expected_fullcopies, bool expected_changed, bool full_copy=false) |
static void | check_equal_dbs (const string &masterpath, const string &replicapath) |
DEFINE_TESTCASE (replicate1, replicas) | |
DEFINE_TESTCASE (replicate2, replicas) | |
static void | replicate_with_brokenness (Xapian::DatabaseMaster &master, Xapian::DatabaseReplica &replica, const string &tempdir, int expected_changesets, int expected_fullcopies, bool expected_changed) |
DEFINE_TESTCASE (replicate3, replicas) | |
DEFINE_TESTCASE (replicate4, replicas) | |
DEFINE_TESTCASE (replicate5, replicas) | |
DEFINE_TESTCASE (replicate6, replicas) | |
Test –full-copy option. More... | |
DEFINE_TESTCASE (replicate7, replicas) | |
Test healing a corrupt replica (new in 1.3.5). More... | |
tests of replication functionality
Definition in file api_replicate.cc.
#define set_max_changesets | ( | N | ) | setenv("XAPIAN_MAX_CHANGESETS", #N, 1) |
Definition at line 239 of file api_replicate.cc.
Referenced by DEFINE_TESTCASE(), and unset_max_changesets_helper_::~unset_max_changesets_helper_().
#define UNSET_MAX_CHANGESETS_AFTERWARDS unset_max_changesets_helper_ ezlxq |
Definition at line 248 of file api_replicate.cc.
Referenced by DEFINE_TESTCASE().
|
static |
Definition at line 164 of file api_replicate.cc.
References Xapian::DatabaseReplica::apply_next_changeset(), Xapian::ReplicationInfo::changed, Xapian::ReplicationInfo::changeset_count, FAIL_TEST, Xapian::ReplicationInfo::fullcopy_count, O_BINARY, Xapian::InMemory::open(), Xapian::DatabaseReplica::set_read_fd(), and TEST_EQUAL.
Referenced by replicate(), and replicate_with_brokenness().
|
static |
Definition at line 224 of file api_replicate.cc.
References Xapian::Database::allterms_begin(), Xapian::Database::allterms_end(), dbcheck(), Xapian::Database::get_doccount(), Xapian::Database::get_lastdocid(), Xapian::Database::get_uuid(), postlist_to_string(), and TEST_EQUAL.
Referenced by DEFINE_TESTCASE().
DEFINE_TESTCASE | ( | replicate1 | , |
replicas | |||
) |
Definition at line 256 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), Xapian::Database::check(), check_equal_dbs(), Xapian::WritableDatabase::commit(), get_named_writable_database(), get_named_writable_database_path(), Xapian::Database::get_uuid(), mktmpdir(), replicate(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate2 | , |
replicas | |||
) |
Definition at line 335 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), check_equal_dbs(), Xapian::Database::close(), Xapian::WritableDatabase::commit(), get_named_writable_database(), get_named_writable_database_path(), get_writable_database_again(), mktmpdir(), replicate(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, SKIP_TEST_FOR_BACKEND, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate3 | , |
replicas | |||
) |
Definition at line 480 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), check_equal_dbs(), Xapian::WritableDatabase::commit(), get_named_writable_database(), get_named_writable_database_path(), mktmpdir(), replicate(), replicate_with_brokenness(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate4 | , |
replicas | |||
) |
Definition at line 531 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), Xapian::Document::add_term(), check_equal_dbs(), Xapian::WritableDatabase::commit(), file_exists(), get_dbtype(), get_named_writable_database(), get_named_writable_database_path(), Xapian::Database::get_uuid(), mktmpdir(), replicate(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, TEST, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate5 | , |
replicas | |||
) |
Definition at line 629 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), Xapian::Document::add_term(), check_equal_dbs(), Xapian::WritableDatabase::commit(), file_exists(), get_named_writable_database(), get_named_writable_database_path(), Xapian::Database::get_uuid(), mktmpdir(), replicate(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, SKIP_TEST_FOR_BACKEND, TEST, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate6 | , |
replicas | |||
) |
Test –full-copy option.
Definition at line 761 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), check_equal_dbs(), Xapian::WritableDatabase::commit(), cp_R(), get_named_writable_database(), get_named_writable_database_path(), Xapian::Database::get_uuid(), mktmpdir(), replicate(), rm_rf(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
DEFINE_TESTCASE | ( | replicate7 | , |
replicas | |||
) |
Test healing a corrupt replica (new in 1.3.5).
Definition at line 827 of file api_replicate.cc.
References Xapian::WritableDatabase::add_document(), Xapian::Document::add_posting(), check_equal_dbs(), close(), closedir(), Xapian::WritableDatabase::commit(), dirent::d_name, errno_to_string(), FAIL_TEST, get_named_writable_database(), get_named_writable_database_path(), Xapian::Database::get_uuid(), mktmpdir(), Xapian::InMemory::open(), opendir(), readdir(), replicate(), rmtmpdir(), Xapian::Document::set_data(), set_max_changesets, TEST, TEST_EQUAL, and UNSET_MAX_CHANGESETS_AFTERWARDS.
|
static |
Definition at line 75 of file api_replicate.cc.
References FAIL_TEST.
Referenced by truncated_copy().
|
static |
Definition at line 92 of file api_replicate.cc.
References FAIL_TEST.
Referenced by truncated_copy().
|
static |
Definition at line 140 of file api_replicate.cc.
References Xapian::ReplicationInfo::changed, Xapian::ReplicationInfo::changeset_count, FAIL_TEST, Xapian::ReplicationInfo::fullcopy_count, Xapian::DatabaseReplica::get_revision_info(), O_BINARY, Xapian::InMemory::open(), TEST_EQUAL, and Xapian::DatabaseMaster::write_changesets_to_fd().
Referenced by replicate(), and replicate_with_brokenness().
|
static |
Definition at line 67 of file api_replicate.cc.
References FAIL_TEST, and file_size().
Referenced by replicate_with_brokenness().
|
static |
Definition at line 60 of file api_replicate.cc.
References FAIL_TEST, and rmtmpdir().
Referenced by DEFINE_TESTCASE().
|
static |
Definition at line 202 of file api_replicate.cc.
References apply_changeset(), and get_changeset().
Referenced by DEFINE_TESTCASE().
|
static |
Definition at line 439 of file api_replicate.cc.
References apply_changeset(), get_changeset(), get_file_size(), TEST_EQUAL, TEST_EXCEPTION, tout, and truncated_copy().
Referenced by DEFINE_TESTCASE().
|
static |
Definition at line 56 of file api_replicate.cc.
References rm_rf().
Referenced by DEFINE_TESTCASE(), and mktmpdir().
|
static |
Definition at line 107 of file api_replicate.cc.
References close(), do_read(), do_write(), FAIL_TEST, O_BINARY, and Xapian::InMemory::open().
Referenced by replicate_with_brokenness().