/** * Copyright (c) 2021 OceanBase * OceanBase CE is licensed under Mulan PubL v2. * You can use this software according to the terms and conditions of the Mulan PubL v2. * You may obtain a copy of Mulan PubL v2 at: * http://license.coscl.org.cn/MulanPubL-2.0 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PubL v2 for more details. */ #include #include "lib/utility/ob_test_util.h" #include "lib/restore/ob_storage.h" #include "lib/allocator/page_arena.h" #include "share/backup/ob_backup_io_adapter.h" #include "common/storage/ob_fd_simulator.h" #define private public #include "share/ob_device_manager.h" #undef private using namespace oceanbase::common; //test fd simulator class TestFdSimulator: public ::testing::Test { public: TestFdSimulator() {} virtual ~TestFdSimulator(){} virtual void SetUp() { } virtual void TearDown() { } static void SetUpTestCase() { } static void TearDownTestCase() { } private: // disallow copy DISALLOW_COPY_AND_ASSIGN(TestFdSimulator); }; TEST_F(TestFdSimulator, test_fd) { ObFdSimulator fd_sim; ASSERT_EQ(OB_SUCCESS, fd_sim.init()); int device_type = 0; int device_flag = 0; oceanbase::common::ObArenaAllocator allocator; void* ctx = NULL; int test_total_num = 200; int test_1_num = 90; //<100 int test_2_num = 30; //90-110 int test_3_num = 80; //200 int used_fd_cnt = 0; int free_fd_cnt = 0; int expect_used_fd_cnt = 0; int expect_free_fd_cnt = 0; int tmp_device_type = 0; int tmp_device_flag = 0; void* tmp_ctx = NULL; //init fds ObIOFd* fds = static_cast(allocator.alloc(sizeof(ObIOFd)*test_total_num)); for(int i =0; i= max_dev_num/2) { ASSERT_EQ(OB_SUCCESS, databuff_printf(storage_info_buf, sizeof(storage_info_buf), "%s_%d", OB_LOCAL_PREFIX, i)); storage_info.assign_ptr(storage_info_buf, strlen(storage_info_buf)); } ASSERT_EQ(OB_SUCCESS, manager.get_device(storage_info, storage_info, device_handle[i])); } device_num = manager.get_device_cnt(); ASSERT_EQ(max_dev_num/2 + 1, device_num); } int main(int argc, char **argv) { system("rm -f test_storage_device_manager.log"); OB_LOGGER.set_file_name("test_storage_device_manager.log"); OB_LOGGER.set_log_level("INFO"); ::testing::InitGoogleTest(&argc,argv); return RUN_ALL_TESTS(); }