-
Notifications
You must be signed in to change notification settings - Fork 77
MCOL-4869: More detailed error report about BufferedFile open failure. #3575
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
Conversation
utils/idbdatafile/BufferedFile.cpp
Outdated
|
||
if (m_fp == NULL) | ||
{ | ||
throw std::runtime_error("unable to open Buffered file "); | ||
static string message = "D 35 CAL0002: Failed to open file: "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to add any numbers here.
it should be "unable to open Buffered file" with filename and errno explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/BufferedFile.cpp
Outdated
|
||
TEST(BufferedFileTest, NoError) | ||
{ | ||
mkdir("/data", 0777); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this wil requre root permissions, unittests are not supposed to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remote system setup is that this is impossible to create directory in home directory (/home/ubuntu). Also, I can not write to files in /var/lib/mysql/test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unitests should work on any machine
https://unix.stackexchange.com/questions/352107/generic-way-to-get-temp-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/BufferedFile.cpp
Outdated
try { | ||
idbdatafile::BufferedFile bf(fname, "r", 0); | ||
} catch(...) { | ||
catched = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXPECT_NO_THROW instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/BufferedFile.cpp
Outdated
idbdatafile::BufferedFile bf(fname, "r", 0); | ||
} catch(const std::runtime_error &e) { | ||
catched = true; | ||
EXPECT_EQ(e.what(), message(fname, ENOENT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXPECT_THROW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/BufferedFile.cpp
Outdated
idbdatafile::BufferedFile bf(fname, "r", 0); | ||
} catch(const std::runtime_error &e) { | ||
catched = true; | ||
EXPECT_EQ(std::string(e.what()), message(fname, ENOTDIR)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXPECT_THROW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
utils/idbdatafile/BufferedFile.cpp
Outdated
throw std::runtime_error("unable to open Buffered file "); | ||
static string message = "unable to open file: "; | ||
|
||
throw std::runtime_error(message+fname+", exception: "+strerror(err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces around '+'
We are following Google Codestyle for c++
https://google.github.io/styleguide/cppguide.html#Horizontal_Whitespace
You can also use clang-format or as we have config for it in the root of codebase
There is also a clang-format extension for VSCode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/CMakeLists.txt
Outdated
@@ -101,6 +101,10 @@ if(WITH_UNITTESTS) | |||
columnstore_link(bytestream ${ENGINE_LDFLAGS} ${ENGINE_WRITE_LIBS} ${CPPUNIT_LIBRARIES} cppunit) | |||
add_test(NAME columnstore:bytestream COMMAND bytestream) | |||
|
|||
add_executable(BufferedFile BufferedFile.cpp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please set a test executable_name
idbdatafile_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
591d143
to
eaeb99b
Compare
eaeb99b
to
6cd5d5c
Compare
The BufferedFile constructor is improved about more descriptive error report about file open failure by using errno.