Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tools/integration_tests/dentry_cache/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *notifierTest) TestWriteFileWithDentryCacheEnabled() {
err = operations.WriteFile(filePath, "ShouldNotWrite")

// First Write File attempt should fail because file has been clobbered.
operations.ValidateESTALEError(s.T(), err)
operations.ValidateESTALEOrEIOError(s.T(), err)
// Second Write File attempt.
err = operations.WriteFile(filePath, "ShouldWrite")
// The notifier is triggered after the first write failure, invalidating the kernel cache entry.
Expand All @@ -97,7 +97,7 @@ func (s *notifierTest) TestReadFileWithDentryCacheEnabled() {
// First Read File attempt.
_, err = operations.ReadFile(filePath)
// First Read File attempt should fail because file has been clobbered.
operations.ValidateESTALEError(s.T(), err)
operations.ValidateESTALEOrEIOError(s.T(), err)
// Second Read File attempt.
_, err = operations.ReadFile(filePath)
// The notifier is triggered after the first read failure, invalidating the kernel cache entry.
Expand All @@ -119,7 +119,7 @@ func (s *notifierTest) TestDeleteFileWithDentryCacheEnabled() {
// Read File to call the notifier to invalidate entry.
_, err = operations.ReadFile(filePath)
// The notifier is triggered after the first read failure, invalidating the kernel cache entry.
operations.ValidateESTALEError(s.T(), err)
operations.ValidateESTALEOrEIOError(s.T(), err)

// Stat again, it should give error as entry does not exist.
_, err = os.Stat(filePath)
Expand Down
15 changes: 13 additions & 2 deletions tools/integration_tests/util/operations/validation_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ func ValidateESTALEError(t *testing.T, err error) {
t.Helper()

require.Error(t, err)
assert.Regexp(t, syscall.ESTALE.Error(), err.Error())
require.Contains(t, err.Error(), syscall.ESTALE.Error())
}

func ValidateESTALEOrEIOError(t *testing.T, err error) {
t.Helper()

require.Error(t, err)
// FUSE kernel driver can translate ESTALE to EIO (input/output error) on some operations/kernels.
// So we accept both "stale file handle" (ESTALE) and "input/output error" (EIO).
errStr := err.Error()
require.True(t, strings.Contains(errStr, syscall.ESTALE.Error()) || strings.Contains(errStr, syscall.EIO.Error()),
"Expected error to contain %q (ESTALE) or %q (EIO). Got: %v", syscall.ESTALE.Error(), syscall.EIO.Error(), err)
}

func ValidateEIOError(t *testing.T, err error) {
t.Helper()

require.Error(t, err)
assert.Regexp(t, syscall.EIO.Error(), err.Error())
require.Contains(t, err.Error(), syscall.EIO.Error())
}

func CheckErrorForReadOnlyFileSystem(t *testing.T, err error) {
Expand Down
Loading