Skip to content

Commit

Permalink
Modify unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ritalin committed Oct 25, 2024
1 parent 9d4501e commit e77c6ea
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
17 changes: 14 additions & 3 deletions lib/test/all_types_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ vector<string> SUPPORTED_TYPES = {"bool",
"uint",
"ubigint",
"hugeint",
"uhugeint",
"time",
"date",
"float",
Expand All @@ -233,7 +234,15 @@ vector<string> SUPPORTED_TYPES = {"bool",
"dec38_10",
"blob",
"bit",
"union"};
"union",
"fixed_int_array",
"fixed_varchar_array",
"fixed_nested_int_array",
"fixed_nested_varchar_array",
"fixed_struct_array",
"struct_of_fixed_array",
"fixed_array_of_int_list",
"list_of_fixed_int_array"};

vector<string> UNSUPPORTED_TYPES = {
// Does not work full range as it overflows during multiplication
Expand Down Expand Up @@ -306,7 +315,9 @@ TEST(AllTypesTest, FullRangeTypes) {
numeric_limits<uint64_t>::max(), batch);

// Date/Time types
AssertParamTypeCorrect<arrow::Time64Type, uint64_t>("time", 0, 86399999999, batch,
// Maximum value for duckdb is 86400000000 ('24:00:00.000000') but apache arrow is 86399999999 ('23.59.59.999999')
// so this assertion tests with duckdb value
AssertParamTypeCorrect<arrow::Time64Type, uint64_t>("time", 0, 86400000000, batch,
arrow::time64(arrow::TimeUnit::MICRO));
// AssertParamTypeCorrect<arrow::Time64Type, uint64_t>("time_tz", 0, 86399999999, batch,
// arrow::time64(arrow::TimeUnit::MICRO));
Expand All @@ -327,7 +338,7 @@ TEST(AllTypesTest, FullRangeTypes) {
arrow::Decimal128("9999999999999999999999999999.9999999999"), batch, arrow::decimal128(38, 10));
// HugeInt from DuckDB is also emitted as a decimal
AssertParamTypeCorrect<arrow::Decimal128Type>(
"hugeint", arrow::Decimal128("-170141183460469231731687303715884105727"),
"hugeint", arrow::Decimal128("-170141183460469231731687303715884105728"),
arrow::Decimal128("170141183460469231731687303715884105727"), batch, arrow::decimal128(38, 0));

// Enum types
Expand Down
20 changes: 15 additions & 5 deletions lib/test/file_page_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST(FilePageBufferTest, FixSingle) {

// Close the file.
// Since there's no more ref, the buffer manager should evict all frames
file->Release();
file->Release(false);
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
ASSERT_EQ(buffer->GetFiles().size(), 0);
ASSERT_EQ(buffer->GetFrames().size(), 0);
Expand Down Expand Up @@ -206,7 +206,7 @@ TEST(FilePageBufferTest, FIFOEviction) {
EXPECT_EQ(expected_fifo, buffer->GetFIFOList());
EXPECT_TRUE(buffer->GetLRUList().empty());

file->Release();
file->Release(false);
ASSERT_EQ(buffer->GetFiles().size(), 0);
ASSERT_EQ(buffer->GetFrames().size(), 0);
}
Expand Down Expand Up @@ -282,7 +282,7 @@ TEST(FilePageBufferTest, LRUEviction) {
EXPECT_EQ(expected_fifo, buffer->GetFIFOList());
EXPECT_EQ(expected_lru, buffer->GetLRUList());

file->Release();
file->Release(false);
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
ASSERT_EQ(buffer->GetFiles().size(), 0);
ASSERT_EQ(buffer->GetFrames().size(), 0);
Expand Down Expand Up @@ -316,7 +316,7 @@ TEST(FilePageBufferTest, ParallelFix) {
EXPECT_EQ(expected_fifo, fifo_list);
EXPECT_TRUE(buffer->GetLRUList().empty());

file->Release();
file->Release(false);
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
ASSERT_EQ(buffer->GetFiles().size(), 0);
ASSERT_EQ(buffer->GetFrames().size(), 0);
Expand Down Expand Up @@ -362,7 +362,7 @@ TEST(FilePageBufferTest, ParallelExclusiveAccess) {
uint64_t value = *reinterpret_cast<uint64_t*>(page_data.data());
EXPECT_EQ(4000, value);
}
file->Release();
file->Release(false);
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
ASSERT_EQ(buffer->GetFiles().size(), 0);
ASSERT_EQ(buffer->GetFrames().size(), 0);
Expand Down Expand Up @@ -399,6 +399,8 @@ TEST(FilePageBufferTest, ParallelScans) {
std::memset(page_data.data(), 0, buffer->GetPageSize());
page.MarkAsDirty();
}

file_ref->Release(false);
}
for (auto& file_path : test_files) {
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
Expand Down Expand Up @@ -440,6 +442,10 @@ TEST(FilePageBufferTest, ParallelScans) {
ASSERT_EQ(value, 0) << "j=" << j << " page=" << page_id;
}
}

for (auto& file : file_refs) {
file->Release(false);
}
});
}

Expand Down Expand Up @@ -482,6 +488,8 @@ TEST(FilePageBufferTest, ParallelReaderWriter) {
std::memset(page_data.data(), 0, buffer->GetPageSize());
page.MarkAsDirty();
}

file_ref->Release(false);
}
for (auto& file_path : test_files) {
ASSERT_FALSE(buffer->BuffersFile(file_path.c_str()));
Expand Down Expand Up @@ -560,6 +568,8 @@ TEST(FilePageBufferTest, ParallelReaderWriter) {
page.MarkAsDirty();
}
}

