Skip to content

log/full: Fix log level unit test #3430

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

Merged
merged 1 commit into from
Jun 13, 2025

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Jun 12, 2025

Unit test was broken in several ways and pass verdict was not reliable.

First of log_offset used for starting walk was never initialized and received random data.
By accident this data had non zero ts_stamp that resulted in expected start from the beginning (it stack was different it could look for timestamp instead).

log_last_walk function that is called on each enumerated entry used uninitialized lo_index value to report last entry index. The assumption that lo_index has means something in this context was also incorrect as this value never changes in walk functions. It looks like original code expected this value to have index of log entry which it never does.

Code also did not expected that very first entry added to the log will have index 0 (which was never modified correctly). To read entry index log_read function must be called.

So now walk callback function does read index of the log.

After fixing incorrect code few more conditions are tested.

  • more logs that should not be stored are generated with different log levels
  • logs with log level above threshold are also tested
  • additional check if index of logs increases

Unit test was broken in several ways and pass verdict was
not reliable.

First of log_offset used for starting walk was never initialized
and received random data.
By accident this data had non zero ts_stamp that resulted in
expected start from the beginning (it stack was different
it could look for timestamp instead).

log_last_walk function that is called on each enumerated entry
used uninitialized lo_index value to report last entry index.
The assumption that lo_index has means something in this context
was also incorrect as this value never changes in walk functions.
It looks like original code expected this value to have index of
log entry which it never does.

Code also did not expected that very first entry added to the log
will have index 0 (which was never modified correctly).
To read entry index log_read function must be called.

So now walk callback function does read index of the log.

After fixing incorrect code few more conditions are tested.
- more logs that should not be stored are generated with
  different log levels
- logs with log level above threshold are also tested
- additional check if index of logs increases

Signed-off-by: Jerzy Kasenberg <[email protected]>
@kasjer kasjer requested a review from sjanc June 12, 2025 06:57
@kasjer kasjer merged commit f9ded5d into apache:master Jun 13, 2025
20 checks passed
@kasjer kasjer deleted the kasjer/log-level-unit-tests-fix branch June 13, 2025 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants