fix storage_schema compat serialize & wrong multi_version_start & major rs checker hung
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include "storage/ob_storage_schema.h"
|
||||
#include "share/ob_encryption_util.h"
|
||||
#include "storage/test_schema_prepare.h"
|
||||
#include "mittest/mtlenv/mock_tenant_module_env.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -30,17 +31,41 @@ namespace unittest
|
||||
class TestStorageSchema : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
TestStorageSchema() : allocator_(ObModIds::TEST) {}
|
||||
TestStorageSchema() : allocator_(ObModIds::TEST), tenant_base_(tenant_id) {}
|
||||
virtual ~TestStorageSchema() {}
|
||||
bool judge_storage_schema_equal(ObStorageSchema &schema1, ObStorageSchema &schema2);
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
static const int64_t tenant_id = 1;
|
||||
common::ObArenaAllocator allocator_;
|
||||
ObTenantBase tenant_base_;
|
||||
};
|
||||
|
||||
void TestStorageSchema::SetUp()
|
||||
{
|
||||
ASSERT_EQ(OB_SUCCESS, tenant_base_.init());
|
||||
|
||||
}
|
||||
void TestStorageSchema::TearDown()
|
||||
{
|
||||
ObTenantEnv::set_tenant(nullptr);
|
||||
}
|
||||
|
||||
void TestStorageSchema::SetUpTestCase()
|
||||
{
|
||||
EXPECT_EQ(OB_SUCCESS, MockTenantModuleEnv::get_instance().init());
|
||||
}
|
||||
void TestStorageSchema::TearDownTestCase()
|
||||
{
|
||||
MockTenantModuleEnv::get_instance().destroy();
|
||||
}
|
||||
|
||||
bool TestStorageSchema::judge_storage_schema_equal(ObStorageSchema &schema1, ObStorageSchema &schema2)
|
||||
{
|
||||
bool equal = false;
|
||||
equal = schema1.version_ == schema2.version_
|
||||
&& schema1.is_use_bloomfilter_ == schema2.is_use_bloomfilter_
|
||||
equal = schema1.is_use_bloomfilter_ == schema2.is_use_bloomfilter_
|
||||
&& schema1.table_type_ == schema2.table_type_
|
||||
&& schema1.table_mode_ == schema2.table_mode_
|
||||
&& schema1.row_store_type_ == schema2.row_store_type_
|
||||
@ -54,8 +79,7 @@ bool TestStorageSchema::judge_storage_schema_equal(ObStorageSchema &schema1, ObS
|
||||
&& schema1.encryption_ == schema2.encryption_
|
||||
&& schema1.encrypt_key_ == schema2.encrypt_key_
|
||||
&& schema1.rowkey_array_.count() == schema2.rowkey_array_.count()
|
||||
&& schema1.column_array_.count() == schema2.column_array_.count()
|
||||
&& schema1.skip_idx_attr_array_.count() == schema2.skip_idx_attr_array_.count();
|
||||
&& schema1.column_array_.count() == schema2.column_array_.count();
|
||||
|
||||
for (int64_t i = 0; equal && i < schema1.rowkey_array_.count(); ++i) {
|
||||
equal = schema1.rowkey_array_[i].meta_type_ == schema1.rowkey_array_[i].meta_type_;
|
||||
@ -65,9 +89,13 @@ bool TestStorageSchema::judge_storage_schema_equal(ObStorageSchema &schema1, ObS
|
||||
equal = schema1.column_array_[i].meta_type_ == schema2.column_array_[i].meta_type_
|
||||
&& schema1.column_array_[i].is_column_stored_in_sstable_ == schema2.column_array_[i].is_column_stored_in_sstable_;
|
||||
}
|
||||
for (int i = 0; equal && i < schema1.skip_idx_attr_array_.count(); ++i) {
|
||||
equal = schema1.skip_idx_attr_array_[i].col_idx_ == schema2.skip_idx_attr_array_[i].col_idx_
|
||||
&& schema1.skip_idx_attr_array_[i].skip_idx_attr_ == schema2.skip_idx_attr_array_[i].skip_idx_attr_;
|
||||
if (equal && schema1.version_ >= ObStorageSchema::STORAGE_SCHEMA_VERSION_V3
|
||||
&& schema2.version_ >= ObStorageSchema::STORAGE_SCHEMA_VERSION_V3) {
|
||||
equal = schema1.skip_idx_attr_array_.count() == schema2.skip_idx_attr_array_.count();
|
||||
for (int i = 0; equal && i < schema1.skip_idx_attr_array_.count(); ++i) {
|
||||
equal = schema1.skip_idx_attr_array_[i].col_idx_ == schema2.skip_idx_attr_array_[i].col_idx_
|
||||
&& schema1.skip_idx_attr_array_[i].skip_idx_attr_ == schema2.skip_idx_attr_array_[i].skip_idx_attr_;
|
||||
}
|
||||
}
|
||||
|
||||
return equal;
|
||||
@ -229,6 +257,29 @@ TEST_F(TestStorageSchema, deep_copy_str)
|
||||
|
||||
}
|
||||
|
||||
TEST_F(TestStorageSchema, compat_serialize_and_deserialize)
|
||||
{
|
||||
share::schema::ObTableSchema table_schema;
|
||||
ObStorageSchema storage_schema;
|
||||
TestSchemaPrepare::prepare_schema(table_schema);
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema.init(allocator_, table_schema, lib::Worker::CompatMode::MYSQL));
|
||||
storage_schema.storage_schema_version_ = ObStorageSchema::STORAGE_SCHEMA_VERSION;
|
||||
|
||||
const int64_t buf_len = 1024 * 1024;
|
||||
int64_t ser_pos = 0;
|
||||
char buf[buf_len] = "\0";
|
||||
ASSERT_EQ(OB_SUCCESS, storage_schema.serialize(buf, buf_len, ser_pos));
|
||||
|
||||
ASSERT_EQ(ser_pos, storage_schema.get_serialize_size());
|
||||
|
||||
ObStorageSchema des_storage_schema;
|
||||
int64_t pos = 0;
|
||||
ASSERT_EQ(OB_SUCCESS, des_storage_schema.deserialize(allocator_, buf, ser_pos, pos));
|
||||
|
||||
COMMON_LOG(INFO, "test", K(storage_schema), K(des_storage_schema));
|
||||
ASSERT_EQ(true, judge_storage_schema_equal(storage_schema, des_storage_schema));
|
||||
}
|
||||
|
||||
} // namespace unittest
|
||||
} // namespace oceanbase
|
||||
|
||||
|
Reference in New Issue
Block a user