From 014c1718603ed9b9fc4d29f0f52fb734514ef0a6 Mon Sep 17 00:00:00 2001 From: Josh van Leeuwen Date: Thu, 18 Apr 2024 17:38:50 +0100 Subject: [PATCH] Test Integration: Fix flaky secret & state fuzz tests (#7619) The current fuzz generator for the state and secret fuzz Component names can sometimes produce invalid names, making those tests flaky. Update name generation to always output a valid name. Signed-off-by: joshvanl Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> --- .../integration/suite/daprd/secret/http/fuzz.go | 17 +---------------- .../integration/suite/daprd/state/grpc/fuzz.go | 5 +---- .../integration/suite/daprd/state/http/fuzz.go | 5 +---- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/tests/integration/suite/daprd/secret/http/fuzz.go b/tests/integration/suite/daprd/secret/http/fuzz.go index 1c394592a58..48cba54f1db 100644 --- a/tests/integration/suite/daprd/secret/http/fuzz.go +++ b/tests/integration/suite/daprd/secret/http/fuzz.go @@ -22,7 +22,6 @@ import ( "net/http" "net/url" "os" - "regexp" "strings" "testing" "time" @@ -30,7 +29,6 @@ import ( fuzz "github.com/google/gofuzz" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "k8s.io/apimachinery/pkg/api/validation/path" "github.com/dapr/dapr/tests/integration/framework" procdaprd "github.com/dapr/dapr/tests/integration/framework/process/daprd" @@ -54,21 +52,8 @@ type fuzzsecret struct { func (f *fuzzsecret) Setup(t *testing.T) []framework.Option { const numTests = 1000 - reg, err := regexp.Compile("^([a-zA-Z].*)$") - require.NoError(t, err) - takenNames := make(map[string]bool) - fz := fuzz.New().Funcs(func(s *string, c fuzz.Continue) { - for *s == "" || - takenNames[*s] || - len(path.IsValidPathSegmentName(*s)) > 0 || - !reg.MatchString(*s) || - *s == "." { - *s = c.RandString() - } - takenNames[*s] = true - }) - fz.Fuzz(&f.secretStoreName) + f.secretStoreName = util.RandomString(t, 10) f.values = make(map[string]string) for i := 0; i < numTests; i++ { diff --git a/tests/integration/suite/daprd/state/grpc/fuzz.go b/tests/integration/suite/daprd/state/grpc/fuzz.go index b7f061160ad..a25b1065685 100644 --- a/tests/integration/suite/daprd/state/grpc/fuzz.go +++ b/tests/integration/suite/daprd/state/grpc/fuzz.go @@ -99,10 +99,7 @@ func (f *fuzzstate) Setup(t *testing.T) []framework.Option { }, } - for f.storeName == "" || - len(path.IsValidPathSegmentName(f.storeName)) > 0 { - fuzz.New().Fuzz(&f.storeName) - } + f.storeName = util.RandomString(t, 10) f.daprd = procdaprd.New(t, procdaprd.WithResourceFiles(fmt.Sprintf(` apiVersion: dapr.io/v1alpha1 diff --git a/tests/integration/suite/daprd/state/http/fuzz.go b/tests/integration/suite/daprd/state/http/fuzz.go index 3c88c284677..fa837dccdf3 100644 --- a/tests/integration/suite/daprd/state/http/fuzz.go +++ b/tests/integration/suite/daprd/state/http/fuzz.go @@ -109,10 +109,7 @@ func (f *fuzzstate) Setup(t *testing.T) []framework.Option { }, } - for f.storeName == "" || - len(path.IsValidPathSegmentName(f.storeName)) > 0 { - fuzz.New().Fuzz(&f.storeName) - } + f.storeName = util.RandomString(t, 10) f.daprd = procdaprd.New(t, procdaprd.WithResourceFiles(fmt.Sprintf(` apiVersion: dapr.io/v1alpha1