Skip to content

Commit

Permalink
Merge pull request #1153 from kuzudb/fix-1112
Browse files Browse the repository at this point in the history
[1129] fix test failures due to open file handles
  • Loading branch information
anuchak committed Jan 6, 2023
2 parents 9ac17d2 + bebbd8a commit 491d050
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/include/storage/wal/wal.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class WAL : public BaseWALAndWALIterator {

class WALIterator : public BaseWALAndWALIterator {
public:
explicit WALIterator(shared_ptr<FileHandle> fileHandle, mutex& mtx);
explicit WALIterator(const shared_ptr<FileHandle>& fileHandle, mutex& mtx);

inline bool hasNextRecord() {
lock_t lck{mtx};
Expand Down
2 changes: 1 addition & 1 deletion src/storage/wal/wal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void WAL::setIsLastRecordCommit() {
}
}

WALIterator::WALIterator(shared_ptr<FileHandle> fileHandle, mutex& mtx)
WALIterator::WALIterator(const shared_ptr<FileHandle>& fileHandle, mutex& mtx)
: BaseWALAndWALIterator(fileHandle), mtx{mtx} {
resetCurrentHeaderPagePrefix();
if (fileHandle->getNumPages() > 0) {
Expand Down
4 changes: 2 additions & 2 deletions test/include/main_test_helper/main_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace kuzu {
namespace testing {

class ApiTest : public EmptyDBTest {
class ApiTest : public BaseGraphTest {

public:
void SetUp() override {
EmptyDBTest::SetUp();
BaseGraphTest::SetUp();
systemConfig->defaultPageBufferPoolSize = (1ull << 26);
systemConfig->largePageBufferPoolSize = (1ull << 26);
createDBAndConn();
Expand Down
3 changes: 3 additions & 0 deletions test/include/test_helper/test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class BaseGraphTest : public Test {
void TearDown() override { FileUtils::removeDir(TestHelper::getTmpTestDir()); }

inline void createDBAndConn() {
if (database != nullptr) {
database.reset();
}
database = make_unique<Database>(*databaseConfig, *systemConfig);
conn = make_unique<Connection>(database.get());
spdlog::set_level(spdlog::level::info);
Expand Down
13 changes: 5 additions & 8 deletions test/main/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
using namespace kuzu::testing;

TEST_F(ApiTest, DatabaseConfig) {
auto db = make_unique<Database>(DatabaseConfig(TestHelper::getTmpTestDir()));
spdlog::set_level(spdlog::level::debug);
ASSERT_NO_THROW(db->resizeBufferManager(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2));
ASSERT_EQ(getDefaultBMSize(*db), (uint64_t)(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2 *
StorageConfig::DEFAULT_PAGES_BUFFER_RATIO));
ASSERT_EQ(getLargeBMSize(*db), (uint64_t)(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2 *
StorageConfig::LARGE_PAGES_BUFFER_RATIO));
ASSERT_NO_THROW(database->resizeBufferManager(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2));
ASSERT_EQ(getDefaultBMSize(*database), (uint64_t)(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2 *
StorageConfig::DEFAULT_PAGES_BUFFER_RATIO));
ASSERT_EQ(getLargeBMSize(*database), (uint64_t)(StorageConfig::DEFAULT_BUFFER_POOL_SIZE * 2 *
StorageConfig::LARGE_PAGES_BUFFER_RATIO));
}

TEST_F(ApiTest, ClientConfig) {
auto db = make_unique<Database>(DatabaseConfig(TestHelper::getTmpTestDir()));
spdlog::set_level(spdlog::level::debug);
auto conn = make_unique<Connection>(db.get());
ASSERT_NO_THROW(conn->setMaxNumThreadForExec(2));
ASSERT_EQ(conn->getMaxNumThreadForExec(), 2);
}
Expand Down

0 comments on commit 491d050

Please sign in to comment.