Skip to content

feat(agent/agentcontainers): add file watcher and dirty status #17573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 29, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add atomic file replacement
  • Loading branch information
mafredri committed Apr 28, 2025
commit 0cbee38c20153463aa8133dc2b7b8814338446b0
20 changes: 20 additions & 0 deletions agent/agentcontainers/watcher/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ func TestFSNotifyWatcher(t *testing.T) {
break
}

err = os.WriteFile(testFile+".atomic", []byte(`{"test": "atomic"}`), 0o600)
require.NoError(t, err, "write new atomic test file failed")

err = os.Rename(testFile+".atomic", testFile)
require.NoError(t, err, "rename atomic test file failed")

// Verify that we receive the event we want.
for {
event, err := wut.Next(ctx)
require.NoError(t, err, "next event failed")
require.NotNil(t, event, "want non-nil event")
if !event.Has(fsnotify.Create) {
t.Logf("Ignoring event: %s", event)
continue
}
require.Truef(t, event.Has(fsnotify.Create), "want create event: %s", event.String())
require.Equal(t, event.Name, testFile, "want event for test file")
break
}

// Test removing the file from the watcher.
err = wut.Remove(testFile)
require.NoError(t, err, "remove file from watcher failed")
Expand Down
Loading