Skip to content
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

reset counter 'watcher.libMatches' in SharedLibrarySuite.TestValidPathExistsInTheMemory() #34504

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion pkg/network/usm/sharedlibraries/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ func (s *SharedLibrarySuite) TestValidPathExistsInTheMemory() {
require.NoError(t, err)
watcher.Start()
t.Cleanup(watcher.Stop)
// the counter may be retrieved from the global registry, it must be reset.
watcher.libMatches.Set(0)

// Overriding PID, to allow the watcher to watch the test process
watcher.thisPID = 0

Expand All @@ -678,7 +681,7 @@ func (s *SharedLibrarySuite) TestValidPathExistsInTheMemory() {
// to avoid race conditions.
for i := 0; i < 10; i++ {
time.Sleep(100 * time.Millisecond)
assert.Zero(t, watcher.libHits.Get())
// the 'watcher.libHits' counter is incremented before rule matching and may be > 0, do not check it.
assert.Zero(t, watcher.libMatches.Get())
assert.Zero(t, registerRecorder.CallsForPathID(dummyPathID))
assert.Zero(t, registerRecorder.CallsForPathID(soPathID))
Expand Down