[MDS/DeadLock] remove uniittest file included in src dir

This commit is contained in:
fengdeyiji
2023-08-30 08:10:49 +00:00
committed by ob-robot
parent b9d0639eb7
commit 0528277691
22 changed files with 7 additions and 27 deletions

View File

@ -1,13 +0,0 @@
#ifndef UNITTEST_STORAGE_MULTI_DATA_SOURCE_COMMON_DEFINE_H
#define UNITTEST_STORAGE_MULTI_DATA_SOURCE_COMMON_DEFINE_H
#include "src/share/scn.h"
#include "example_user_data_define.h"
namespace oceanbase {
namespace unittest {
inline share::SCN mock_scn(int64_t val) { share::SCN scn; scn.convert_for_gts(val); return scn; }
}
}
#endif

View File

@ -1,130 +0,0 @@
#ifndef UNITTEST_SHARE_MULTI_DATA_SOURCE_EXAMPLE_USER_DATA_DEFINE_H
#define UNITTEST_SHARE_MULTI_DATA_SOURCE_EXAMPLE_USER_DATA_DEFINE_H
#include "lib/ob_errno.h"
#include "lib/utility/ob_print_utils.h"
#include "lib/utility/ob_unify_serialize.h"
#include "lib/utility/serialization.h"
#include "meta_programming/ob_meta_serialization.h"
#include "common_define.h"
namespace oceanbase {
namespace unittest {
struct ExampleUserKey {
OB_UNIS_VERSION(1);
public:
ExampleUserKey() : value_(0) {}
ExampleUserKey(const int val) : value_(val) {}
TO_STRING_KV(K_(value));
bool operator<(const ExampleUserKey &rhs) const { return value_ < rhs.value_; }
bool operator==(const ExampleUserKey &rhs) const { return value_ == rhs.value_; }
int64_t value_;
};
OB_SERIALIZE_MEMBER_TEMP(inline, ExampleUserKey, value_);
struct ExampleUserData1 {// simple data structure
OB_UNIS_VERSION(1);
public:
bool operator==(const ExampleUserData1 &rhs) const { return value_ == rhs.value_; }
ExampleUserData1() : value_(0) {}
ExampleUserData1(const int val) : value_(val) {}
TO_STRING_KV(K_(value));
int value_;
};
OB_SERIALIZE_MEMBER_TEMP(inline, ExampleUserData1, value_);
struct ExampleUserData2 {// complicated data structure
public:
ExampleUserData2() : alloc_(nullptr) {}
~ExampleUserData2() {
if (OB_NOT_NULL(alloc_)) {
if (!data_.empty()) {
alloc_->free(data_.ptr());
}
}
}
int serialize(char *buf, const int64_t buf_len, int64_t &pos) const {
int ret = OB_SUCCESS;
if (OB_ISNULL(alloc_)) {
} else if (OB_FAIL(serialization::encode(buf, buf_len, pos, (int64_t)data_.length()))) {
} else {
for (int64_t idx = 0; idx < data_.length() && OB_SUCC(ret); ++idx) {
ret = serialization::encode(buf, buf_len, pos, data_.ptr()[idx]);
}
}
return ret;
}
int deserialize(ObIAllocator &alloc, const char *buf, const int64_t buf_len, int64_t &pos) {
int ret = OB_SUCCESS;
int64_t length = 0;
char *buffer = nullptr;
if (OB_FAIL(serialization::decode(buf, buf_len, pos, length))) {
} else if (OB_ISNULL(buffer = (char *)alloc.alloc(length))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
for (int64_t idx = 0; idx < length && OB_SUCC(ret); ++idx) {
ret = serialization::decode(buf, buf_len, pos, buffer[idx]);
}
if (OB_SUCC(ret)) {
data_.assign(buffer, length);
alloc_ = &alloc;
}
}
return ret;
}
int64_t get_serialize_size() const {
int64_t total_size = 0;
total_size += serialization::encoded_length((int64_t)data_.length());
for (int64_t idx = 0; idx < data_.length(); ++idx) {
total_size += serialization::encoded_length(data_.ptr()[idx]);
}
return total_size;
}
int assign(ObIAllocator &alloc, const char *str) {
int ret = OB_SUCCESS;
OB_ASSERT(OB_ISNULL(alloc_) && data_.empty());
int64_t len = strlen(str);
char *buffer = nullptr;
if (OB_ISNULL(buffer = (char *)alloc.alloc(len))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
memcpy(buffer, str, len);
alloc_ = &alloc;
data_.assign(buffer, len);
}
return ret;
}
int assign(ObIAllocator &alloc, const ExampleUserData2 &rhs) {
int ret = OB_SUCCESS;
if (OB_NOT_NULL(rhs.alloc_)) {
OB_ASSERT(OB_ISNULL(alloc_) && data_.empty());
int64_t len = rhs.data_.length();
char *buffer = nullptr;
if (OB_ISNULL(buffer = (char *)alloc.alloc(len))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
memcpy(buffer, rhs.data_.ptr(), len);
alloc_ = &alloc;
data_.assign(buffer, len);
}
}
return ret;
}
// support move semantic
ExampleUserData2(ExampleUserData2 &&rhs) {
if (OB_NOT_NULL(rhs.alloc_)) {
data_ = rhs.data_;
alloc_ = rhs.alloc_;
rhs.alloc_ = nullptr;
rhs.data_.reset();
MDS_LOG(INFO, "call move construction", K(*this));
}
}
TO_STRING_KV(KP(data_.ptr()), K(data_.length()));
ObIAllocator *alloc_;
ObString data_;
};
}
}
#endif

