From 52b3c2531d958e6f1f391a4dc5713ebb57b037e8 Mon Sep 17 00:00:00 2001 From: Adam Fisk Date: Wed, 23 Oct 2024 15:39:27 -0600 Subject: [PATCH] Improved test --- direct_test.go | 19 +++++++++---------- go.mod | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/direct_test.go b/direct_test.go index 365ae33..88f84ad 100644 --- a/direct_test.go +++ b/direct_test.go @@ -15,6 +15,7 @@ import ( "path/filepath" "strconv" "strings" + "sync/atomic" "testing" "time" @@ -856,7 +857,7 @@ func TestFindWorkingMasquerades(t *testing.T) { } return masquerades }(), - expectedSuccessful: 10, + expectedSuccessful: 4, }, } @@ -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) }) } } diff --git a/go.mod b/go.mod index fcd0b1c..fc503af 100644 --- a/go.mod +++ b/go.mod @@ -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