file->Release(false);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/test/insert_csv_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ TEST(CSVExportTest, TestExport) {
auto path = duckdb::web::test::SOURCE_DIR / ".." / "data" / "test.csv";

// Import csv
auto db = std::make_shared<WebDB>(NATIVE);
auto db = std::make_shared<WebDB>(WEB);
WebDB::Connection conn{*db};
auto maybe_ok = conn.InsertCSVFromPath(path.c_str(), R"JSON({
"schema": "main",
Expand Down
3 changes: 0 additions & 3 deletions lib/test/parquet_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace {

TEST(ParquetLoadTest, LoadParquet) {
auto db = make_shared<WebDB>(NATIVE);
duckdb_web_parquet_init(&db->database());
WebDB::Connection conn{*db};
std::stringstream ss;
auto data = test::SOURCE_DIR / ".." / "data" / "uni" / "studenten.parquet";
Expand All @@ -34,7 +33,6 @@ TEST(ParquetLoadTest, LoadParquet) {

TEST(ParquetLoadTest, LoadParquetTwice) {
auto db = make_shared<WebDB>(NATIVE);
duckdb_web_parquet_init(&db->database());
WebDB::Connection conn{*db};
std::stringstream ss;
auto data = test::SOURCE_DIR / ".." / "data" / "uni" / "studenten.parquet";
Expand All @@ -57,7 +55,6 @@ TEST(ParquetLoadTest, LoadParquetTwice) {

TEST(FileSystemBufferTest, FlushFrameMemoryBugRegression) {
auto db = make_shared<WebDB>(NATIVE);
duckdb_web_parquet_init(&db->database());
WebDB::Connection conn{*db};
std::string files[] = {"customer", "lineitem", "nation", "orders", "partsupp", "part", "region", "supplier"};
for (const auto& f : files) {
Expand Down
2 changes: 0 additions & 2 deletions lib/test/web_filesystem_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ namespace {

TEST(WebFileSystemTest, LoadParquet) {
auto db = std::make_shared<WebDB>(WEB);
duckdb_web_parquet_init(&db->database());
WebDB::Connection conn{*db};
std::stringstream ss;
auto data = test::SOURCE_DIR / ".." / "data" / "uni" / "studenten.parquet";
Expand All @@ -68,7 +67,6 @@ TEST(WebFileSystemTest, LoadParquet) {

TEST(WebFileSystemTest, TestTPCHScans) {
auto db = std::make_shared<WebDB>(WEB);
duckdb_web_parquet_init(&db->database());
WebDB::Connection conn{*db};
std::string files[] = {"customer", "lineitem", "nation", "orders", "partsupp", "part", "region", "supplier"};
for (const auto& f : files) {
Expand Down

0 comments on commit e77c6ea

Please sign in to comment.