View File

@ -1,123 +0,0 @@
#ifdef TEST_MDS_TRANSACTION
#include "example_user_helper_define.h"
#include "storage/multi_data_source/mds_table_handle.h"
namespace oceanbase {
namespace unittest {
using namespace storage;
using namespace mds;
MdsTableHandle TestMdsTable;
const storage::mds::MdsWriter ExampleUserHelperCtx::get_writer() const
{
return storage::mds::MdsWriter(transaction::ObTransID(0));
}
int ExampleUserHelperFunction1::on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
int64_t test_value;
int64_t pos = 0;
if (OB_FAIL(serialization::decode(buf, len, pos, test_value))) {
MDS_LOG(ERROR, "[UNITTEST] ExampleUserHelperFunction1 fail to deserialize", KR(ret));
} else {
MDS_LOG(INFO, "[UNITTEST] ExampleUserHelperFunction1 call on_register with helper", K(test_value));
}
return ret;
}
int ExampleUserHelperFunction1::on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx)
{
UNUSED(scn);
return on_register(buf, len, ctx);
}
int ExampleUserHelperFunction2::on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
int64_t test_value;
int64_t pos = 0;
if (OB_FAIL(serialization::decode(buf, len, pos, test_value))) {
MDS_LOG(ERROR, "[UNITTEST] ExampleUserHelperFunction2 fail to deserialize", KR(ret));
} else {
ExampleUserData1 data(test_value);
MdsCtx &mds_ctx = dynamic_cast<MdsCtx &>(ctx);
if (OB_FAIL(TestMdsTable.set(data, mds_ctx))) {
MDS_LOG(ERROR, "[UNITTEST] ExampleUserHelperFunction2 fail to set mdstable", KR(ret));
} else {
MDS_LOG(INFO, "[UNITTEST] ExampleUserHelperFunction2 call on_register with helper", K(test_value));
}
}
return ret;
}
int ExampleUserHelperFunction2::on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx)
{
UNUSED(scn);
return on_register(buf, len, ctx);
}
int ExampleUserHelperFunction3::on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
int64_t test_value;
int64_t pos = 0;
if (OB_FAIL(serialization::decode(buf, len, pos, test_value))) {
MDS_LOG(ERROR, "[UNITTEST] ExampleUserHelperFunction3 fail to deserialize", KR(ret));
} else {
MDS_LOG(INFO, "[UNITTEST] ExampleUserHelperFunction3 call on_register with helper", K(test_value));
}
return ret;
}
int ExampleUserHelperFunction3::on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx)
{
UNUSED(scn);
return on_register(buf, len, ctx);
}
void ExampleUserHelperCtx::on_redo(const share::SCN &)
{
MDS_LOG(INFO, "[UNITTEST] call on_redo with ctx", K(++call_times_));
}
void ExampleUserHelperCtx::before_prepare()
{
MDS_LOG(INFO, "[UNITTEST] call before_prepare with ctx", K(++call_times_));
}
void ExampleUserHelperCtx::on_prepare(const share::SCN &prepare_version)
{
MDS_LOG(INFO, "[UNITTEST] call on_prepare with ctx", K(++call_times_));
}
void ExampleUserHelperCtx::on_commit(const share::SCN &commit_version, const share::SCN &)
{
MDS_LOG(INFO, "[UNITTEST] call on_commit with ctx", K(++call_times_));
}
void ExampleUserHelperCtx::on_abort(const share::SCN &end_scn)
{
MDS_LOG(INFO, "[UNITTEST] call on_abort with ctx", K(++call_times_), K(end_scn));
}
}
}
#endif

