Skip to content

Commit 014c171

Browse files
JoshVanLdapr-bot
andauthored
Test Integration: Fix flaky secret & state fuzz tests (dapr#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 <[email protected]> Co-authored-by: Dapr Bot <[email protected]>
1 parent 2ce5d5d commit 014c171

File tree

3 files changed

+3
-24
lines changed

3 files changed

+3
-24
lines changed

tests/integration/suite/daprd/secret/http/fuzz.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ import (
2222
"net/http"
2323
"net/url"
2424
"os"
25-
"regexp"
2625
"strings"
2726
"testing"
2827
"time"
2928

3029
fuzz "github.com/google/gofuzz"
3130
"github.com/stretchr/testify/assert"
3231
"github.com/stretchr/testify/require"
33-
"k8s.io/apimachinery/pkg/api/validation/path"
3432

3533
"github.com/dapr/dapr/tests/integration/framework"
3634
procdaprd "github.com/dapr/dapr/tests/integration/framework/process/daprd"
@@ -54,21 +52,8 @@ type fuzzsecret struct {
5452
func (f *fuzzsecret) Setup(t *testing.T) []framework.Option {
5553
const numTests = 1000
5654

57-
reg, err := regexp.Compile("^([a-zA-Z].*)$")
58-
require.NoError(t, err)
59-
6055
takenNames := make(map[string]bool)
61-
fz := fuzz.New().Funcs(func(s *string, c fuzz.Continue) {
62-
for *s == "" ||
63-
takenNames[*s] ||
64-
len(path.IsValidPathSegmentName(*s)) > 0 ||
65-
!reg.MatchString(*s) ||
66-
*s == "." {
67-
*s = c.RandString()
68-
}
69-
takenNames[*s] = true
70-
})
71-
fz.Fuzz(&f.secretStoreName)
56+
f.secretStoreName = util.RandomString(t, 10)
7257

7358
f.values = make(map[string]string)
7459
for i := 0; i < numTests; i++ {

tests/integration/suite/daprd/state/grpc/fuzz.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ func (f *fuzzstate) Setup(t *testing.T) []framework.Option {
9999
},
100100
}
101101

102-
for f.storeName == "" ||
103-
len(path.IsValidPathSegmentName(f.storeName)) > 0 {
104-
fuzz.New().Fuzz(&f.storeName)
105-
}
102+
f.storeName = util.RandomString(t, 10)
106103

107104
f.daprd = procdaprd.New(t, procdaprd.WithResourceFiles(fmt.Sprintf(`
108105
apiVersion: dapr.io/v1alpha1

tests/integration/suite/daprd/state/http/fuzz.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ func (f *fuzzstate) Setup(t *testing.T) []framework.Option {
109109
},
110110
}
111111

112-
for f.storeName == "" ||
113-
len(path.IsValidPathSegmentName(f.storeName)) > 0 {
114-
fuzz.New().Fuzz(&f.storeName)
115-
}
112+
f.storeName = util.RandomString(t, 10)
116113

117114
f.daprd = procdaprd.New(t, procdaprd.WithResourceFiles(fmt.Sprintf(`
118115
apiVersion: dapr.io/v1alpha1

0 commit comments

Comments
 (0)