Fix unit test, add check

This commit is contained in:
kssenii 2023-06-15 14:22:13 +02:00
parent 0023bf69cb
commit b8a4a784de
2 changed files with 10 additions and 2 deletions

View File

@ -412,6 +412,14 @@ void CacheMetadata::downloadImpl(FileSegment & file_segment, std::optional<Memor
auto reader = file_segment.getRemoteFileReader();
if (!reader)
{
throw Exception(
ErrorCodes::LOGICAL_ERROR, "No reader. "
"File segment should not have been submitted for background download ({})",
file_segment.getInfoForLog());
}
/// If remote_fs_read_method == 'threadpool',
/// reader itself never owns/allocates the buffer.
if (reader->internalBuffer().empty())

View File

@ -533,8 +533,8 @@ TEST_F(FileCacheTest, get)
cv.notify_one();
file_segment2.wait(file_segment2.range().left);
ASSERT_TRUE(file_segment2.state() == DB::FileSegment::State::PARTIALLY_DOWNLOADED);
ASSERT_TRUE(file_segment2.getOrSetDownloader() == DB::FileSegment::getCallerId());
ASSERT_EQ(file_segment2.state(), DB::FileSegment::State::EMPTY);
ASSERT_EQ(file_segment2.getOrSetDownloader(), DB::FileSegment::getCallerId());
download(file_segment2);
});