View File

@ -1,151 +0,0 @@
#ifndef UNITTEST_SHARE_MULTI_DATA_SOURCE_EXAMPLE_USER_HELPER_DEFINE_H
#define UNITTEST_SHARE_MULTI_DATA_SOURCE_EXAMPLE_USER_HELPER_DEFINE_H
#include "storage/multi_data_source/buffer_ctx.h"
#include "lib/oblog/ob_log_module.h"
#include "lib/utility/serialization.h"
#include "share/scn.h"
#include "storage/multi_data_source/runtime_utility/common_define.h"
namespace oceanbase {
namespace unittest {
struct ExampleUserHelperFunction1 {
static int on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx); // 出参,将对应修改记录在Ctx中
static int on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx); // 备机回放
};
struct ExampleUserHelperFunction2 {
static int on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx); // 出参,将对应修改记录在Ctx中
static int on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx); // 备机回放
};
struct ExampleUserHelperFunction3 {
static int on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx); // 出参,将对应修改记录在Ctx中
static int on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx); // 备机回放
};
struct ExampleUserHelperCtx : public storage::mds::BufferCtx {
ExampleUserHelperCtx() : call_times_(0) {}
virtual const storage::mds::MdsWriter get_writer() const override;
virtual void on_redo(const share::SCN &redo_scn) override;
virtual void before_prepare() override;
virtual void on_prepare(const share::SCN &prepare_version) override;
virtual void on_commit(const share::SCN &commit_version, const share::SCN &scn) override;
virtual void on_abort(const share::SCN &scn) override;
int assign(const ExampleUserHelperCtx &rhs) {
call_times_ = rhs.call_times_;
return OB_SUCCESS;
}
int call_times_;// 这个类可以有自己的内部状态
virtual int64_t to_string(char*, const int64_t buf_len) const { return 0; }
// 同事务状态一起持久化以及恢复
virtual int serialize(char*, const int64_t, int64_t&) const { return OB_SUCCESS; }
virtual int deserialize(const char*, const int64_t, int64_t&) { return OB_SUCCESS; }
virtual int64_t get_serialize_size(void) const { return 0; }
};
#ifndef TEST_MDS_TRANSACTION
inline int ExampleUserHelperFunction1::on_register(const char* buf,
const int64_t len,
storage::mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
return ret;
}
inline int ExampleUserHelperFunction1::on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx)
{
int ret = OB_SUCCESS;
return ret;
}
inline int ExampleUserHelperFunction2::on_register(const char*,
const int64_t,
storage::mds::BufferCtx &)
{
int ret = OB_SUCCESS;
return ret;
}
inline int ExampleUserHelperFunction2::on_replay(const char*,
const int64_t,
const share::SCN &, // 日志scn
storage::mds::BufferCtx &)
{
int ret = OB_SUCCESS;
return ret;
}
inline int ExampleUserHelperFunction3::on_register(const char*,
const int64_t,
storage::mds::BufferCtx &)
{
int ret = OB_SUCCESS;
return ret;
}
inline int ExampleUserHelperFunction3::on_replay(const char* buf,
const int64_t len,
const share::SCN &scn, // 日志scn
storage::mds::BufferCtx &ctx)
{
UNUSED(scn);
return on_register(buf, len, ctx);
}
inline const storage::mds::MdsWriter ExampleUserHelperCtx::get_writer() const
{
return storage::mds::MdsWriter(storage::mds::WriterType::TRANSACTION, 1);
}
inline void ExampleUserHelperCtx::on_redo(const share::SCN &redo_scn)
{
MDS_LOG(INFO, "[UNITTEST] call on_redo with ctx", K(++call_times_));
}
inline void ExampleUserHelperCtx::before_prepare()
{
MDS_LOG(INFO, "[UNITTEST] call before_prepare with ctx", K(++call_times_));
}
inline void ExampleUserHelperCtx::on_prepare(const share::SCN &prepare_version)
{
MDS_LOG(INFO, "[UNITTEST] call on_prepare with ctx", K(++call_times_));
}
inline void ExampleUserHelperCtx::on_commit(const share::SCN &commit_version, const share::SCN &scn)
{
MDS_LOG(INFO, "[UNITTEST] call on_commit with ctx", K(++call_times_));
}
inline void ExampleUserHelperCtx::on_abort(const share::SCN &scn)
{
MDS_LOG(INFO, "[UNITTEST] call on_abort with ctx", K(++call_times_));
}
#endif
}
}
#endif

