Skip to content

Commit

Permalink
[usm] reset counter 'watcher.libMatches' in SharedLibrarySuite.TestVa…
Browse files Browse the repository at this point in the history
…lidPathExistsInTheMemory()
  • Loading branch information
yuri-lipnesh committed Feb 26, 2025
1 parent 5d5b9ce commit f74581b
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit f74581b

Please sign in to comment.