Skip to content

Commit

Permalink
Update TruncatedWalTest to use the new filesystem API
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwinger committed Dec 19, 2023
1 parent 28bd991 commit c60aa32
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit c60aa32

Please sign in to comment.