View File

@ -18,7 +18,6 @@
#define protected public
#include "storage/multi_data_source/compile_utility/mds_dummy_key.h"
#include "storage/multi_data_source/compile_utility/map_type_index_in_tuple.h"
#include "common_define.h"
#include "storage/multi_data_source/adapter_define/mds_dump_node.h"
#include <thread>
#include <iostream>
@ -27,7 +26,6 @@
#include "storage/multi_data_source/runtime_utility/mds_factory.h"
#include "common/ob_clock_generator.h"
#include "storage/multi_data_source/mds_node.h"
#include "example_user_helper_define.cpp"
#include "storage/multi_data_source/mds_table_handle.h"
#include "storage/tablet/ob_tablet_meta.h"
namespace oceanbase {

View File

@ -25,7 +25,6 @@
#include "storage/multi_data_source/runtime_utility/mds_factory.h"
#include "common/ob_clock_generator.h"
#include "storage/multi_data_source/mds_node.h"
#include "example_user_helper_define.cpp"
#include "common/meta_programming/ob_type_traits.h"
#include "storage/multi_data_source/mds_row.h"
namespace oceanbase {

View File

@ -25,7 +25,6 @@
#include "storage/multi_data_source/runtime_utility/mds_factory.h"
#include "common/ob_clock_generator.h"
#include "storage/multi_data_source/mds_node.h"
#include "example_user_helper_define.cpp"
#include "common/meta_programming/ob_type_traits.h"
#include "storage/multi_data_source/mds_row.h"
namespace oceanbase {

View File

@ -16,7 +16,6 @@
#include <exception>
#define private public
#define protected public
#include "common_define.h"
#include "lib/allocator/ob_malloc.h"
#include "storage/multi_data_source/mds_node.h"
#include <thread>

View File

@ -14,7 +14,6 @@
#include <gtest/gtest.h>
#define private public
#define protected public
#include "multi_data_source/example_user_data_define.h"
#include "share/ob_ls_id.h"
#include "storage/multi_data_source/mds_writer.h"
#include <thread>
@ -22,7 +21,6 @@
#include <vector>
#include <chrono>
#include <exception>
#include "common_define.h"
#include "lib/ob_errno.h"
#include "share/ob_errno.h"
#include "storage/multi_data_source/adapter_define/mds_dump_node.h"
@ -33,7 +31,6 @@
#include "storage/multi_data_source/mds_unit.h"
#include "storage/multi_data_source/mds_table_handle.h"
#include "storage/multi_data_source/mds_table_handler.h"
#include "example_user_helper_define.cpp"
#include "storage/tx/ob_trans_define.h"
#include <algorithm>
#include <numeric>

View File

@ -15,7 +15,6 @@
#include <gtest/gtest.h>
#define private public
#define protected public
#include "multi_data_source/example_user_data_define.h"
#include "share/ob_ls_id.h"
#include "storage/multi_data_source/mds_writer.h"
#include <thread>
@ -23,7 +22,6 @@
#include <vector>
#include <chrono>
#include <exception>
#include "common_define.h"
#include "lib/ob_errno.h"
#include "share/ob_errno.h"
#include "storage/multi_data_source/adapter_define/mds_dump_node.h"
@ -34,7 +32,6 @@
#include "storage/multi_data_source/mds_unit.h"
#include "storage/multi_data_source/mds_table_handle.h"
#include "storage/multi_data_source/mds_table_handler.h"
#include "example_user_helper_define.cpp"
#include "storage/tx/ob_trans_define.h"
#include <algorithm>
#include <numeric>

View File

@ -9,8 +9,6 @@
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "multi_data_source/example_user_data_define.h"
#include "share/ob_errno.h"
#include <gtest/gtest.h>

View File

@ -15,7 +15,6 @@
#include "lib/utility/utility.h"
#include "share/ob_errno.h"
#include <exception>
#include "common_define.h"
#include "lib/allocator/ob_malloc.h"
#include "storage/multi_data_source/mds_node.h"
#include <thread>