Skip to content

feat: Add read-ahead configuration and verification support for integration tests#4777

Open
kislaykishore wants to merge 4 commits into
masterfrom
read-ahead-support
Open

feat: Add read-ahead configuration and verification support for integration tests#4777
kislaykishore wants to merge 4 commits into
masterfrom
read-ahead-support

Conversation

@kislaykishore

Copy link
Copy Markdown
Collaborator

This pull request adds support for configuring and verifying read-ahead size in GCSFuse integration tests.

Changes

  • New CLI Parameter: Added --read-ahead-kb flag in setup.go to specify read-ahead sizes.
  • Mounting Hook: Added ConfigureReadAhead and VerifyReadAhead in mounting.go to resolve BDI devices programmatically and apply configurations (with passwordless sudo tee fallback).
  • Mock Unit Tests: Added coverage in mounting_test.go verifying mount directory resolution and configuration writes.
  • E2E verification: Added read_ahead_verify_test.go (TestVerifyReadAheadKB) to verify the mount point's read-ahead setting matches the flag value during E2E.
  • Script Integration: Updated improved_run_e2e_tests.sh to forward --read-ahead-kb parameter.

@kislaykishore kislaykishore requested review from a team and meet2mky as code owners June 14, 2026 15:55
@kislaykishore kislaykishore requested a review from geertj June 14, 2026 15:55
@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Jun 14, 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 enhances the GCSFuse integration testing framework by adding support for configuring and verifying the read-ahead size of mount points. These changes enable more granular control over file system performance testing by allowing developers to specify and validate read-ahead settings directly through the test suite's CLI arguments.

Highlights

  • Read-ahead Configuration: Introduced a new --read-ahead-kb CLI flag to allow configurable read-ahead sizes for GCSFuse integration tests.
  • Mounting Utilities: Added ConfigureReadAhead and VerifyReadAhead functions in mounting.go to programmatically manage and validate read-ahead settings on Linux mount points, including a sudo tee fallback for permission handling.
  • Testing Infrastructure: Implemented a new E2E test TestVerifyReadAheadKB and added comprehensive unit tests in mounting_test.go to verify mount directory resolution and configuration logic.
  • Script Integration: Updated improved_run_e2e_tests.sh to support passing the new read-ahead parameter through to the test execution command.
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 the 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 counterproductive. 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.

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

Copy link
Copy Markdown
Contributor

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 introduces the ability to configure and verify the read-ahead size (in KB) on FUSE mount points during integration testing. It adds a new --read-ahead-kb flag to the E2E test runner, implements the configuration and verification logic by writing to and reading from /sys/class/bdi, and includes corresponding unit and integration tests. The review feedback suggests improving the robustness of the configuration command by using non-interactive sudo -n to prevent potential hangs, and recommends replacing deprecated syscall usages with the golang.org/x/sys/unix package for better consistency.


