Skip to content

Commit

Permalink
[chore] Ensure file is closed in Supervisor test (#35588)
Browse files Browse the repository at this point in the history
**Description:**

Follow up to
#35468.
This should fix issues like the following:

```
testing.go:1231: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestSupervisorInfoLoggingLevel3383092187\001\supervisor_log.log: The process cannot access the file because it is being used by another process.
```

I believe this error is caused by the temp directory doing a cleanup
before all `defer` statements can run, but I'm not sure. This is how
I've seen this error fixed in other tests.
  • Loading branch information
evan-bradley authored Oct 3, 2024
1 parent 2cb6696 commit 2e04885
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/opampsupervisor/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,6 @@ func TestSupervisorInfoLoggingLevel(t *testing.T) {
// Read from log file checking for Info level logs
logFile, err := os.Open(supervisorLogFilePath)
require.NoError(t, err)
defer logFile.Close()

scanner := bufio.NewScanner(logFile)
check := false
Expand All @@ -1434,6 +1433,7 @@ func TestSupervisorInfoLoggingLevel(t *testing.T) {
}
// verify at least 1 log was read
require.True(t, check)
require.NoError(t, logFile.Close())
}

func findRandomPort() (int, error) {
Expand Down

0 comments on commit 2e04885

Please sign in to comment.