patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -19,12 +19,13 @@ using namespace oceanbase::common;
using namespace oceanbase::json;
using namespace oceanbase::share::schema;
namespace test {
namespace test
{
static int MAX_THREAD_COUNT = 1;
static uint64_t TENANT_ID_NUM = 1;
static TestSQL* test_sql = NULL;
static ObPlanCacheManager* plan_cache_mgr = NULL;
static TestSQL *test_sql = NULL;
static ObPlanCacheManager *plan_cache_mgr = NULL;
void init_pcm()
{
@ -39,46 +40,43 @@ void init_pcm()
}
}
class TestPlanCacheManager : public ::testing::Test {
class TestPlanCacheManager : public ::testing::Test
{
public:
TestPlanCacheManager()
{}
virtual ~TestPlanCacheManager()
{}
void SetUp()
{}
void TearDown()
{}
TestPlanCacheManager() {}
virtual ~TestPlanCacheManager() {}
void SetUp() {}
void TearDown() {}
private:
// disallow copy
TestPlanCacheManager(const TestPlanCacheManager& other);
TestPlanCacheManager& operator=(const TestPlanCacheManager& other);
TestPlanCacheManager(const TestPlanCacheManager &other);
TestPlanCacheManager& operator=(const TestPlanCacheManager &other);
};
void test_plan_cache_manager()
void test_plan_cache_manager()
{
uint64_t tenant_id = 0;
ObPlanCache* plan_cache = NULL;
ObPlanCache *plan_cache = NULL;
// test get_plan_cache()
//test get_plan_cache()
ObPCMemPctConf conf;
for (tenant_id = 0; tenant_id < TENANT_ID_NUM; tenant_id++) {
plan_cache = plan_cache_mgr->get_plan_cache(tenant_id);
plan_cache = plan_cache_mgr->get_or_create_plan_cache(tenant_id, conf); // may be plan_cache = NULL in parallel
LOG_INFO("get_plan_cache", K(tenant_id), K(plan_cache));
// ob_print_mod_memory_usage();
if (TENANT_ID_NUM / 2 == tenant_id) {
plan_cache = plan_cache_mgr->get_or_create_plan_cache(tenant_id, conf);//may be plan_cache = NULL in parallel
LOG_INFO("get_plan_cache",K(tenant_id), K(plan_cache));
//ob_print_mod_memory_usage();
if (TENANT_ID_NUM/2 == tenant_id) {
plan_cache_mgr->elimination_task_.runTimerTask();
}
}
// test revert_plan_cache()
//test revert_plan_cache()
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->revert_plan_cache(TENANT_ID_NUM - 1));
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->revert_plan_cache(TENANT_ID_NUM + 1));
}
class ObPlanCacheManagerRunnable : public share::ObThreadPool {
class ObPlanCacheManagerRunnable : public share::ObThreadPool
{
public:
void run1()
{
@ -98,32 +96,31 @@ TEST_F(TestPlanCacheManager, basic)
}
EXPECT_TRUE(OB_SUCCESS == plan_cache_mgr->flush_all_plan_cache());
plan_cache_mgr->destroy();
}
} // namespace test
plan_cache_mgr->destroy(); }
}//namespace test end
int main(int argc, char** argv)
int main(int argc, char **argv)
{
::oceanbase::sql::init_sql_factories();
::testing::InitGoogleTest(&argc, argv);
::testing::InitGoogleTest(&argc,argv);
int c = 0;
while (-1 != (c = getopt(argc, argv, "t::n::"))) {
while(-1 != (c = getopt(argc, argv, "t::n::"))) {
switch (c) {
case 't':
if (NULL != optarg) {
test::MAX_THREAD_COUNT = atoi(optarg);
}
break;
case 'n':
if (NULL != optarg) {
test::TENANT_ID_NUM = atoi(optarg);
}
default:
break;
case 't':
if (NULL != optarg) {
test::MAX_THREAD_COUNT = atoi(optarg);
}
break;
case 'n':
if (NULL != optarg) {
test::TENANT_ID_NUM = atoi(optarg);
}
default:
break;
}
}
::test::init_pcm();
return RUN_ALL_TESTS();
} // namespace test end
}//namespace test end