// If direct write fails (e.g., due to permission error on /sys/class/bdi/ when run as non-root),
// fallback to sudo tee.
cmd := exec.Command("sudo", "tee", bdiPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Use sudo -n (non-interactive) to prevent the command from prompting for a password and hanging indefinitely if passwordless sudo is not configured or misconfigured in the test environment.

Suggested change
cmd := exec.Command("sudo", "tee", bdiPath)
cmd := exec.Command("sudo", "-n", "tee", bdiPath)

Comment on lines +102 to +103
var stat syscall.Stat_t
if err := syscall.Stat(mountDir, &stat); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use unix.Stat_t and unix.Stat from golang.org/x/sys/unix instead of the deprecated syscall package. This maintains consistency with the rest of the file which already imports and uses unix.

Suggested change
var stat syscall.Stat_t
if err := syscall.Stat(mountDir, &stat); err != nil {
var stat unix.Stat_t
if err := unix.Stat(mountDir, &stat); err != nil {

Comment on lines +134 to +135
var stat syscall.Stat_t
if err := syscall.Stat(mountDir, &stat); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use unix.Stat_t and unix.Stat from golang.org/x/sys/unix instead of the deprecated syscall package to maintain consistency.

Suggested change
var stat syscall.Stat_t
if err := syscall.Stat(mountDir, &stat); err != nil {
var stat unix.Stat_t
if err := unix.Stat(mountDir, &stat); err != nil {

Comment on lines +115 to +116
var stat syscall.Stat_t
err = syscall.Stat(tempMountDir, &stat)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use unix.Stat_t and unix.Stat from golang.org/x/sys/unix instead of the deprecated syscall package to maintain consistency.

Suggested change
var stat syscall.Stat_t
err = syscall.Stat(tempMountDir, &stat)
var stat unix.Stat_t
err = unix.Stat(tempMountDir, &stat)

@kislaykishore

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 introduces a new command-line option --read-ahead-kb to configure and verify the read-ahead size on FUSE mount points during integration tests. This includes updates to the test runner script, setup flags, mounting utilities (with support for writing to sysfs BDI settings directly or via sudo tee), and a new verification test. The review comments suggest improving the robustness of the mount directory resolution by prioritizing setup.MntDir() and explicitly skipping the verification test using t.Skip when the option is not configured.

Comment on lines +67 to +74
mountDir := getMountDir(flags)
if mountDir != "" {
if err := ConfigureReadAhead(mountDir, readAheadKB); err != nil {
return fmt.Errorf("failed to configure read-ahead: %w", err)
}
} else {
log.Printf("Warning: read-ahead-kb specified but mount directory could not be resolved from flags: %v", flags)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To make the mount directory resolution more robust and less dependent on parsing command-line flags (which can be fragile if directory-valued flags are introduced in the future), prefer using setup.MntDir() as the primary source, falling back to getMountDir(flags) only if it is not set.

		mountDir := setup.MntDir()
		if mountDir == "" {
			mountDir = getMountDir(flags)
		}
		if mountDir != "" {
			if err := ConfigureReadAhead(mountDir, readAheadKB); err != nil {
				return fmt.Errorf("failed to configure read-ahead: %w", err)
			}
		} else {
			log.Printf("Warning: read-ahead-kb specified but mount directory could not be resolved: %v", flags)
		}
References
  1. Instead of extracting configuration values from flags at runtime, use a global constant in a shared setup file for values like block size.

Comment on lines +25 to +31
expectedKB := setup.ReadAheadKB()
if expectedKB > 0 {
err := mounting.VerifyReadAhead(setup.MntDir(), expectedKB)
if err != nil {
t.Errorf("read-ahead verification failed: %v", err)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of silently passing when read-ahead-kb is not configured, use t.Skip to explicitly skip the test. This improves test reporting and visibility in CI/CD pipelines.

	expectedKB := setup.ReadAheadKB()
	if expectedKB <= 0 {
		t.Skip("Skipping read-ahead verification as read-ahead-kb is not configured.")
	}

	err := mounting.VerifyReadAhead(setup.MntDir(), expectedKB)
	if err != nil {
		t.Errorf("read-ahead verification failed: %v", err)
	}

@kislaykishore

Copy link
Copy Markdown
Collaborator Author

/gemini review

@kislaykishore

Copy link
Copy Markdown
Collaborator Author

/gemini review

@kislaykishore kislaykishore changed the title Add read-ahead configuration and verification support for integration tests feat: Add read-ahead configuration and verification support for integration tests Jun 14, 2026

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

Copy link
Copy Markdown
Contributor

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 adds support for configuring and verifying the FUSE mount read-ahead size (--read-ahead-kb) during integration tests. It introduces command-line flag propagation in the test runner, setup configuration parsing, and utility functions to write to and read from the Linux sysfs BDI interface. Feedback on this PR highlights critical compilation issues on macOS (Darwin) due to the direct use of Linux-specific golang.org/x/sys/unix APIs without build tags. To resolve this, the Linux-specific mounting utilities and their mock tests should be moved to separate files (e.g., using //go:build linux) with appropriate stubs for non-Linux platforms.

Comment thread tools/integration_tests/util/mounting/mounting.go
Comment thread tools/integration_tests/util/mounting/mounting_test.go

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

Copy link
Copy Markdown
Contributor

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 introduces support for configuring and verifying the read-ahead size (in KB) on FUSE mount points during integration testing. It adds a --read-ahead-kb flag to the E2E test runner script, propagates it to the test execution command, and implements the configuration on Linux by writing to the corresponding sysfs BDI path. A verification test and unit tests are also added. The review feedback suggests prioritizing the resolution of the mount directory from the command flags first, falling back to the global default mount directory only if it cannot be resolved.

Comment on lines +67 to +70
mountDir := setup.MntDir()
if mountDir == "" {
mountDir = getMountDir(flags)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

When mounting GCSFuse with custom flags or custom mount directories, setup.MntDir() (which returns the global default mount directory) might not match the actual mount directory being used for this specific mount command. We should prioritize resolving the mount directory from the command flags first, and only fall back to setup.MntDir() if it cannot be resolved.

Suggested change
mountDir := setup.MntDir()
if mountDir == "" {
mountDir = getMountDir(flags)
}
mountDir := getMountDir(flags)
if mountDir == "" {
mountDir = setup.MntDir()
}

@github-actions

Copy link
Copy Markdown

Hi @meet2mky, @geertj, 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!

1 similar comment
@github-actions

Copy link
Copy Markdown

Hi @meet2mky, @geertj, 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

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