Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/mounting/static_mounting"
"github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/setup"
"github.com/googlecloudplatform/gcsfuse/v3/tools/integration_tests/util/test_suite"
"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -93,9 +94,7 @@ func hasInactiveReaderClosedLogLineInLogFile(t *testing.T, objectName, logFile s
expectedMsgSubstring := fmt.Sprintf("Closing reader for object %q due to inactivity.", objectName)

file, err := os.Open(logFile)
Comment thread
PranjalC100 marked this conversation as resolved.
if err != nil {
return "", fmt.Errorf("failed to open log file: %w", err)
}
require.NoError(t, err, "failed to open log file")
defer file.Close()

scanner := bufio.NewScanner(file)
Expand Down
18 changes: 15 additions & 3 deletions tools/integration_tests/util/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ func OverrideFilePathsInFlagSet(t *test_suite.TestConfig, GCSFuseTempDirPath str

func ParseLogFileFromFlags(flags []string) string {
for _, flagStr := range flags {
flagStr = strings.ReplaceAll(flagStr, ",", " ")
parts := strings.Fields(flagStr)
for _, part := range parts {
if strings.HasPrefix(part, "--log-file=") {
Expand All @@ -861,14 +862,25 @@ func ParseLogFileFromFlags(flags []string) string {
func SetUpLogFilePath(flags []string, GKETempDir string, OldGKElogFilePath string, cfg *test_suite.TestConfig) {
var logFilePath string
parsedLogFileName := ParseLogFileFromFlags(flags)
if cfg.GKEMountedDirectory != "" { // GKE path
logFilePath = path.Join(GKETempDir, parsedLogFileName) + ".log"

// Infer log filename directly from the parsed config block.
if parsedLogFileName == "" && cfg != nil && len(cfg.Configs) > 0 {
parsedLogFileName = ParseLogFileFromFlags(cfg.Configs[0].Flags)
}
Comment thread
PranjalC100 marked this conversation as resolved.

// Default logFile name.
if parsedLogFileName == "" {
parsedLogFileName = "gcsfuse-tmp.log"
}
Comment thread
meet2mky marked this conversation as resolved.

if cfg != nil && cfg.GKEMountedDirectory != "" { // GKE path
logFilePath = path.Join(GKETempDir, parsedLogFileName)
if ConfigFile() == "" {
// TODO: clean this up when GKE test migration completes.
logFilePath = OldGKElogFilePath
}
} else {
logFilePath = path.Join(TestDir(), GKETempDir, parsedLogFileName) + ".log"
logFilePath = path.Join(TestDir(), GKETempDir, parsedLogFileName)
}
cfg.LogFile = logFilePath
SetLogFile(logFilePath)
Expand Down
Loading