Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TruncatedWalTest to use the new filesystem API #2597

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions test/storage/node_insertion_deletion_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <fcntl.h>

#include "common/constants.h"
#include "common/file_utils.h"
#include "common/file_system/local_file_system.h"
#include "graph_test/graph_test.h"

using namespace kuzu::common;
Expand Down Expand Up @@ -111,6 +113,7 @@ TEST_F(NodeInsertionDeletionTests, InsertManyNodesTest) {

TEST_F(NodeInsertionDeletionTests, TruncatedWalTest) {
auto preparedStatement = conn->prepare("CREATE (:person {ID:$id});");
auto fs = LocalFileSystem();
// Note: this test will fail if the transaction is small enough to fit the wal headers in a
// single page, since we currently may fail to recover if the headers are intact but shadow
// pages are missing. Pages are flushed before writing the commit record to make sure that
Expand All @@ -122,14 +125,14 @@ TEST_F(NodeInsertionDeletionTests, TruncatedWalTest) {
}
conn->query("COMMIT_SKIP_CHECKPOINT");
auto databasePath = this->databasePath;
auto walPath = FileUtils::joinPath(databasePath, StorageConstants::WAL_FILE_SUFFIX);
auto walPath = fs.joinPath(databasePath, StorageConstants::WAL_FILE_SUFFIX);
// Close database
database.reset();
{
auto walFileInfo = FileUtils::openFile(walPath, O_RDWR);
auto walFileInfo = fs.openFile(walPath, O_RDWR);
ASSERT_GT(walFileInfo->getFileSize(), BufferPoolConstants::PAGE_4KB_SIZE)
<< "Test needs a wal file with more than one page";
FileUtils::truncateFileToSize(walFileInfo.get(), BufferPoolConstants::PAGE_4KB_SIZE);
walFileInfo->truncate(BufferPoolConstants::PAGE_4KB_SIZE);
}
// Re-open database
database = std::make_unique<Database>(databasePath);
Expand Down