test(bq_driver): add e2e tracing testing#1323
Conversation
| int log_file_size; | ||
| int max_threads; | ||
| bool logging_enabled = false; | ||
| int max_threads = 0; |
There was a problem hiding this comment.
The default value of max_threads should be 8.
| std::string const kLogFileCount = "LogFileCount"; | ||
| std::string const kLogFileSize = "LogFileSize"; | ||
| std::string const kMaxThreadsParam = "MaxThreads"; | ||
| inline std::string const kLogLevel = "LogLevel"; |
There was a problem hiding this comment.
Is this needed to fix the issue in this PR?
I don't understand why these have to be inline.
There was a problem hiding this comment.
Yes, this is needed because CreateTraceOptionsFile is invoked multiple times during driver initialization, and in some runs the constant values end up being empty.
There was a problem hiding this comment.
Why was this not an issue earlier? I don't believe kLogLevel can be empty in any case.
In any case, we should find the root cause. Lets have a call to discuss this.
There was a problem hiding this comment.
it is a case of static initialization fiasco , similar to how static variables should be declared in header file but defined in implementation cc file , in this case either do that or make it inline. stack-over-flow-link
| options_file_ = std::shared_ptr<TraceOptions>(new TraceOptions()); | ||
| } | ||
|
|
||
| if (log_level > 0 && logging_enabled) { |
There was a problem hiding this comment.
Did I make some undersirable changes recently? I want to understand where we went wrong.
There was a problem hiding this comment.
No, these unwanted changes were introduced in the last logging PR.
sachinpro
left a comment
There was a problem hiding this comment.
We need comprehensive e2e tests for tracing utilities doing something like:
- Setting
GOOGLEBIGQUERYODBCINIto a new folder path - Use
LOG(macro with a specific testing string. - No error should be thrown whether the path is valid or not.
- If the path was valid, check that the first log file was created.
- If it was created, check the contents for the testing string we logged in step 2.
On top of this, we need similar test(s) for LogFileCount andLogFileSize too.
716d506 to
0b792f4
Compare
451a866 to
3f92d6e
Compare
3f92d6e to
95d534a
Compare
95d534a to
b38650a
Compare
b38650a to
b573a2c
Compare
b573a2c to
8a074f8
Compare
8a074f8 to
3c34c91
Compare
3c34c91 to
214120e
Compare
All the points listed above are now being validated in the existing |
0efd8b8 to
e46eec3
Compare
e46eec3 to
56a1984
Compare
56a1984 to
c037d30
Compare
be29e54 to
61383b0
Compare
| } | ||
|
|
||
| // Should have atleast 2 files if rotation worked | ||
| EXPECT_LE(log_files.size(), std::stoi(log_file_count)); |
There was a problem hiding this comment.
should have used EXPECT_EQ we need to match the same and if same number of files are not coming let's write more atleast more than 2MB(log_file_count * log_file_size) to make sure we are not creating more log file than the count
There was a problem hiding this comment.
Updated the EXPECT_EQ , but kept the log file size at 1 MB. Increasing the max file size would generate more logs, which could lead to test timeouts.
| } | ||
|
|
||
| TEST(GetOdbcTraceConfigPath, GetDefaultPath) { | ||
| auto home = ::google::cloud::internal::GetEnv("GOOGLEBIGQUERYODBCINI"); |
There was a problem hiding this comment.
Please document here why this is needed
| EXPECT_EQ(6, (*test_opts_file)->max_file_size); | ||
| } | ||
|
|
||
| #if !defined(_WIN32) && !defined(__APPLE__) |
There was a problem hiding this comment.
Simplify and add flag for linux only
| #endif // _WIN32 | ||
| } | ||
|
|
||
| void UpdateTraceConfig(std::string const& odbc_trace_config, |
There was a problem hiding this comment.
Maybe you can move this to commons.cc with generic behaviour to update registry entry
| std::unordered_map<std::string, std::string> kv; | ||
| std::string line; | ||
|
|
||
| if (fs::exists(config_path) && fs::is_regular_file(config_path)) { |
There was a problem hiding this comment.
It should not check if file exists or not, it should simply update the entry , rest of the logic also seems unnecessary
| if (fs::exists(config_path) && fs::is_regular_file(config_path)) { | ||
| std::ifstream input(odbc_trace_config); | ||
| ASSERT_TRUE(input.is_open()); | ||
| std::cout << "check " << std::endl; |
There was a problem hiding this comment.
there should not be prints
|
|
||
| fs::path log_file_path = fs::path(log_path) / "odbcdriverforbigquery_0.log"; | ||
| log_file = log_file_path.string(); | ||
| std::cout << "odbc_ini file " << odbc_ini_path << std::endl; |
There was a problem hiding this comment.
please remove prints
|
@sachinpro PR ready for review |
|
@sachinpro PR is ready for review |
|
@sachinpro This PR has been pending review since December. It contains required logging changes and needs to be merged. |
|
@shivamd-gpartner @NeerajDwivedii Please rebase and clean this PR up. |
| int const log_file_count = 2; | ||
| int const log_file_size = 1024; | ||
|
|
||
| // Unique test dir |
There was a problem hiding this comment.
Added logic to create an individual googlebigqueryodbc.ini file and directory for log generation, preventing overlap with files used by other git checks, and ensuring they are cleaned up after validation.
|
All previous comments have already been addressed. Here are the GHA workflow: https://github.com/googleapis/cpp-bigquery-odbc/actions/runs/24875185212 @sachinpro PR ready for review |
This PR fixes the logging issue that was previously not working. Logging now functions correctly across all platforms and adheres to the tracing priorities defined in the design document. Additionally,
max_threadshas been initialized to 0 to prevent the Windows error:Run-Time Check Failure #3 – The variable 'max_threads' is being used without being initialized.