Skip to content

Commit

Permalink
Improved test
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Oct 23, 2024
1 parent 5985882 commit 52b3c25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
19 changes: 9 additions & 10 deletions direct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -856,7 +857,7 @@ func TestFindWorkingMasquerades(t *testing.T) {
}
return masquerades
}(),
expectedSuccessful: 10,
expectedSuccessful: 4,
},
}

Expand All @@ -870,18 +871,16 @@ func TestFindWorkingMasquerades(t *testing.T) {
d.masquerades[i] = m
}

d.findWorkingMasquerades()
var successful atomic.Uint32
d.vetGroup(0, 10, &successful)

time.Sleep(1000 * time.Millisecond)
var successful int
for _, m := range tt.masquerades {
// If it has a last succeeded time, it was successful
if !m.lastSucceededTime.IsZero() {
successful++
}
tries := 0
for successful.Load() < uint32(tt.expectedSuccessful) && tries < 100 {
time.Sleep(30 * time.Millisecond)
tries++
}

assert.GreaterOrEqual(t, successful, tt.expectedSuccessful)
assert.GreaterOrEqual(t, int(successful.Load()), tt.expectedSuccessful)
})
}
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ require (
github.com/go-stack/stack v1.8.1 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
Expand Down

0 comments on commit 52b3c25

Please sign in to comment.