Skip to content

test(logs): enforce log-file strictness and centralize log filename parsing#4620

Open
PranjalC100 wants to merge 1 commit intomasterfrom
log-file-parsing-for-mounted-dir
Open

test(logs): enforce log-file strictness and centralize log filename parsing#4620
PranjalC100 wants to merge 1 commit intomasterfrom
log-file-parsing-for-mounted-dir

Conversation

@PranjalC100
Copy link
Copy Markdown
Member

Description

This PR centralizes and strengthens log file handling within the integration test suite. It ensures that log files are consistently parsed with the correct .log suffix and that failures to open log files result in immediate test failure rather than silent errors during mounted directory tests.

Vulnerability Analysis: Silent Test Validation Passes

1. The Root Cause

In inactive_stream_timeout, test validations check for the absence of activity logs via doesNotHaveInactiveReaderClosedLogLineInLogFile. Previously, if the target file handle was unavailable, the system printed an error but completely skipped blocking assertions because it evaluated err == nil as false:

Original Unsafe Code (before fixes):

// Flawed logic inside Setup
_, err := hasInactiveReaderClosedLogLineInLogFile(t, objectName, logFile, startTime, endTime)
if err != nil { // This printed the error but allowed the test to continue
    fmt.Println("INACTIVE STREAM CHECK ERROR:", err)
}
if err == nil {
    // If the file was missing, err != nil, so this assertion was skipped!
    t.Fatalf("Unexpected 'Inactive Reader Closed' log message found...")
}

The Output

The test package prints success (PASS) without actually verifying from the logs:

INACTIVE STREAM CHECK ERROR: failed to open log file: open /gcsfuse-tmp/TestTimeoutEnabledSuite.log: no such file or directory
--- PASS: TestTimeoutEnabledSuite (12.05s)

Key Changes:

  • Strict Log File Access: Replaced soft error returns with require.NoError in the inactive_stream_timeout test setup to ensure that a missing or inaccessible log file correctly fails the test.
  • Centralized Suffix Enforcement: Modified ParseLogFileFromFlags to automatically append a .log extension to filenames extracted from flags if it is missing.
  • Improved Log Path Discovery: Updated SetUpLogFilePath to attempt to infer log filenames from the first configuration block if they are not explicitly provided in the top-level flags.

Link to the issue in case of a bug fix.

link

Testing details

  • Manual - Ran the mounted directory tests for inactive_stream_timeout.
  • Unit tests - NA
  • Integration tests - Validated that log paths are correctly constructed for both mounted directory and local environments and that tests fail appropriately when logs are missing.

Any backward incompatible change? If so, please explain.

No.

@PranjalC100 PranjalC100 requested review from a team and meet2mky as code owners April 15, 2026 13:52
@github-actions github-actions bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Apr 15, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request centralizes and strengthens log file handling within the integration test suite. By enforcing consistent naming conventions and ensuring that log file access errors result in immediate test failures, the changes prevent silent validation passes and improve the reliability of the test suite.

Highlights

  • Strict Log File Access: Replaced soft error handling with require.NoError in the inactive_stream_timeout test setup to ensure that missing or inaccessible log files trigger an immediate test failure.
  • Centralized Suffix Enforcement: Updated ParseLogFileFromFlags to automatically append a .log extension to filenames if it is missing, ensuring consistent log file naming.
  • Improved Log Path Discovery: Enhanced SetUpLogFilePath to infer log filenames from the first configuration block if they are not explicitly provided in the top-level flags.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@PranjalC100 PranjalC100 added execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. labels Apr 15, 2026
@PranjalC100 PranjalC100 force-pushed the log-file-parsing-for-mounted-dir branch from 6d29e5d to 217dfbe Compare April 15, 2026 13:54
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors error handling in integration tests by using require.NoError and updates the log file path parsing logic to handle comma-separated flags and configuration-based inference. Feedback indicates a missing import for the require package, a potential regression where an empty log filename could result in a directory path instead of a file, and an edge case where an empty --log-file flag value leads to an incorrect filename.

Comment thread tools/integration_tests/inactive_stream_timeout/setup_test.go
Comment thread tools/integration_tests/util/setup/setup.go
Comment thread tools/integration_tests/util/setup/setup.go Outdated
@PranjalC100 PranjalC100 force-pushed the log-file-parsing-for-mounted-dir branch from 217dfbe to 277ce6a Compare April 15, 2026 14:08
Comment thread tools/integration_tests/util/setup/setup.go Outdated
@PranjalC100 PranjalC100 force-pushed the log-file-parsing-for-mounted-dir branch from 277ce6a to af7478b Compare April 16, 2026 09:37
@github-actions
Copy link
Copy Markdown

Hi @meet2mky, @kislaykishore, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant